Skip to content

Commit fb70217

Browse files
committed
Add more schema tests
1 parent 3f3345e commit fb70217

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

mcp-test/src/test/java/io/modelcontextprotocol/spec/McpSchemaTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,16 @@ void testEnumSchemaOptionDeserialization() throws Exception {
17431743
assertThat(option.title()).isEqualTo("Low Priority");
17441744
}
17451745

1746+
@Test
1747+
void testEnumSchemaOptionDeserializationWithUnknownField() throws Exception {
1748+
var option = JSON_MAPPER.readValue("""
1749+
{
1750+
"futureField": 42
1751+
}""", McpSchema.EnumSchemaOption.class);
1752+
1753+
assertThat(option).isNotNull();
1754+
}
1755+
17461756
@Test
17471757
void testEnumSchemaOptionDeserializationWithBothFieldsMissing() throws Exception {
17481758
var option = JSON_MAPPER.readValue("{}", McpSchema.EnumSchemaOption.class);
@@ -1751,6 +1761,16 @@ void testEnumSchemaOptionDeserializationWithBothFieldsMissing() throws Exception
17511761
assertThat(option.title()).isEqualTo("");
17521762
}
17531763

1764+
@Test
1765+
void testEnumSchemaOptionsRequiredField() {
1766+
assertThatThrownBy(() -> new McpSchema.EnumSchemaOption("~~~", null))
1767+
.isInstanceOf(IllegalArgumentException.class)
1768+
.hasMessage("title must not be null");
1769+
assertThatThrownBy(() -> new McpSchema.EnumSchemaOption(null, "~~~"))
1770+
.isInstanceOf(IllegalArgumentException.class)
1771+
.hasMessage("constValue must not be null");
1772+
}
1773+
17541774
@Test
17551775
void testUntitledSingleSelectEnumSchemaSerialization() throws Exception {
17561776
var schema = new McpSchema.UntitledSingleSelectEnumSchema(null, "Choose a color",

0 commit comments

Comments
 (0)