Search in sources :

Example 1 with STATUS_CONFIRMED

use of org.sonar.api.issue.Issue.STATUS_CONFIRMED in project sonarqube by SonarSource.

the class IssueWorkflowTest method automatically_reopen_closed_issue_to_most_recent_previous_status_from_changelog.

@Test
@UseDataProvider("allStatusesLeadingToClosed")
public void automatically_reopen_closed_issue_to_most_recent_previous_status_from_changelog(String previousStatus) {
    DefaultIssue[] issues = Arrays.stream(SUPPORTED_RESOLUTIONS_FOR_UNCLOSING).map(resolution -> {
        DefaultIssue issue = newClosedIssue(resolution);
        Date now = new Date();
        addStatusChange(issue, addDays(now, -60), STATUS_OPEN, STATUS_CONFIRMED);
        addStatusChange(issue, addDays(now, -10), STATUS_CONFIRMED, previousStatus);
        setStatusPreviousToClosed(issue, previousStatus);
        return issue;
    }).toArray(DefaultIssue[]::new);
    Date now = new Date();
    underTest.start();
    Arrays.stream(issues).forEach(issue -> {
        underTest.doAutomaticTransition(issue, IssueChangeContext.createScan(now));
        assertThat(issue.status()).isEqualTo(previousStatus);
        assertThat(issue.updateDate()).isEqualTo(DateUtils.truncate(now, Calendar.SECOND));
        assertThat(issue.closeDate()).isNull();
        assertThat(issue.isChanged()).isTrue();
    });
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) RESOLUTION_WONT_FIX(org.sonar.api.issue.Issue.RESOLUTION_WONT_FIX) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) STATUS_OPEN(org.sonar.api.issue.Issue.STATUS_OPEN) RunWith(org.junit.runner.RunWith) DateUtils.addDays(org.apache.commons.lang.time.DateUtils.addDays) STATUS_RESOLVED(org.sonar.api.issue.Issue.STATUS_RESOLVED) Random(java.util.Random) Collections2(com.google.common.collect.Collections2) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) DataProviderRunner(com.tngtech.java.junit.dataprovider.DataProviderRunner) STATUS_CLOSED(org.sonar.api.issue.Issue.STATUS_CLOSED) ArrayList(java.util.ArrayList) IssueFieldsSetter(org.sonar.server.issue.IssueFieldsSetter) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Calendar(java.util.Calendar) DateUtils(org.apache.commons.lang.time.DateUtils) IssueChangeContext(org.sonar.core.issue.IssueChangeContext) RESOLUTION_FALSE_POSITIVE(org.sonar.api.issue.Issue.RESOLUTION_FALSE_POSITIVE) Assert.fail(org.junit.Assert.fail) RESOLUTION_FIXED(org.sonar.api.issue.Issue.RESOLUTION_FIXED) Nullable(javax.annotation.Nullable) DefaultIssue(org.sonar.core.issue.DefaultIssue) STATUS_REOPENED(org.sonar.api.issue.Issue.STATUS_REOPENED) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider) Collection(java.util.Collection) Test(org.junit.Test) RESOLUTION_REMOVED(org.sonar.api.issue.Issue.RESOLUTION_REMOVED) STATUS_TO_REVIEW(org.sonar.api.issue.Issue.STATUS_TO_REVIEW) FieldDiffs(org.sonar.core.issue.FieldDiffs) STATUS_CONFIRMED(org.sonar.api.issue.Issue.STATUS_CONFIRMED) List(java.util.List) STATUS_REVIEWED(org.sonar.api.issue.Issue.STATUS_REVIEWED) DefaultTransitions(org.sonar.api.issue.DefaultTransitions) RuleKey(org.sonar.api.rule.RuleKey) DefaultIssue(org.sonar.core.issue.DefaultIssue) Date(java.util.Date) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Collections2 (com.google.common.collect.Collections2)1 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)1 DataProviderRunner (com.tngtech.java.junit.dataprovider.DataProviderRunner)1 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Random (java.util.Random)1 Nullable (javax.annotation.Nullable)1 DateUtils (org.apache.commons.lang.time.DateUtils)1 DateUtils.addDays (org.apache.commons.lang.time.DateUtils.addDays)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assert.fail (org.junit.Assert.fail)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 DefaultTransitions (org.sonar.api.issue.DefaultTransitions)1