use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.
the class IssueWorkflowTest method user_should_confirm_issue.
/**
* SONAR-4329
*/
@Test
public void user_should_confirm_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 unconfirm the issue
assertThat(transitions(confirmed.getKey())).contains("unconfirm");
issuesService.doTransition(new DoTransitionRequest(confirmed.getKey(), "unconfirm"));
Issue unconfirmed = issueRule.getByKey(issue.getKey());
assertThat(unconfirmed.getStatus()).isEqualTo("REOPENED");
assertThat(unconfirmed.hasResolution()).isFalse();
assertThat(unconfirmed.getCreationDate()).isEqualTo(confirmed.getCreationDate());
}
use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.
the class IssueWorkflowTest method scan_should_close_resolved_issue.
/**
* SONAR-4288
*/
@Test
public void scan_should_close_resolved_issue() {
// mark as resolved
issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "resolve"));
Issue resolvedIssue = issueRule.getByKey(issue.getKey());
assertThat(resolvedIssue.getStatus()).isEqualTo("RESOLVED");
assertThat(resolvedIssue.getResolution()).isEqualTo("FIXED");
assertThat(resolvedIssue.getCreationDate()).isEqualTo(issue.getCreationDate());
assertThat(resolvedIssue.hasCloseDate()).isFalse();
// re-execute scan without rules -> the issue is removed with resolution "REMOVED"
analysisWithoutIssues.run();
// reload issue
Issue closedIssue = issueRule.getByKey(issue.getKey());
assertThat(closedIssue.getStatus()).isEqualTo("CLOSED");
assertThat(closedIssue.getResolution()).isEqualTo("REMOVED");
assertThat(closedIssue.getCreationDate()).isEqualTo(issue.getCreationDate());
assertThat(toDatetime(closedIssue.getUpdateDate())).isAfter(toDatetime(resolvedIssue.getUpdateDate()));
assertThat(closedIssue.hasCloseDate()).isTrue();
assertThat(toDatetime(closedIssue.getCloseDate())).isAfter(toDatetime(closedIssue.getCreationDate()));
}
use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.
the class IssueActionTest method change_severity.
/**
* SONAR-4352
*/
@Test
public void change_severity() {
String componentKey = "sample";
// there are no blocker issues
assertThat(searchIssuesBySeverities(componentKey, "BLOCKER")).isEmpty();
// increase the severity of an issue
issuesService.setSeverity(new SetSeverityRequest(randomIssue.getKey(), "BLOCKER"));
assertThat(searchIssuesBySeverities(componentKey, "BLOCKER")).hasSize(1);
projectAnalysis.run();
Issue reloaded = issueRule.getByKey(randomIssue.getKey());
assertThat(reloaded.getSeverity()).isEqualTo(BLOCKER);
assertThat(reloaded.getStatus()).isEqualTo("OPEN");
assertThat(reloaded.hasResolution()).isFalse();
assertThat(reloaded.getCreationDate()).isEqualTo(randomIssue.getCreationDate());
assertThat(toDatetime(reloaded.getCreationDate())).isBefore(toDatetime(reloaded.getUpdateDate()));
}
use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.
the class IssueBulkChangeTest method should_setSeverity_add_comment_in_single_WS_call.
@Test
public void should_setSeverity_add_comment_in_single_WS_call() {
xooSampleLittleIssuesAnalysis.run();
String newSeverity = "BLOCKER";
String[] issueKeys = searchIssueKeys(BULK_EDITED_ISSUE_COUNT);
BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(BulkChangeRequest.builder().setIssues(asList(issueKeys)).setSetSeverity(newSeverity).setComment(COMMENT_AS_MARKDOWN).build());
assertThat(bulkChangeResponse.getSuccess()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
for (Issue issue : issueRule.getByKeys(issueKeys)) {
assertThat(issue.getComments().getCommentsList()).hasSize(1);
assertThat(issue.getComments().getComments(0).getHtmlText()).isEqualTo(COMMENT_AS_HTML);
}
}
use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.
the class IssueBulkChangeTest method should_add_comment_only_on_issues_that_will_be_changed.
@Test
public void should_add_comment_only_on_issues_that_will_be_changed() {
xooSampleLittleIssuesAnalysis.run();
int nbIssues = BULK_EDITED_ISSUE_COUNT;
String[] issueKeys = searchIssueKeys(nbIssues);
// Confirm an issue
adminIssueClient().doTransition(searchIssues().iterator().next().key(), "confirm");
// Apply a bulk change on unconfirm transition
BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(BulkChangeRequest.builder().setIssues(asList(issueKeys)).setDoTransition("unconfirm").setComment("this is my comment").build());
assertThat(bulkChangeResponse.getSuccess()).isEqualTo(1);
int nbIssuesWithComment = 0;
for (Issues.Issue issue : issueRule.getByKeys(issueKeys)) {
if (!issue.getComments().getCommentsList().isEmpty()) {
nbIssuesWithComment++;
}
}
// Only one issue should have the comment
assertThat(nbIssuesWithComment).isEqualTo(1);
}
Aggregations