Search in sources :

Example 16 with CompatibilityInfo

use of com.linkedin.restli.tools.idlcheck.CompatibilityInfo in project rest.li by linkedin.

the class TestResourceCompatibilityChecker method testPassAssociationFile.

@Test
public void testPassAssociationFile() throws IOException {
    final Collection<CompatibilityInfo> testDiffs = new HashSet<CompatibilityInfo>();
    testDiffs.add(new CompatibilityInfo(Arrays.<Object>asList("", "association", "methods", "create", "parameters"), CompatibilityInfo.Type.PARAMETER_NEW_OPTIONAL, "type"));
    final ResourceSchema prevResource = idlToResource(IDLS_SUFFIX + PREV_ASSOC_FILE);
    final ResourceSchema currResource = idlToResource(IDLS_SUFFIX + CURR_ASSOC_PASS_FILE);
    ResourceCompatibilityChecker checker = new ResourceCompatibilityChecker(prevResource, prevSchemaResolver, currResource, prevSchemaResolver);
    Assert.assertTrue(checker.check(CompatibilityLevel.BACKWARDS));
    final Collection<CompatibilityInfo> incompatibles = checker.getInfoMap().getIncompatibles();
    final Collection<CompatibilityInfo> compatibles = new HashSet<CompatibilityInfo>(checker.getInfoMap().getCompatibles());
    for (CompatibilityInfo di : testDiffs) {
        Assert.assertTrue(compatibles.contains(di), "Reported compatibles should contain: " + di.toString());
        compatibles.remove(di);
    }
    Assert.assertTrue(incompatibles.isEmpty());
    Assert.assertTrue(compatibles.isEmpty());
}
Also used : ResourceSchema(com.linkedin.restli.restspec.ResourceSchema) CompatibilityInfo(com.linkedin.restli.tools.idlcheck.CompatibilityInfo) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

CompatibilityInfo (com.linkedin.restli.tools.idlcheck.CompatibilityInfo)16 HashSet (java.util.HashSet)11 Test (org.testng.annotations.Test)11 ResourceSchema (com.linkedin.restli.restspec.ResourceSchema)8 StringArray (com.linkedin.data.template.StringArray)3 CompatibilityInfoMap (com.linkedin.restli.tools.compatibility.CompatibilityInfoMap)3 SchemaParser (com.linkedin.data.schema.SchemaParser)1 AssocKeySchema (com.linkedin.restli.restspec.AssocKeySchema)1 AssocKeySchemaArray (com.linkedin.restli.restspec.AssocKeySchemaArray)1