diff --git a/tck/src/main/java/org/eclipse/microprofile/openapi/tck/ModelConstructionTest.java b/tck/src/main/java/org/eclipse/microprofile/openapi/tck/ModelConstructionTest.java index ae674fe9..410804d9 100644 --- a/tck/src/main/java/org/eclipse/microprofile/openapi/tck/ModelConstructionTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/openapi/tck/ModelConstructionTest.java @@ -43,6 +43,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Function; @@ -1018,7 +1019,16 @@ public void mediaTypeTest() { @SuppressWarnings("deprecation") // Testing deprecated Schema methods @Test public void schemaTest() { - final Schema s = processConstructible(Schema.class); + final Schema s = processConstructible(Schema.class, Set.of("booleanSchema")); + + s.setBooleanSchema(Boolean.TRUE); + assertSame(s.getBooleanSchema(), Boolean.TRUE, "Schema.getBooleanSchema should return the value that was set"); + Schema s2 = s.booleanSchema(Boolean.FALSE); + assertSame(s2, s, "Schema.booleanSchema should return the same object"); + assertSame(s.getBooleanSchema(), Boolean.FALSE, + "Schema.getBooleanSchema should return the value that was set with the builder method"); + s.setBooleanSchema(null); + assertNull(s.getBooleanSchema(), "Should be able to set Schema.booleanSchema to null"); final Schema ap = createConstructibleInstance(Schema.class); checkSameObject(s, s.additionalPropertiesSchema(ap)); @@ -1029,7 +1039,7 @@ public void schemaTest() { checkSameObject(s, s.additionalPropertiesBoolean(Boolean.TRUE)); assertEquals(s.getAdditionalPropertiesBoolean(), Boolean.TRUE, "AdditionalProperties (Boolean type) is expected to be true"); - Schema s2 = s.getAdditionalPropertiesSchema(); + s2 = s.getAdditionalPropertiesSchema(); assertNotNull(s2, "AdditionalProperties (Schema type) is expected to be non-null"); assertEquals(s2.getBooleanSchema(), Boolean.TRUE, "AdditionalProperties (Schema type) is expected to return a boolean-true schema"); @@ -1721,6 +1731,10 @@ public void tagTest() { } private T processConstructible(Class clazz) { + return processConstructible(clazz, Collections.emptySet()); + } + + private T processConstructible(Class clazz, Set propertiesToIgnore) { final T o = createConstructibleInstance(clazz); if (o instanceof Extensible && Extensible.class.isAssignableFrom(clazz)) { processExtensible((Extensible) o); @@ -1729,9 +1743,12 @@ private T processConstructible(Class clazz) { processReference((Reference) o); } final Map properties = collectProperties(clazz); - properties.values().stream().filter((p) -> p.isComplete()).forEach((p) -> { - processConstructibleProperty(o, p, clazz); - }); + properties.values().stream() + .filter((p) -> p.isComplete()) + .filter((p) -> !propertiesToIgnore.contains(p.getName())) + .forEach((p) -> { + processConstructibleProperty(o, p, clazz); + }); return o; }