|
25 | 25 | import java.io.File;
|
26 | 26 | import java.nio.file.Files;
|
27 | 27 | import java.util.Collections;
|
| 28 | +import java.util.List; |
| 29 | +import java.util.stream.Collectors; |
28 | 30 | import org.junit.BeforeClass;
|
29 | 31 | import org.junit.ClassRule;
|
30 | 32 | import org.junit.Test;
|
| 33 | +import org.sonarqube.ws.Issues; |
| 34 | +import org.sonarqube.ws.client.HttpConnector; |
| 35 | +import org.sonarqube.ws.client.WsClient; |
| 36 | +import org.sonarqube.ws.client.WsClientFactories; |
| 37 | +import org.sonarqube.ws.client.issues.SearchRequest; |
31 | 38 | import org.sonarsource.analyzer.commons.ProfileGenerator;
|
32 | 39 |
|
33 | 40 | import static java.nio.charset.StandardCharsets.UTF_8;
|
| 41 | +import static java.util.Collections.singletonList; |
34 | 42 | import static org.assertj.core.api.Assertions.assertThat;
|
35 | 43 | import static org.sonar.python.it.RulingHelper.getOrchestrator;
|
36 | 44 |
|
@@ -76,8 +84,28 @@ public void test() throws Exception {
|
76 | 84 | .setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Xmx2000m");
|
77 | 85 | ORCHESTRATOR.executeBuild(build);
|
78 | 86 |
|
| 87 | + String issueDifferences = issues(PROJECT_KEY).stream() |
| 88 | + .map(i -> String.join("\t", i.getRule(), "" + i.getSeverity(), i.getComponent(), "" + i.getLine())) |
| 89 | + .collect(Collectors.joining("\n")); |
| 90 | + assertThat(issueDifferences).isEmpty(); |
| 91 | + |
79 | 92 | String litsDifferences = new String(Files.readAllBytes(litsDifferencesFile.toPath()), UTF_8);
|
80 | 93 | assertThat(litsDifferences).isEmpty();
|
81 | 94 | }
|
82 | 95 |
|
| 96 | + static WsClient newWsClient() { |
| 97 | + return newWsClient(null, null); |
| 98 | + } |
| 99 | + |
| 100 | + static WsClient newWsClient(String login, String password) { |
| 101 | + return WsClientFactories.getDefault().newClient(HttpConnector.newBuilder() |
| 102 | + .url(ORCHESTRATOR.getServer().getUrl()) |
| 103 | + .credentials(login, password) |
| 104 | + .build()); |
| 105 | + } |
| 106 | + |
| 107 | + static List<Issues.Issue> issues(String projectKey) { |
| 108 | + return newWsClient().issues().search(new SearchRequest().setProjects(singletonList(projectKey))).getIssuesList(); |
| 109 | + } |
| 110 | + |
83 | 111 | }
|
0 commit comments