gnodet-bot commented on code in PR #29454:
URL: https://github.com/apache/camel/pull/29454#discussion_r4513427197


##########
components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngineTest.java:
##########
@@ -80,6 +87,28 @@ void toolAddedBeforeStartIsQueuedWithoutNpe() {
         assertThatCode(() -> 
engine.toolRemoved("queued_tool")).doesNotThrowAnyException();
     }
 
+    @Test
+    void promptAddedBeforeStartIsFlushedWhenServerStarts() throws Exception {
+        StdioMcpServerEngine engine = new StdioMcpServerEngine();
+        engine.initialize(new 
org.apache.camel.component.mcp.server.McpServerInfo(
+                "test", "1.0", "/mcp", 0, 0, null, null, null, null, null));

Review Comment:
   💡 **Nit:** `McpServerInfo` is now imported (line 31), but the new test 
method still uses the FQN. Use the simple name:
   
   ```suggestion
           engine.initialize(new McpServerInfo(
                   "test", "1.0", "/mcp", 0, 0, null, null, null, null, null));
   ```



##########
components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngineTest.java:
##########
@@ -80,6 +87,28 @@ void toolAddedBeforeStartIsQueuedWithoutNpe() {
         assertThatCode(() -> 
engine.toolRemoved("queued_tool")).doesNotThrowAnyException();
     }
 
+    @Test
+    void promptAddedBeforeStartIsFlushedWhenServerStarts() throws Exception {
+        StdioMcpServerEngine engine = new StdioMcpServerEngine();
+        engine.initialize(new 
org.apache.camel.component.mcp.server.McpServerInfo(
+                "test", "1.0", "/mcp", 0, 0, null, null, null, null, null));
+        engine.setTransportStreams(new ByteArrayInputStream(new byte[0]), new 
ByteArrayOutputStream());
+        engine.promptAdded(samplePrompt("queued_prompt", "Queued before 
start"));
+
+        assertThatCode(engine::start).doesNotThrowAnyException();
+        engine.stop();
+    }
+
+    @Test
+    void promptRemovedBeforeStartRemovesItFromPendingQueue() {
+        StdioMcpServerEngine engine = new StdioMcpServerEngine();
+        engine.initialize(new 
org.apache.camel.component.mcp.server.McpServerInfo(
+                "test", "1.0", "/mcp", 0, 0, null, null, null, null, null));

Review Comment:
   💡 **Nit:** Same FQN issue in this test method — use the imported 
`McpServerInfo`:
   
   ```suggestion
           engine.initialize(new McpServerInfo(
                   "test", "1.0", "/mcp", 0, 0, null, null, null, null, null));
   ```



##########
components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngineTest.java:
##########
@@ -80,6 +87,28 @@ void toolAddedBeforeStartIsQueuedWithoutNpe() {
         assertThatCode(() -> 
engine.toolRemoved("queued_tool")).doesNotThrowAnyException();
     }
 
+    @Test
+    void promptAddedBeforeStartIsFlushedWhenServerStarts() throws Exception {
+        StdioMcpServerEngine engine = new StdioMcpServerEngine();
+        engine.initialize(new 
org.apache.camel.component.mcp.server.McpServerInfo(
+                "test", "1.0", "/mcp", 0, 0, null, null, null, null, null));
+        engine.setTransportStreams(new ByteArrayInputStream(new byte[0]), new 
ByteArrayOutputStream());
+        engine.promptAdded(samplePrompt("queued_prompt", "Queued before 
start"));
+
+        assertThatCode(engine::start).doesNotThrowAnyException();
+        engine.stop();
+    }
+
+    @Test
+    void promptRemovedBeforeStartRemovesItFromPendingQueue() {
+        StdioMcpServerEngine engine = new StdioMcpServerEngine();
+        engine.initialize(new 
org.apache.camel.component.mcp.server.McpServerInfo(
+                "test", "1.0", "/mcp", 0, 0, null, null, null, null, null));
+
+        engine.promptAdded(samplePrompt("ephemeral_prompt", "Removed before 
start"));
+        assertThatCode(() -> 
engine.promptRemoved("ephemeral_prompt")).doesNotThrowAnyException();

Review Comment:
   💡 **Low:** `promptRemovedBeforeStartRemovesItFromPendingQueue` only asserts 
no exception — it doesn't verify the prompt was actually removed from the 
pending queue. Without a state assertion this test is just a smoke check. 
Consider verifying the queue is empty after removal, e.g. by calling 
`promptAdded` again with the same name and asserting it succeeds (which would 
fail if the entry were still in the queue), or by exposing a package-visible 
`pendingPrompts` size for test inspection.
   
   Note: `promptAddedBeforeStartIsFlushedWhenServerStarts` has the same gap — 
it doesn't assert that the prompt is actually served by the started engine.



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