@@ -55,14 +55,9 @@ public void testEqualCase() {
5555 SchemaInfo schemaInfo1 = new SchemaInfo ("toValidate" , SerializationFormat .Json , ByteBuffer .wrap (y .getBytes ()),
5656 ImmutableMap .of ());
5757 toValidateAgainst .add (schemaInfo1 );
58- boolean canRead = jsonCompatibilityChecker .canRead (toValidate , toValidateAgainst );
59- Assert .assertTrue (canRead );
58+ Assert .assertTrue (jsonCompatibilityChecker .canRead (toValidate , toValidateAgainst ));
6059 //CanBeRead
61- boolean canBeRead = toValidateAgainst .stream ().map (p -> jsonCompatibilityChecker .canBeRead (p ,
62- Collections .singletonList (toValidate ))).allMatch (p -> p .equals (true ));
63- Assert .assertTrue (canBeRead );
64- // canMutuallyRead
65- Assert .assertTrue (canRead && canBeRead );
60+ Assert .assertTrue (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainst ));
6661 }
6762
6863 @ Test
@@ -113,8 +108,11 @@ public void testDependencies() {
113108 List <SchemaInfo > toValidateAgainst = new ArrayList <>();
114109 toValidateAgainst .add (toValidate );
115110 Assert .assertTrue (jsonCompatibilityChecker .canRead (toValidate , toValidateAgainst ));
111+ // canBeRead
112+ Assert .assertTrue (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainst ));
116113 toValidateAgainst .add (schemaInfo1 );
117114 Assert .assertTrue (jsonCompatibilityChecker .canRead (toValidate , toValidateAgainst ));
115+ Assert .assertFalse (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainst ));
118116 String z = "{\n " +
119117 "\" type\" : \" object\" ,\n " +
120118 "\" properties\" : {\n " +
@@ -135,6 +133,7 @@ public void testDependencies() {
135133 ByteBuffer .wrap (z .getBytes ()), ImmutableMap .of ());
136134 toValidateAgainst .add (schemaInfo11 );
137135 Assert .assertFalse (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainst ));
136+ Assert .assertFalse (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainst ));
138137 }
139138
140139 @ Test
@@ -164,6 +163,7 @@ public void testBasicProperties() throws IOException {
164163 List <SchemaInfo > toValidateAgainstList = new ArrayList <>();
165164 toValidateAgainstList .add (toValidateAgainst );
166165 Assert .assertTrue (jsonCompatibilityChecker .canRead (toValidate , toValidateAgainstList ));
166+ Assert .assertTrue (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainstList ));
167167 //different properties
168168 x2 = "{\n " +
169169 "\" type\" : \" object\" ,\n " +
@@ -177,6 +177,7 @@ public void testBasicProperties() throws IOException {
177177 ByteBuffer .wrap (x2 .getBytes ()), ImmutableMap .of ());
178178 toValidateAgainstList .add (toValidateAgainst1 );
179179 Assert .assertFalse (jsonCompatibilityChecker .canRead (toValidate , toValidateAgainstList ));
180+ Assert .assertFalse (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainstList ));
180181 //different property values
181182 x2 = "{\n " +
182183 "\" type\" : \" object\" ,\n " +
@@ -190,6 +191,7 @@ public void testBasicProperties() throws IOException {
190191 ByteBuffer .wrap (x2 .getBytes ()), ImmutableMap .of ());
191192 toValidateAgainstList .add (toValidateAgainst2 );
192193 Assert .assertFalse (jsonCompatibilityChecker .canRead (toValidate , toValidateAgainstList ));
194+ Assert .assertFalse (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainstList ));
193195 }
194196
195197 @ Test
@@ -213,6 +215,7 @@ public void testRequired() throws IOException {
213215 List <SchemaInfo > toValidateAgainstList = new ArrayList <>();
214216 toValidateAgainstList .add (toValidateAgainst );
215217 Assert .assertTrue (jsonCompatibilityChecker .canRead (toValidate , toValidateAgainstList ));
218+ Assert .assertTrue (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainstList ));
216219 //remove required array element
217220 String x2 = "{\n " +
218221 "\" type\" : \" object\" ,\n " +
@@ -228,6 +231,7 @@ public void testRequired() throws IOException {
228231 ByteBuffer .wrap (x2 .getBytes ()), ImmutableMap .of ());
229232 toValidateAgainstList .add (toValidateAgainst1 );
230233 Assert .assertTrue (jsonCompatibilityChecker .canRead (toValidate , toValidateAgainstList ));
234+ Assert .assertFalse (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainstList ));
231235 x2 = "{\n " +
232236 "\" type\" : \" object\" ,\n " +
233237 "\" properties\" : {\n " +
@@ -236,13 +240,14 @@ public void testRequired() throws IOException {
236240 "\" address\" : { \" type\" : \" string\" },\n " +
237241 "\" telephone\" : { \" type\" : \" string\" }\n " +
238242 "},\n " +
239- "\" required\" : [\" address \" ]\n " +
243+ "\" required\" : [\" name \" ]\n " +
240244 "}\n " ;
241245 SchemaInfo toValidateAgainst2 = new SchemaInfo ("toValidateAgainst" , SerializationFormat .Json ,
242246 ByteBuffer .wrap (x2 .getBytes ()), ImmutableMap .of ());
243247 toValidateAgainstList .clear ();
244248 toValidateAgainstList .add (toValidateAgainst2 );
245- Assert .assertFalse (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainstList ));
249+ Assert .assertFalse (jsonCompatibilityChecker .canRead (toValidate , toValidateAgainstList ));
250+ Assert .assertTrue (jsonCompatibilityChecker .canBeRead (toValidate , toValidateAgainstList ));
246251 }
247252}
248253
0 commit comments