use of com.linkedin.data.schema.compatibility.CompatibilityOptions in project rest.li by linkedin.
the class TestCompatibilityChecker method testCompatibility.
private void testCompatibility(String olderSchemaText, String newerSchemaText, List<CompatibilityOptions> compatibilityOptions, boolean hasError, Object[] expected, int expectedIndex) throws IOException {
if (_debug)
out.println(olderSchemaText + "\n" + newerSchemaText);
DataSchema olderSchema = TestUtil.dataSchemaFromString(olderSchemaText);
DataSchema newerSchema = TestUtil.dataSchemaFromString(newerSchemaText);
assertNotNull(olderSchema, olderSchemaText);
assertNotNull(newerSchema, newerSchemaText);
for (CompatibilityOptions option : compatibilityOptions) {
CompatibilityResult result = CompatibilityChecker.checkCompatibility(olderSchema, newerSchema, option);
String messageText = result.getMessages().toString();
if (_debug)
out.println(result);
assertEquals(result.isError(), hasError, olderSchemaText + "\n" + newerSchemaText + "\n" + messageText);
for (int i = expectedIndex; i < expected.length; i++) {
String expectedText = ".*" + expected[i] + "\n.*";
if (_debug)
out.println(expectedText);
Pattern pattern = Pattern.compile(expectedText, Pattern.DOTALL);
Matcher matcher = pattern.matcher(messageText);
boolean matches = matcher.matches();
assertTrue(matches, messageText + "\n" + expectedText);
}
}
}
Aggregations