use of org.sonar.plugins.java.api.JavaFileScannerContext.Location in project sonar-java by SonarSource.
the class DefaultJavaFileScannerContextTest method report_issue_on_tree_with_secondary.
@Test
public void report_issue_on_tree_with_secondary() {
ClassTree tree = (ClassTree) compilationUnitTree.types().get(0);
Tree firstMember = tree.members().get(0);
Tree secondMember = tree.members().get(1);
ArrayList<Location> secondary = new ArrayList<>();
secondary.add(new JavaFileScannerContext.Location("secondary", firstMember));
secondary.add(new JavaFileScannerContext.Location("secondary", secondMember));
context.reportIssue(CHECK, tree.simpleName(), "msg", secondary, null);
assertThat(reportedMessage.getMessage()).isEqualTo("msg");
assertThat(reportedMessage.getCost()).isNull();
assertThat(reportedMessage.flows).hasSize(2);
assertMessagePosition(reportedMessage, 1, 6, 1, 7);
List<AnalyzerMessage> secondaries = reportedMessage.flows.stream().map(flow -> flow.get(0)).collect(Collectors.toList());
assertThat(secondaries).hasSize(2);
assertMessagePosition(secondaries.get(0), 2, 2, 2, 13);
assertMessagePosition(secondaries.get(1), 3, 2, 3, 15);
}
Aggregations