-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from mkouba/detect-duplicate-names
Detect duplicate prompt/tool names
- Loading branch information
Showing
13 changed files
with
329 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
deployment/src/test/java/io/quarkiverse/mcp/server/test/serverinfo/CustomServerInfoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.quarkiverse.mcp.server.test.serverinfo; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import java.net.URISyntaxException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkiverse.mcp.server.test.McpClient; | ||
import io.quarkiverse.mcp.server.test.McpServerTest; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.vertx.core.json.JsonObject; | ||
|
||
public class CustomServerInfoTest extends McpServerTest { | ||
|
||
private static final String NAME = "Foo"; | ||
private static final String VERSION = "1.0"; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root.addClasses(McpClient.class)) | ||
.overrideConfigKey("quarkus.mcp-server.server-info.name", NAME) | ||
.overrideConfigKey("quarkus.mcp-server.server-info.version", VERSION); | ||
|
||
@Test | ||
public void testServerInfo() throws URISyntaxException { | ||
initClient(result -> { | ||
JsonObject serverInfo = result.getJsonObject("serverInfo"); | ||
assertNotNull(serverInfo); | ||
assertEquals(NAME, serverInfo.getString("name")); | ||
assertEquals(VERSION, serverInfo.getString("version")); | ||
}); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...oyment/src/test/java/io/quarkiverse/mcp/server/test/serverinfo/DefaultServerInfoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkiverse.mcp.server.test.serverinfo; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import java.net.URISyntaxException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkiverse.mcp.server.test.McpClient; | ||
import io.quarkiverse.mcp.server.test.McpServerTest; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.vertx.core.json.JsonObject; | ||
|
||
public class DefaultServerInfoTest extends McpServerTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root.addClasses(McpClient.class)); | ||
|
||
@Test | ||
public void testServerInfo() throws URISyntaxException { | ||
initClient(result -> { | ||
JsonObject serverInfo = result.getJsonObject("serverInfo"); | ||
assertNotNull(serverInfo); | ||
assertEquals("quarkus-mcp-server-deployment", serverInfo.getString("name")); | ||
assertEquals("999-SNAPSHOT", serverInfo.getString("version")); | ||
}); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ment/src/test/java/io/quarkiverse/mcp/server/test/validation/DuplicatePromptNameTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.quarkiverse.mcp.server.test.validation; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkiverse.mcp.server.Prompt; | ||
import io.quarkiverse.mcp.server.PromptResponse; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class DuplicatePromptNameTest { | ||
|
||
@RegisterExtension | ||
public static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> { | ||
root.addClasses(InvalidPrompts.class); | ||
}) | ||
.setExpectedException(IllegalStateException.class, true); | ||
|
||
@Test | ||
public void test() { | ||
fail(); | ||
} | ||
|
||
public static class InvalidPrompts { | ||
|
||
@Prompt | ||
PromptResponse foo() { | ||
return null; | ||
} | ||
|
||
@Prompt(name = "foo") | ||
PromptResponse foos() { | ||
return null; | ||
} | ||
|
||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...oyment/src/test/java/io/quarkiverse/mcp/server/test/validation/DuplicateToolNameTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.quarkiverse.mcp.server.test.validation; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkiverse.mcp.server.Tool; | ||
import io.quarkiverse.mcp.server.ToolResponse; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class DuplicateToolNameTest { | ||
|
||
@RegisterExtension | ||
public static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> { | ||
root.addClasses(InvalidTools.class); | ||
}) | ||
.setExpectedException(IllegalStateException.class, true); | ||
|
||
@Test | ||
public void test() { | ||
fail(); | ||
} | ||
|
||
public static class InvalidTools { | ||
|
||
@Tool | ||
ToolResponse foo() { | ||
return null; | ||
} | ||
|
||
@Tool(name = "foo") | ||
ToolResponse foos() { | ||
return null; | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.