Search in sources :

Example 6 with IssueClient

use of org.sonar.wsclient.issue.IssueClient in project sonar-java by SonarSource.

the class JavaTest method filtered_issues.

/**
 * SONARJAVA-1615
 */
@Test
public void filtered_issues() throws Exception {
    MavenBuild build = MavenBuild.create(TestUtils.projectPom("filtered-issues")).setCleanPackageSonarGoals().setProperty("sonar.profile", "filtered-issues");
    orchestrator.executeBuild(build);
    assertThat(getMeasureAsInteger("org.example:example", "violations")).isEqualTo(2);
    IssueClient issueClient = orchestrator.getServer().wsClient().issueClient();
    List<Issue> issues = issueClient.find(IssueQuery.create().components("org.example:example:src/main/java/EclispeI18NFiltered.java")).list();
    assertThat(issues).hasSize(2);
    for (Issue issue : issues) {
        assertThat(issue.ruleKey()).matches(value -> "squid:S1444".equals(value) || "squid:ClassVariableVisibilityCheck".equals(value));
        assertThat(issue.line()).isEqualTo(17);
    }
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) Issue(org.sonar.wsclient.issue.Issue) IssueClient(org.sonar.wsclient.issue.IssueClient) Test(org.junit.Test)

Example 7 with IssueClient

use of org.sonar.wsclient.issue.IssueClient in project sonar-java by SonarSource.

the class SquidTest method should_detect_missing_package_info.

@Test
public void should_detect_missing_package_info() throws Exception {
    IssueClient issueClient = orchestrator.getServer().wsClient().issueClient();
    List<Issue> issues = issueClient.find(IssueQuery.create().components(JavaTestSuite.keyFor("com.sonarsource.it.samples:squid", "package1", ""))).list();
    assertThat(issues).hasSize(1);
    assertThat(issues.get(0).ruleKey()).isEqualTo("squid:S1228");
    assertThat(issues.get(0).line()).isNull();
    issues = issueClient.find(IssueQuery.create().components("com.sonarsource.it.samples:squid:src/test/java/package1")).list();
    assertThat(issues).isEmpty();
}
Also used : Issue(org.sonar.wsclient.issue.Issue) IssueClient(org.sonar.wsclient.issue.IssueClient) Test(org.junit.Test)

Example 8 with IssueClient

use of org.sonar.wsclient.issue.IssueClient in project sonar-go by SonarSource.

the class GoIntegrationTest method issues.

@Test
public void issues() {
    IssueClient issueClient = orchestrator.getServer().wsClient().issueClient();
    assertThat(issueClient.find(IssueQuery.create().componentRoots("project").rules("go:S1656")).list()).hasSize(2);
    assertThat(issueClient.find(IssueQuery.create().componentRoots("project").severities("BLOCKER")).list()).hasSize(1);
    assertThat(issueClient.find(IssueQuery.create().componentRoots("project").severities("MAJOR")).list()).hasSize(4);
    assertThat(issueClient.find(IssueQuery.create().componentRoots("project").severities("MINOR")).list()).hasSize(1);
}
Also used : IssueClient(org.sonar.wsclient.issue.IssueClient) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 IssueClient (org.sonar.wsclient.issue.IssueClient)8 Issue (org.sonar.wsclient.issue.Issue)7 MavenBuild (com.sonar.orchestrator.build.MavenBuild)3 BuildResult (com.sonar.orchestrator.build.BuildResult)1 SonarScanner (com.sonar.orchestrator.build.SonarScanner)1 Issues (org.sonarqube.ws.Issues)1