Search in sources :

Example 6 with SearchWsRequest

use of org.sonarqube.ws.client.issue.SearchWsRequest in project sonarqube by SonarSource.

the class IssueQueryServiceTest method fail_if_since_leak_period_and_created_after_set_at_the_same_time.

@Test
public void fail_if_since_leak_period_and_created_after_set_at_the_same_time() {
    expectedException.expect(BadRequestException.class);
    expectedException.expectMessage("'createdAfter' and 'sinceLeakPeriod' cannot be set simultaneously");
    underTest.createFromRequest(new SearchWsRequest().setSinceLeakPeriod(true).setCreatedAfter("2013-07-25T07:35:00+0100"));
}
Also used : SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) Test(org.junit.Test)

Example 7 with SearchWsRequest

use of org.sonarqube.ws.client.issue.SearchWsRequest in project sonarqube by SonarSource.

the class IssueQueryServiceTest method fail_if_several_components_provided_with_since_leak_period.

@Test
public void fail_if_several_components_provided_with_since_leak_period() {
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("One and only one component must be provided when searching since leak period");
    underTest.createFromRequest(new SearchWsRequest().setSinceLeakPeriod(true).setComponentUuids(newArrayList("component-uuid", "project-uuid")));
}
Also used : SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) Test(org.junit.Test)

Example 8 with SearchWsRequest

use of org.sonarqube.ws.client.issue.SearchWsRequest in project sonarqube by SonarSource.

the class IssueTrackingTest method track_existing_unchanged_issues_on_multi_modules.

/**
   * SONAR-4310
   */
@Test
public void track_existing_unchanged_issues_on_multi_modules() throws Exception {
    // The custom rule on module is enabled
    ORCHESTRATOR.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "com.sonarsource.it.samples:multi-modules-sample");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-module");
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-multi-modules-sample");
    // One issue by module are created
    List<Issue> issues = searchIssues(new SearchWsRequest()).getIssuesList();
    assertThat(issues).hasSize(4);
    // Re analysis of the same project
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-multi-modules-sample");
    // No new issue should be created
    assertThat(searchIssues(new SearchWsRequest()).getIssuesList()).hasSize(issues.size());
    // Issues on modules should stay open and be the same from the first analysis
    for (Issue issue : issues) {
        Issue reloadIssue = getIssueByKey(issue.getKey());
        assertThat(reloadIssue.getStatus()).isEqualTo("OPEN");
        assertThat(reloadIssue.hasResolution()).isFalse();
        assertThat(reloadIssue.getCreationDate()).isEqualTo(issue.getCreationDate());
        assertThat(reloadIssue.getUpdateDate()).isEqualTo(issue.getUpdateDate());
    }
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) Test(org.junit.Test)

Example 9 with SearchWsRequest

use of org.sonarqube.ws.client.issue.SearchWsRequest in project sonarqube by SonarSource.

the class IssueTrackingTest method getIssueByKey.

private static Issue getIssueByKey(String issueKey) {
    SearchWsResponse search = searchIssues(new SearchWsRequest().setIssues(singletonList(issueKey)));
    assertThat(search.getTotal()).isEqualTo(1);
    return search.getIssues(0);
}
Also used : SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) SearchWsResponse(org.sonarqube.ws.Issues.SearchWsResponse)

Example 10 with SearchWsRequest

use of org.sonarqube.ws.client.issue.SearchWsRequest in project sonarqube by SonarSource.

the class IssueWorkflowTest method issue_is_closed_as_removed_when_rule_is_disabled.

/**
   * Issue on a disabled rule (uninstalled plugin or rule deactivated from quality profile) must 
   * be CLOSED with resolution REMOVED
   */
@Test
public void issue_is_closed_as_removed_when_rule_is_disabled() throws Exception {
    SearchWsRequest ruleSearchRequest = new SearchWsRequest().setRules(singletonList("xoo:OneIssuePerLine"));
    List<Issue> issues = issueRule.search(ruleSearchRequest).getIssuesList();
    assertThat(issues).isNotEmpty();
    // re-analyze with profile "empty". The rule is disabled so the issues must be closed
    analysisWithoutIssues.run();
    issues = issueRule.search(ruleSearchRequest).getIssuesList();
    assertThat(issues).isNotEmpty();
    for (Issue issue : issues) {
        assertThat(issue.getStatus()).isEqualTo("CLOSED");
        assertThat(issue.getResolution()).isEqualTo("REMOVED");
    }
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) Test(org.junit.Test)

Aggregations

SearchWsRequest (org.sonarqube.ws.client.issue.SearchWsRequest)10 Test (org.junit.Test)8 Issue (org.sonarqube.ws.Issues.Issue)4 Issues (org.sonarqube.ws.Issues)3 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assert.fail (org.junit.Assert.fail)1 Before (org.junit.Before)1 ClassRule (org.junit.ClassRule)1 Rule (org.junit.Rule)1 BLOCKER (org.sonarqube.ws.Common.Severity.BLOCKER)1 SearchWsResponse (org.sonarqube.ws.Issues.SearchWsResponse)1 AddCommentRequest (org.sonarqube.ws.client.issue.AddCommentRequest)1 AssignRequest (org.sonarqube.ws.client.issue.AssignRequest)1 EditCommentRequest (org.sonarqube.ws.client.issue.EditCommentRequest)1 IssuesService (org.sonarqube.ws.client.issue.IssuesService)1 SetSeverityRequest (org.sonarqube.ws.client.issue.SetSeverityRequest)1 ItUtils.newAdminWsClient (util.ItUtils.newAdminWsClient)1 ItUtils.toDatetime (util.ItUtils.toDatetime)1