davsclaus commented on code in PR #22830:
URL: https://github.com/apache/camel/pull/22830#discussion_r3161325946


##########
dsl/camel-jbang/camel-jbang-mcp/src/test/java/org/apache/camel/dsl/jbang/core/commands/mcp/ConfigurationValidateToolsTest.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.mcp;
+
+import java.util.Optional;
+
+import io.quarkiverse.mcp.server.ToolCallException;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class ConfigurationValidateToolsTest {
+
+    private ConfigurationValidateTools createTools() {
+        CatalogService catalogService = new CatalogService();
+        catalogService.catalogRepos = Optional.empty();
+
+        ConfigurationValidateTools tools = new ConfigurationValidateTools();
+        tools.catalogService = catalogService;
+        return tools;
+    }
+
+    @Test
+    void validatesValidMainProperty() {
+        ConfigurationValidateTools tools = createTools();
+
+        ConfigurationValidateTools.ConfigurationValidateResult result
+                = 
tools.camel_configuration_validate("camel.main.streamCachingEnabled=true", 
null, null, null);
+
+        assertThat(result).isNotNull();
+        assertThat(result.camelVersion()).isNotNull();
+        assertThat(result.summary().total()).isEqualTo(1);
+        assertThat(result.summary().valid()).isEqualTo(1);
+        assertThat(result.summary().errors()).isZero();
+        assertThat(result.properties()).hasSize(1);
+
+        ConfigurationValidateTools.PropertyValidationInfo info = 
result.properties().get(0);
+        assertThat(info.lineNumber()).isEqualTo(1);
+        assertThat(info.accepted()).isTrue();
+        assertThat(info.valid()).isTrue();
+        assertThat(info.errors()).isZero();
+        assertThat(info.issues()).isEmpty();
+    }
+
+    @Test
+    void detectsUnknownOption() {
+        ConfigurationValidateTools tools = createTools();
+
+        ConfigurationValidateTools.ConfigurationValidateResult result
+                = 
tools.camel_configuration_validate("camel.main.streamCachngEnabled=true", null, 
null, null);
+
+        assertThat(result.summary().errors()).isPositive();
+        ConfigurationValidateTools.PropertyValidationInfo info = 
result.properties().get(0);
+        assertThat(info.valid()).isFalse();
+        assertThat(info.issues()).anyMatch(i -> "unknown".equals(i.kind()));
+    }
+
+    @Test
+    void detectsInvalidBoolean() {
+        ConfigurationValidateTools tools = createTools();
+
+        ConfigurationValidateTools.ConfigurationValidateResult result
+                = 
tools.camel_configuration_validate("camel.main.streamCachingEnabled=notabool", 
null, null, null);

Review Comment:
   Can you add a new test for a placeholder value 
   
   `camel.main.streamCachingEnabled={{myCacheEnabled}}`
   
   As this should be an accepted value for any kind of type: string, int, 
boolean, and so on



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to