Search in sources :

Example 16 with Issue

use of org.sonarqube.ws.Issues.Issue 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 17 with Issue

use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.

the class IssueTrackingTest method track_file_moves_based_on_identical_content.

@Test
public void track_file_moves_based_on_identical_content() {
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, "xoo", "issue-on-tag-foobar");
    // version 1
    runProjectAnalysis(ORCHESTRATOR, "issue/xoo-tracking-v1", "sonar.projectDate", OLD_DATE);
    List<Issue> issues = searchUnresolvedIssuesByComponent("sample:src/main/xoo/sample/Sample.xoo");
    assertThat(issues).hasSize(1);
    Issue issueOnSample = issues.iterator().next();
    // version 2
    runProjectAnalysis(ORCHESTRATOR, "issue/xoo-tracking-v3", "sonar.projectDate", NEW_DATE_STR);
    assertThat(searchUnresolvedIssuesByComponent("sample:src/main/xoo/sample/Sample.xoo")).isEmpty();
    issues = searchUnresolvedIssuesByComponent("sample:src/main/xoo/sample/Sample2.xoo");
    assertThat(issues).hasSize(1);
    Issue issueOnSample2 = issues.get(0);
    assertThat(issueOnSample2.getKey()).isEqualTo(issueOnSample.getKey());
    assertThat(issueOnSample2.getCreationDate()).isEqualTo(issueOnSample.getCreationDate());
    assertThat(issueOnSample2.getUpdateDate()).isNotEqualTo(issueOnSample.getUpdateDate());
    assertThat(issueOnSample2.getStatus()).isEqualTo("OPEN");
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) Test(org.junit.Test)

Example 18 with Issue

use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.

the class IssueWorkflowTest method user_should_mark_as_false_positive_confirmed_issue.

/**
   * SONAR-4329
   */
@Test
public void user_should_mark_as_false_positive_confirmed_issue() {
    // mark as confirmed
    issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "confirm"));
    Issue confirmed = issueRule.getByKey(issue.getKey());
    assertThat(confirmed.getStatus()).isEqualTo("CONFIRMED");
    assertThat(confirmed.hasResolution()).isFalse();
    assertThat(confirmed.getCreationDate()).isEqualTo(issue.getCreationDate());
    // user mark the issue as false-positive
    assertThat(transitions(confirmed.getKey())).contains("falsepositive");
    issuesService.doTransition(new DoTransitionRequest(confirmed.getKey(), "falsepositive"));
    Issue falsePositive = issueRule.getByKey(issue.getKey());
    assertThat(falsePositive.getStatus()).isEqualTo("RESOLVED");
    assertThat(falsePositive.getResolution()).isEqualTo("FALSE-POSITIVE");
    assertThat(falsePositive.getCreationDate()).isEqualTo(confirmed.getCreationDate());
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) DoTransitionRequest(org.sonarqube.ws.client.issue.DoTransitionRequest) Test(org.junit.Test)

Example 19 with Issue

use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.

the class IssueWorkflowTest method scan_should_close_no_more_existing_confirmed.

/**
   * SONAR-4329
   */
@Test
public void scan_should_close_no_more_existing_confirmed() {
    // mark as confirmed
    issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "confirm"));
    Issue falsePositive = issueRule.getByKey(issue.getKey());
    assertThat(falsePositive.getStatus()).isEqualTo("CONFIRMED");
    assertThat(falsePositive.hasResolution()).isFalse();
    assertThat(falsePositive.getCreationDate()).isEqualTo(issue.getCreationDate());
    // scan without any rules -> confirmed is closed
    analysisWithoutIssues.run();
    Issue closed = issueRule.getByKey(issue.getKey());
    assertThat(closed.getStatus()).isEqualTo("CLOSED");
    assertThat(closed.getResolution()).isEqualTo("REMOVED");
    assertThat(closed.getCreationDate()).isEqualTo(issue.getCreationDate());
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) DoTransitionRequest(org.sonarqube.ws.client.issue.DoTransitionRequest) Test(org.junit.Test)

Example 20 with Issue

use of org.sonarqube.ws.Issues.Issue 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

Test (org.junit.Test)24 Issue (org.sonarqube.ws.Issues.Issue)24 DoTransitionRequest (org.sonarqube.ws.client.issue.DoTransitionRequest)9 Issues (org.sonarqube.ws.Issues)5 AddCommentRequest (org.sonarqube.ws.client.issue.AddCommentRequest)5 BulkChangeWsResponse (org.sonarqube.ws.Issues.BulkChangeWsResponse)4 SearchWsRequest (org.sonarqube.ws.client.issue.SearchWsRequest)4 EditCommentRequest (org.sonarqube.ws.client.issue.EditCommentRequest)2 SetSeverityRequest (org.sonarqube.ws.client.issue.SetSeverityRequest)2 Collections.singletonList (java.util.Collections.singletonList)1 Date (java.util.Date)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 AssignRequest (org.sonarqube.ws.client.issue.AssignRequest)1 IssuesService (org.sonarqube.ws.client.issue.IssuesService)1