test: keep input schemas in tool modules
All checks were successful
Deploy to OCIWP / deploy (push) Successful in 1m56s
All checks were successful
Deploy to OCIWP / deploy (push) Successful in 1m56s
This commit is contained in:
@@ -3,7 +3,12 @@ package io.shinhanlife.dap.mcc.biz.cmm.dto;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.shinhanlife.dap.lib.annotation.McpFunction;
|
||||
import io.shinhanlife.dap.lib.util.JsonSchemaGenerator;
|
||||
import io.shinhanlife.dap.lib.util.ToolSchemaResolver;
|
||||
import io.shinhanlife.dap.mcc.biz.cmm.usecase.ClaimSearchSchemaSampleUseCase;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -24,8 +29,26 @@ class ClaimSearchRequestSchemaTest {
|
||||
Map.of("required", List.of("contractNo"))), schema.get("anyOf"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolvesSchemaFromToolModuleResource() throws Exception {
|
||||
Method method = ClaimSearchSchemaSampleUseCase.class
|
||||
.getDeclaredMethod("search", ClaimSearchRequest.class);
|
||||
McpFunction function = method.getAnnotation(McpFunction.class);
|
||||
|
||||
Map<String, Object> schema = new ToolSchemaResolver(new ObjectMapper())
|
||||
.resolve(function, ClaimSearchRequest.class);
|
||||
|
||||
assertEquals("https://json-schema.org/draft/2020-12/schema", schema.get("$schema"));
|
||||
assertTrue(schema.containsKey("anyOf"));
|
||||
assertEquals(50, property(schema, "size").get("maximum"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<String, Map<String, Object>> properties(Map<String, Object> schema) {
|
||||
return (Map<String, Map<String, Object>>) schema.get("properties");
|
||||
}
|
||||
|
||||
private Map<String, Object> property(Map<String, Object> schema, String name) {
|
||||
return properties(schema).get(name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user