use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssuePurgeTest method purge_old_closed_issues.
/**
* SONAR-4308
*/
@Test
public void purge_old_closed_issues() throws Exception {
projectAnalysisRule.setServerProperty("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "5000");
// Generate some issues
xooSampleAnalysis.withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-01").run();
// All the issues are open
List<Issue> issuesList = searchIssues();
for (Issue issue : issuesList) {
assertThat(issue.resolution()).isNull();
}
// Second scan with empty profile -> all issues are resolved and closed
// -> Not deleted because less than 5000 days long
xooSampleAnalysis.withXooEmptyProfile().withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-15").run();
issuesList = searchIssues();
assertThat(issuesList).isNotEmpty();
for (Issue issue : issuesList) {
assertThat(issue.resolution()).isNotNull();
assertThat(issue.status()).isEqualTo("CLOSED");
}
// Third scan -> closed issues are deleted
projectAnalysisRule.setServerProperty("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "1");
xooSampleAnalysis.withXooEmptyProfile().withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-20").run();
Issues issues = issueClient().find(IssueQuery.create());
assertThat(issues.list()).isEmpty();
assertThat(issues.paging().total()).isZero();
}
use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssuePurgeTest method purge_old_closed_issues_when_zero_closed_issues_wanted.
/**
* SONAR-7108
*/
@Test
public void purge_old_closed_issues_when_zero_closed_issues_wanted() throws Exception {
projectAnalysisRule.setServerProperty("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "5000");
// Generate some issues
xooSampleAnalysis.withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-01").run();
// All the issues are open
List<Issue> issueList = searchIssues();
for (Issue issue : issueList) {
assertThat(issue.resolution()).isNull();
}
// Second scan with empty profile -> all issues are resolved and closed
// -> Not deleted because less than 5000 days long
xooSampleAnalysis.withXooEmptyProfile().withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-15").run();
issueList = searchIssues();
assertThat(issueList).isNotEmpty();
for (Issue issue : issueList) {
assertThat(issue.resolution()).isNotNull();
assertThat(issue.status()).isEqualTo("CLOSED");
}
// Third scan -> closed issues are deleted
projectAnalysisRule.setServerProperty("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "0");
xooSampleAnalysis.withXooEmptyProfile().withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-20").run();
Issues issues = issueClient().find(IssueQuery.create());
assertThat(issues.list()).isEmpty();
assertThat(issues.paging().total()).isZero();
}
use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssueSearchTest method search_by_exact_creation_date.
/**
* SONAR-4563
*/
@Test
public void search_by_exact_creation_date() {
final Issue issue = search(IssueQuery.create()).list().get(0);
assertThat(issue.creationDate()).isNotNull();
// search the issue key with the same date
assertThat(search(IssueQuery.create().issues().issues(issue.key()).createdAt(issue.creationDate())).list()).hasSize(1);
// search issue key with 1 second more and less should return nothing
assertThat(search(IssueQuery.create().issues().issues(issue.key()).createdAt(DateUtils.addSeconds(issue.creationDate(), 1))).size()).isEqualTo(0);
assertThat(search(IssueQuery.create().issues().issues(issue.key()).createdAt(DateUtils.addSeconds(issue.creationDate(), -1))).size()).isEqualTo(0);
// search with future and past dates that do not match any issues
assertThat(search(IssueQuery.create().createdAt(toDate("2020-01-01"))).size()).isEqualTo(0);
assertThat(search(IssueQuery.create().createdAt(toDate("2010-01-01"))).size()).isEqualTo(0);
}
use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssueChangelogTest method update_changelog_when_assigning_issue_by_user.
@Test
public void update_changelog_when_assigning_issue_by_user() throws Exception {
runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample");
Issue issue = searchRandomIssue();
assertIssueHasNoChange(issue.key());
adminIssueClient().assign(issue.key(), "admin");
List<Changelog> changes = changelog(issue.key()).getChangelogList();
assertThat(changes).hasSize(1);
Changelog change = changes.get(0);
assertThat(change.getUser()).isEqualTo("admin");
assertThat(change.getCreationDate()).isNotNull();
assertThat(change.getDiffsList()).extracting(Changelog.Diff::getKey, Changelog.Diff::hasOldValue, Changelog.Diff::getNewValue).containsOnly(tuple("assignee", false, "Administrator"));
}
use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssueChangelogTest method display_file_name_in_changelog_during_file_move.
@Test
public void display_file_name_in_changelog_during_file_move() {
// version 1
runProjectAnalysis(ORCHESTRATOR, "issue/xoo-tracking-v1");
// version 2
runProjectAnalysis(ORCHESTRATOR, "issue/xoo-tracking-v3");
Issue issue = searchRandomIssue();
List<Changelog> changes = changelog(issue.key()).getChangelogList();
assertThat(changes).hasSize(1);
Changelog change = changes.get(0);
assertThat(change.hasUser()).isFalse();
assertThat(change.getCreationDate()).isNotNull();
assertThat(change.getDiffsList()).extracting(Changelog.Diff::getKey, Changelog.Diff::getOldValue, Changelog.Diff::getNewValue).containsOnly(tuple("file", "src/main/xoo/sample/Sample.xoo", "src/main/xoo/sample/Sample2.xoo"));
}
Aggregations