Search in sources :

Example 21 with Difference

use of org.revapi.Difference in project revapi by revapi.

the class ClassificationTransformTest method test.

@Test
public void test() throws Exception {
    DummyElement oldE = new DummyElement("old");
    DummyElement newE = new DummyElement("new");
    Difference difference = Difference.builder().withCode("code").addClassification(CompatibilityType.BINARY, DifferenceSeverity.NON_BREAKING).addClassification(CompatibilityType.SOURCE, DifferenceSeverity.POTENTIALLY_BREAKING).build();
    AnalysisContext config = getAnalysisContextFromFullConfig(ClassificationTransform.class, "[{\"extension\": \"revapi.reclassify\", \"configuration\":[{\"code\":\"code\", \"classify\": {\"BINARY\" : \"BREAKING\"}}]}]");
    try (ClassificationTransform t = new ClassificationTransform()) {
        t.initialize(config);
        difference = t.transform(oldE, newE, difference);
        assert difference != null && difference.classification.get(CompatibilityType.BINARY) == DifferenceSeverity.BREAKING;
        assert difference != null && difference.classification.get(CompatibilityType.SOURCE) == DifferenceSeverity.POTENTIALLY_BREAKING;
    }
}
Also used : Difference(org.revapi.Difference) AnalysisContext(org.revapi.AnalysisContext) Test(org.junit.Test)

Example 22 with Difference

use of org.revapi.Difference in project revapi by revapi.

the class IgnoreDifferenceTransformTest method testRegexMatch.

@Test
public void testRegexMatch() throws Exception {
    DummyElement oldE = new DummyElement("a");
    DummyElement newE = new DummyElement("b");
    Difference difference = Difference.builder().withCode("c").build();
    try (IgnoreDifferenceTransform t = new IgnoreDifferenceTransform()) {
        AnalysisContext config = getAnalysisContextFromFullConfig(IgnoreDifferenceTransform.class, "[{\"extension\": \"revapi.ignore\", \"configuration\": [{\"regex\": true, \"code\":\"c\", \"justification\" : \"because\"}]}]");
        t.initialize(config);
        difference = t.transform(oldE, newE, difference);
        Assert.assertNull(difference);
    }
}
Also used : Difference(org.revapi.Difference) AnalysisContext(org.revapi.AnalysisContext) Test(org.junit.Test)

Aggregations

Difference (org.revapi.Difference)22 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 AnalysisContext (org.revapi.AnalysisContext)6 JavaTypeElement (org.revapi.java.spi.JavaTypeElement)6 TypeElement (javax.lang.model.element.TypeElement)5 Map (java.util.Map)4 TypeMirror (javax.lang.model.type.TypeMirror)4 Report (org.revapi.Report)4 List (java.util.List)3 JavaMethodElement (org.revapi.java.spi.JavaMethodElement)3 Nullable (javax.annotation.Nullable)2 AnnotationValue (javax.lang.model.element.AnnotationValue)2 ExecutableElement (javax.lang.model.element.ExecutableElement)2 CoIterator (org.revapi.CoIterator)2 DifferenceSeverity (org.revapi.DifferenceSeverity)2 Element (org.revapi.Element)2 Util (org.revapi.java.spi.Util)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1