75 lines
2.8 KiB
Java
75 lines
2.8 KiB
Java
package io.shinhanlife.dap.biz.mcp;
|
|
|
|
import io.shinhanlife.dap.biz.mcp.config.McpProperties;
|
|
import io.shinhanlife.dap.biz.mcp.context.McpRequestContext;
|
|
import io.shinhanlife.dap.biz.mcp.registry.ToolMetadata;
|
|
|
|
import java.time.Instant;
|
|
import java.util.List;
|
|
|
|
import tools.jackson.databind.ObjectMapper;
|
|
|
|
public final class TestFixtures {
|
|
|
|
public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
|
|
|
private TestFixtures() {
|
|
}
|
|
|
|
public static McpProperties properties(boolean redisEnabled, boolean forwardAuthorization) {
|
|
return properties(redisEnabled, forwardAuthorization, List.of());
|
|
}
|
|
|
|
public static McpProperties properties(
|
|
boolean redisEnabled, boolean forwardAuthorization, List<McpProperties.Bundle> bundles) {
|
|
return new McpProperties(
|
|
"mcp-test",
|
|
"/mcp",
|
|
new McpProperties.Server("shl-axhub-mcp-server", "SHL AX HUB MCP Server", "1.0.0"),
|
|
new McpProperties.Registry(
|
|
"file:./config/local-core-tools-manifest-sample-v1.json", 30, 5),
|
|
new McpProperties.ToolClient(1_000, 5_000, 300_000, forwardAuthorization),
|
|
new McpProperties.Redis(redisEnabled, "test:mcp:tools"),
|
|
new McpProperties.Trace(true, 1_048_576),
|
|
new McpProperties.Protocol(List.of("2025-06-18"), "2025-06-18"),
|
|
new McpProperties.Discovery(!bundles.isEmpty(), 1_000, 3_000, 100, 200, 1_048_576, 30_000),
|
|
bundles);
|
|
}
|
|
|
|
public static McpProperties.Bundle bundle(
|
|
String id, String manifestUrl, String baseEndpoint, String namePrefix) {
|
|
return new McpProperties.Bundle(id, manifestUrl, baseEndpoint, namePrefix, true, null);
|
|
}
|
|
|
|
public static McpRequestContext context() {
|
|
return new McpRequestContext(
|
|
"req-1",
|
|
"guid-1",
|
|
"session-1",
|
|
"ENC(employee-1)",
|
|
"ENC(virtual-1)",
|
|
"Bearer test-token",
|
|
Instant.parse("2030-01-01T00:00:00Z"));
|
|
}
|
|
|
|
public static ToolMetadata tool(String endpoint) {
|
|
try {
|
|
return new ToolMetadata(
|
|
"customer.search",
|
|
"1.0.0",
|
|
"Search customer information",
|
|
endpoint,
|
|
OBJECT_MAPPER.readTree(
|
|
"""
|
|
{"type":"object","properties":{"customerNo":{"type":"string"}},
|
|
"required":["customerNo"]}
|
|
"""),
|
|
3_000,
|
|
true,
|
|
null);
|
|
} catch (Exception exception) {
|
|
throw new IllegalStateException(exception);
|
|
}
|
|
}
|
|
}
|