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


##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/McpFacadeGetFilesTest.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.tui;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * {@code camel_get_files} on the selected integration: an exported Spring 
Boot project is a Maven layout, and the
+ * running routes point at the files under {@code src/main}, so a model finds 
the route file in one call instead of
+ * guessing names in the wrong folder (CAMEL-24798).
+ */
+class McpFacadeGetFilesTest {
+
+    private static final String ROUTE = "- route:\n    id: timer-log\n    
from:\n      uri: timer:tick\n"
+                                        + "      steps:\n        - log:\n      
      message: hi\n";
+
+    private static McpFacade facade(Path projectDir, String routeSource) {
+        IntegrationInfo info = new IntegrationInfo();
+        info.name = "timer-log";
+        info.pid = "1";
+        info.directory = projectDir.toString();
+        RouteInfo route = new RouteInfo();
+        route.routeId = "timer-log";

Review Comment:
   Added in fc6d78aa4c75: `aRouteWithoutAnIdIsListedByItsFileAlone` builds a 
`RouteInfo` with a null `routeId`, calls `facade.getFiles("timer-log", null)` 
and asserts the route entry carries `file` but no `routeId` key. The `facade()` 
helper got a `routeId` parameter for it.
   
   _Claude Code on behalf of davsclaus_



##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/McpFacadeGetFilesTest.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.tui;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * {@code camel_get_files} on the selected integration: an exported Spring 
Boot project is a Maven layout, and the
+ * running routes point at the files under {@code src/main}, so a model finds 
the route file in one call instead of
+ * guessing names in the wrong folder (CAMEL-24798).
+ */
+class McpFacadeGetFilesTest {
+
+    private static final String ROUTE = "- route:\n    id: timer-log\n    
from:\n      uri: timer:tick\n"
+                                        + "      steps:\n        - log:\n      
      message: hi\n";
+
+    private static McpFacade facade(Path projectDir, String routeSource) {
+        IntegrationInfo info = new IntegrationInfo();
+        info.name = "timer-log";
+        info.pid = "1";
+        info.directory = projectDir.toString();
+        RouteInfo route = new RouteInfo();
+        route.routeId = "timer-log";
+        route.source = routeSource;
+        info.routes.add(route);
+        return new McpFacade(
+                null, new AtomicReference<>(List.of(info)), null, null, null, 
null, null, null, null, null, null,
+                null, null);
+    }
+
+    @Test
+    void 
anExportedProjectListsItsRouteFileAndWhereTheRunningRouteComesFrom(@TempDir 
Path dir) throws IOException {
+        Files.createDirectories(dir.resolve("src/main/resources/camel"));
+        Files.createDirectories(dir.resolve("target/classes/camel"));
+        Files.writeString(dir.resolve("pom.xml"), "<project/>");
+        
Files.writeString(dir.resolve("src/main/resources/camel/timer-log.camel.yaml"), 
ROUTE);
+        
Files.writeString(dir.resolve("src/main/resources/application.properties"), 
"camel.main.name=timer-log\n");
+        
Files.writeString(dir.resolve("target/classes/camel/timer-log.camel.yaml"), 
ROUTE);
+        McpFacade facade = facade(dir, "nested:" + dir
+                                       + 
"/target/timer-log-1.0-SNAPSHOT.jar/!BOOT-INF/classes/!/camel/timer-log.camel.yaml:4");
+
+        JsonObject list = facade.getFiles("timer-log", null);
+
+        assertNotNull(list);
+        assertEquals("maven", list.getString("layout"));
+        assertEquals(List.of("src/main/resources/camel/timer-log.camel.yaml"), 
list.getCollection("routeFiles"));
+        assertEquals(dir.toString(), list.getString("directory"));

Review Comment:
   Added in fc6d78aa4c75: `aRouteWithoutAnIdIsListedByItsFileAlone` builds a 
`RouteInfo` with a null `routeId`, calls `facade.getFiles("timer-log", null)` 
and asserts the route entry carries `file` but no `routeId` key. The `facade()` 
helper got a `routeId` parameter for it.
   
   _Claude Code on behalf of davsclaus_



-- 
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