Skip to content

Commit 619c081

Browse files
Atharva JoshiAtharva Joshi
authored andcommitted
integration test - dynamic properties
Signed-off-by: Atharva Joshi <[email protected]>
1 parent a4335da commit 619c081

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

server/src/test/java/io/pravega/schemaregistry/rules/jsoncompatibility/JsonCompatibilityCheckerTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,5 +249,39 @@ public void testRequired() throws IOException {
249249
Assert.assertFalse(jsonCompatibilityChecker.canRead(toValidate, toValidateAgainstList));
250250
Assert.assertTrue(jsonCompatibilityChecker.canBeRead(toValidate, toValidateAgainstList));
251251
}
252+
253+
@Test
254+
public void testDynamicProperties() {
255+
JsonCompatibilityChecker jsonCompatibilityChecker = new JsonCompatibilityChecker();
256+
String x1 = "{\n" +
257+
"\"type\": \"object\",\n" +
258+
"\"properties\": {\n" +
259+
"\"name\": { \"type\": \"string\" },\n" +
260+
"\"email\": { \"type\": \"string\" },\n" +
261+
"\"address\": { \"type\": \"string\" },\n" +
262+
"\"telephone\": { \"type\": \"string\" }\n" +
263+
"},\n" +
264+
"\"additionalProperties\": { \"type\": \"string\" }\n" +
265+
"}\n";
266+
String x2 = "{\n" +
267+
"\"type\": \"object\",\n" +
268+
"\"properties\": {\n" +
269+
"\"name\": { \"type\": \"string\" },\n" +
270+
"\"email\": { \"type\": \"string\" },\n" +
271+
"\"address\": { \"type\": \"string\" },\n" +
272+
"\"telephone\": { \"type\": \"string\" },\n" +
273+
"\"SSN\": { \"type\": \"number\" }\n" +
274+
"},\n" +
275+
"\"additionalProperties\": { \"type\": \"string\" }\n" +
276+
"}\n";
277+
SchemaInfo toValidate = new SchemaInfo("toValidate", SerializationFormat.Json, ByteBuffer.wrap(x1.getBytes()),
278+
ImmutableMap.of());
279+
SchemaInfo toValidateAgainst = new SchemaInfo("toValidateAgainst", SerializationFormat.Json,
280+
ByteBuffer.wrap(x2.getBytes()), ImmutableMap.of());
281+
List<SchemaInfo> toValidateAgainstList = new ArrayList<>();
282+
toValidateAgainstList.add(toValidateAgainst);
283+
Assert.assertFalse(jsonCompatibilityChecker.canRead(toValidate, toValidateAgainstList));
284+
Assert.assertFalse(jsonCompatibilityChecker.canBeRead(toValidate, toValidateAgainstList));
285+
}
252286
}
253287

0 commit comments

Comments
 (0)