From 619c08113541bb72becffa3f7c3bf00229b27ca9 Mon Sep 17 00:00:00 2001 From: Atharva Joshi Date: Thu, 5 Nov 2020 13:24:52 +0530 Subject: [PATCH] integration test - dynamic properties Signed-off-by: Atharva Joshi --- .../JsonCompatibilityCheckerTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/server/src/test/java/io/pravega/schemaregistry/rules/jsoncompatibility/JsonCompatibilityCheckerTest.java b/server/src/test/java/io/pravega/schemaregistry/rules/jsoncompatibility/JsonCompatibilityCheckerTest.java index 1c0ccd5d2..15cbd378e 100644 --- a/server/src/test/java/io/pravega/schemaregistry/rules/jsoncompatibility/JsonCompatibilityCheckerTest.java +++ b/server/src/test/java/io/pravega/schemaregistry/rules/jsoncompatibility/JsonCompatibilityCheckerTest.java @@ -249,5 +249,39 @@ public void testRequired() throws IOException { Assert.assertFalse(jsonCompatibilityChecker.canRead(toValidate, toValidateAgainstList)); Assert.assertTrue(jsonCompatibilityChecker.canBeRead(toValidate, toValidateAgainstList)); } + + @Test + public void testDynamicProperties() { + JsonCompatibilityChecker jsonCompatibilityChecker = new JsonCompatibilityChecker(); + String x1 = "{\n" + + "\"type\": \"object\",\n" + + "\"properties\": {\n" + + "\"name\": { \"type\": \"string\" },\n" + + "\"email\": { \"type\": \"string\" },\n" + + "\"address\": { \"type\": \"string\" },\n" + + "\"telephone\": { \"type\": \"string\" }\n" + + "},\n" + + "\"additionalProperties\": { \"type\": \"string\" }\n" + + "}\n"; + String x2 = "{\n" + + "\"type\": \"object\",\n" + + "\"properties\": {\n" + + "\"name\": { \"type\": \"string\" },\n" + + "\"email\": { \"type\": \"string\" },\n" + + "\"address\": { \"type\": \"string\" },\n" + + "\"telephone\": { \"type\": \"string\" },\n" + + "\"SSN\": { \"type\": \"number\" }\n" + + "},\n" + + "\"additionalProperties\": { \"type\": \"string\" }\n" + + "}\n"; + SchemaInfo toValidate = new SchemaInfo("toValidate", SerializationFormat.Json, ByteBuffer.wrap(x1.getBytes()), + ImmutableMap.of()); + SchemaInfo toValidateAgainst = new SchemaInfo("toValidateAgainst", SerializationFormat.Json, + ByteBuffer.wrap(x2.getBytes()), ImmutableMap.of()); + List toValidateAgainstList = new ArrayList<>(); + toValidateAgainstList.add(toValidateAgainst); + Assert.assertFalse(jsonCompatibilityChecker.canRead(toValidate, toValidateAgainstList)); + Assert.assertFalse(jsonCompatibilityChecker.canBeRead(toValidate, toValidateAgainstList)); + } } \ No newline at end of file