Search in sources :

Example 1 with MethodParameterElement

use of org.revapi.java.model.MethodParameterElement in project revapi by revapi.

the class AnnotatedElementFilterTest method testChangesReportedOnAnnotationElements.

@Test
public void testChangesReportedOnAnnotationElements() throws Exception {
    CollectingReporter reporter = runAnalysis(CollectingReporter.class, "{\"revapi\": {\"java\": {\"filter\": {\"annotated\": {\"regex\": true," + " \"include\":[\"@Attributes.Anno.*\"]}}}}}", "v1/annotations/Attributes.java", "v2/annotations/Attributes.java");
    List<Report> reports = reporter.getReports();
    Assert.assertEquals(2, reports.size());
    Report parameterChange = reports.stream().filter(r -> r.getNewElement() instanceof MethodParameterElement).findFirst().orElse(null);
    Report annotationChanges = reports.stream().filter(r -> r.getNewElement() instanceof MethodElement).findFirst().orElse(null);
    Assert.assertEquals(1, parameterChange.getDifferences().size());
    Assert.assertEquals("java.method.parameterTypeChanged", parameterChange.getDifferences().get(0).code);
    Assert.assertEquals(3, annotationChanges.getDifferences().size());
    Assert.assertEquals(new HashSet<>(Arrays.asList("java.annotation.attributeValueChanged", "java.annotation.attributeAdded", "java.element.nowDeprecated")), annotationChanges.getDifferences().stream().map(d -> d.code).collect(Collectors.toSet()));
}
Also used : Report(org.revapi.Report) MethodParameterElement(org.revapi.java.model.MethodParameterElement) MethodElement(org.revapi.java.model.MethodElement) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Report (org.revapi.Report)1 MethodElement (org.revapi.java.model.MethodElement)1 MethodParameterElement (org.revapi.java.model.MethodParameterElement)1