aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-05-23 12:19:12 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-05-23 12:19:12 +0200
commitb7252332e854af6c13d5c31c8638ca31c732139b (patch)
treeb84f21b1f73574e12e137f45f82c0cc3257c902a /sonar-core/src
parent5da0b7bf83fb86b209b7c831faa2c8625025ad43 (diff)
downloadsonarqube-b7252332e854af6c13d5c31c8638ca31c732139b.tar.gz
sonarqube-b7252332e854af6c13d5c31c8638ca31c732139b.zip
SONAR-4329 Close no more existing confirmed issues
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java6
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java55
2 files changed, 61 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java b/sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java
index 8d1b1ea539b..ff308798a0c 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java
@@ -111,6 +111,12 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable
.functions(new SetResolution(Issue.RESOLUTION_FIXED), new SetCloseDate(true))
.automatic()
.build())
+ .transition(Transition.builder("automaticclose")
+ .from(Issue.STATUS_CONFIRMED).to(Issue.STATUS_CLOSED)
+ .conditions(new IsAlive(false))
+ .functions(new SetResolution(Issue.RESOLUTION_FIXED), new SetCloseDate(true))
+ .automatic()
+ .build())
// Close the issues marked as resolved and that do not exist anymore.
// Note that false-positives are kept resolved and are not closed.
.transition(Transition.builder("automaticclose")
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java b/sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java
index 7919a92219c..8d5e3bbeb22 100644
--- a/sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java
@@ -121,6 +121,61 @@ public class IssueWorkflowTest {
}
@Test
+ public void should_close_open_dead_issue() throws Exception {
+ workflow.start();
+
+ DefaultIssue issue = new DefaultIssue()
+ .setKey("ABCDE")
+ .setResolution(null)
+ .setStatus(Issue.STATUS_OPEN)
+ .setNew(false)
+ .setAlive(false);
+ Date now = new Date();
+ workflow.doAutomaticTransition(issue, IssueChangeContext.createScan(now));
+ assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED);
+ assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED);
+ assertThat(issue.closeDate()).isNotNull();
+ assertThat(issue.updateDate()).isEqualTo(now);
+ }
+
+ @Test
+ public void should_close_reopened_dead_issue() throws Exception {
+ workflow.start();
+
+ DefaultIssue issue = new DefaultIssue()
+ .setKey("ABCDE")
+ .setResolution(null)
+ .setStatus(Issue.STATUS_REOPENED)
+ .setNew(false)
+ .setAlive(false);
+ Date now = new Date();
+ workflow.doAutomaticTransition(issue, IssueChangeContext.createScan(now));
+ assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED);
+ assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED);
+ assertThat(issue.closeDate()).isNotNull();
+ assertThat(issue.updateDate()).isEqualTo(now);
+ }
+
+ @Test
+ public void should_close_confirmed_dead_issue() throws Exception {
+ workflow.start();
+
+ DefaultIssue issue = new DefaultIssue()
+ .setKey("ABCDE")
+ .setResolution(null)
+ .setStatus(Issue.STATUS_CONFIRMED)
+ .setNew(false)
+ .setAlive(false);
+ Date now = new Date();
+ workflow.doAutomaticTransition(issue, IssueChangeContext.createScan(now));
+ assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED);
+ assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED);
+ assertThat(issue.closeDate()).isNotNull();
+ assertThat(issue.updateDate()).isEqualTo(now);
+ }
+
+
+ @Test
public void should_fail_if_unknown_status() throws Exception {
workflow.start();