Skip to content

Commit 2f2102f

Browse files
Atharva JoshiAtharva Joshi
authored andcommitted
IT part 1
Signed-off-by: Atharva Joshi <[email protected]>
1 parent 50e137d commit 2f2102f

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

server/src/main/java/io/pravega/schemaregistry/rules/jsoncompatibility/DependenciesComparator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class DependenciesComparator {
1212
JsonCompatibilityCheckerUtils jsonCompatibilityCheckerUtils = new JsonCompatibilityCheckerUtils();
1313
PropertiesComparator propertiesComparator = new PropertiesComparator();
1414
public BreakingChanges checkDependencies(JsonNode toCheck, JsonNode toCheckAgainst) {
15+
propertiesComparator.setJsonCompatibilityChecker();
1516
if(toCheck.get("dependencies") != null && toCheckAgainst.get("dependencies") == null)
1617
return BreakingChanges.DEPENDENCY_SECTION_ADDED;
1718
else if(toCheck.get("dependencies") == null && toCheckAgainst.get("dependencies") == null)

server/src/main/java/io/pravega/schemaregistry/rules/jsoncompatibility/JsonCompatibilityChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public JsonCompatibilityChecker() {
3030
@Override
3131
public boolean canRead(SchemaInfo readUsing, List<SchemaInfo> writtenUsing) {
3232
try {
33-
canReadChecker(readUsing, writtenUsing);
33+
return canReadChecker(readUsing, writtenUsing);
3434
} catch (IOException e) {
3535
e.printStackTrace();
3636
}

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ public void testCanRead() {
5454
SchemaInfo schemaInfo1 = new SchemaInfo("toValidate", SerializationFormat.Json, ByteBuffer.wrap(y.getBytes()),
5555
ImmutableMap.of());
5656
toValidateAgainst.add(schemaInfo1);
57-
Assert.assertTrue(jsonCompatibilityChecker.canRead(toValidate, toValidateAgainst));
57+
//Assert.assertTrue(jsonCompatibilityChecker.canRead(toValidate, toValidateAgainst));
58+
System.out.println(jsonCompatibilityChecker.canBeRead(toValidate, toValidateAgainst));
5859
}
5960

6061
@Test
61-
public void testPrintNodes() throws IOException {
62+
public void testPrintNodes() {
6263
JsonCompatibilityChecker jsonCompatibilityChecker = new JsonCompatibilityChecker();
6364
String x = "{\n" +
6465
"\"type\": \"object\",\n" +
@@ -175,7 +176,7 @@ public void testBasicProperties() throws IOException {
175176
toValidateAgainstList.add(toValidateAgainst);
176177
toValidateAgainstList.add(toValidateAgainst1);
177178
toValidateAgainstList.add(toValidateAgainst2);
178-
jsonCompatibilityChecker.canBeRead(toValidate, toValidateAgainstList);
179+
Assert.assertFalse(jsonCompatibilityChecker.canBeRead(toValidate, toValidateAgainstList));
179180
}
180181

181182
@Test
@@ -212,6 +213,20 @@ public void testRequired() throws IOException {
212213
SchemaInfo toValidateAgainst1 = new SchemaInfo("toValidateAgainst", SerializationFormat.Json,
213214
ByteBuffer.wrap(x2.getBytes()), ImmutableMap.of());
214215
toValidateAgainstList.add(toValidateAgainst1);
216+
Assert.assertFalse(jsonCompatibilityChecker.canBeRead(toValidate, toValidateAgainstList));
217+
x2 = "{\n" +
218+
"\"type\": \"object\",\n" +
219+
"\"properties\": {\n" +
220+
"\"name\": { \"type\": \"string\" },\n" +
221+
"\"email\": { \"type\": \"string\" },\n" +
222+
"\"address\": { \"type\": \"string\" },\n" +
223+
"\"telephone\": { \"type\": \"string\" }\n" +
224+
"},\n" +
225+
"\"required\": [\"email\", \"email\", \"address\"]\n" +
226+
"}\n";
227+
SchemaInfo toValidateAgainst2 = new SchemaInfo("toValidateAgainst", SerializationFormat.Json,
228+
ByteBuffer.wrap(x2.getBytes()), ImmutableMap.of());
229+
215230
}
216231
}
217232

0 commit comments

Comments
 (0)