Skip to content

Commit

Permalink
integration test - dynamic properties
Browse files Browse the repository at this point in the history
Signed-off-by: Atharva Joshi <[email protected]>
  • Loading branch information
Atharva Joshi authored and Atharva Joshi committed Nov 6, 2020
1 parent a4335da commit 619c081
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SchemaInfo> toValidateAgainstList = new ArrayList<>();
toValidateAgainstList.add(toValidateAgainst);
Assert.assertFalse(jsonCompatibilityChecker.canRead(toValidate, toValidateAgainstList));
Assert.assertFalse(jsonCompatibilityChecker.canBeRead(toValidate, toValidateAgainstList));
}
}

0 comments on commit 619c081

Please sign in to comment.