From 105176fb19c3ab8a82eec620abd99b32b1387139 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Wed, 5 Aug 2015 16:32:47 +0200 Subject: SONAR-6754 Add support of execution flow in Xoo --- .../batch/mediumtest/issues/MultilineIssuesMediumTest.java | 14 ++++++++++++++ .../xoo/sample-multiline/xources/hello/WithFlow.xoo | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 sonar-batch/src/test/resources/mediumtest/xoo/sample-multiline/xources/hello/WithFlow.xoo (limited to 'sonar-batch') diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/MultilineIssuesMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/MultilineIssuesMediumTest.java index 8ba2d4834ba..b5a6cdc14dd 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/MultilineIssuesMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/MultilineIssuesMediumTest.java @@ -29,6 +29,7 @@ import org.junit.rules.TemporaryFolder; import org.sonar.batch.mediumtest.BatchMediumTester; import org.sonar.batch.mediumtest.TaskResult; import org.sonar.batch.protocol.input.ActiveRule; +import org.sonar.batch.protocol.output.BatchReport.ExecutionFlow; import org.sonar.batch.protocol.output.BatchReport.Issue; import org.sonar.batch.protocol.output.BatchReport.IssueLocation; import org.sonar.xoo.XooPlugin; @@ -120,4 +121,17 @@ public class MultilineIssuesMediumTest { assertThat(additionalLocation.getTextRange().getEndLine()).isEqualTo(7); assertThat(additionalLocation.getTextRange().getEndOffset()).isEqualTo(52); } + + @Test + public void testExecutionFlows() throws Exception { + List issues = result.issuesFor(result.inputFile("xources/hello/WithFlow.xoo")); + assertThat(issues).hasSize(1); + Issue issue = issues.get(0); + assertThat(issue.getExecutionFlowList()).hasSize(1); + + ExecutionFlow executionFlow = issue.getExecutionFlow(0); + assertThat(executionFlow.getLocationList()).hasSize(2); + + // TODO more assertions + } } diff --git a/sonar-batch/src/test/resources/mediumtest/xoo/sample-multiline/xources/hello/WithFlow.xoo b/sonar-batch/src/test/resources/mediumtest/xoo/sample-multiline/xources/hello/WithFlow.xoo new file mode 100644 index 00000000000..31e11c695e9 --- /dev/null +++ b/sonar-batch/src/test/resources/mediumtest/xoo/sample-multiline/xources/hello/WithFlow.xoo @@ -0,0 +1,14 @@ +package hello; + +public class HelloJava { + + public static void main(String[] args) { + {xoo-start-flow:1:1:1}if (true){xoo-end-flow:1:1:1} { + {xoo-start-flow:1:1:2}if (true){xoo-end-flow:1:1:2} { + {xoo-start-issue:1:1}if (true){xoo-end-issue:1:1} { + System.out.println("Hello"); + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3