]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4329 Create a new CONFIRMED status for Issues
authorJulien Lancelot <julien.lancelot@gmail.com>
Thu, 23 May 2013 08:29:04 +0000 (10:29 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Thu, 23 May 2013 08:29:04 +0000 (10:29 +0200)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java
sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java
sonar-plugin-api/src/main/java/org/sonar/api/issue/DefaultTransitions.java
sonar-plugin-api/src/main/java/org/sonar/api/issue/Issue.java

index 2dd46637bf9e13c4ff8c1ebba2155ad02d65aa2b..bf69c17b99baff773b2931ccaaab7bd47887ded5 100644 (file)
@@ -537,6 +537,8 @@ issue.comment.submit=Comment
 issue.comment.delete_confirm_title=Delete Comment
 issue.comment.delete_confirm_message=Do you want to delete this comment?
 issue.comment.delete_confirm_button=Delete
+issue.transition.confirm=Confirm
+issue.transition.unconfirm=Unconfirm
 issue.transition.resolve=Resolve
 issue.transition.falsepositive=False-Positive
 issue.transition.reopen=Reopen
@@ -551,6 +553,7 @@ issue.plan_must_be_created_first=An action plan should be first created to plan
 issue.status.REOPENED=Reopened
 issue.status.RESOLVED=Resolved
 issue.status.OPEN=Open
+issue.status.CONFIRMED=Confirmed
 issue.status.CLOSED=Closed
 issue.resolution.OPEN=Open
 issue.resolution.FALSE-POSITIVE=False-positive
index 926b769bcb9ed704d2065268d8ef25b96af056f9..8d1b1ea539b5d3c5f28ddcc1bf8c203e35d0c1bc 100644 (file)
@@ -32,9 +32,9 @@ import java.util.List;
 
 public class IssueWorkflow implements BatchComponent, ServerComponent, Startable {
 
-  private StateMachine machine;
   private final FunctionExecutor functionExecutor;
   private final IssueUpdater updater;
+  private StateMachine machine;
 
   public IssueWorkflow(FunctionExecutor functionExecutor, IssueUpdater updater) {
     this.functionExecutor = functionExecutor;
@@ -46,8 +46,20 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable
     machine = StateMachine.builder()
 
       // order is important for UI
-      .states(Issue.STATUS_OPEN, Issue.STATUS_REOPENED, Issue.STATUS_RESOLVED, Issue.STATUS_CLOSED)
+      .states(Issue.STATUS_OPEN, Issue.STATUS_CONFIRMED, Issue.STATUS_REOPENED, Issue.STATUS_RESOLVED, Issue.STATUS_CLOSED)
 
+      .transition(Transition.builder(DefaultTransitions.CONFIRM)
+        .from(Issue.STATUS_OPEN).to(Issue.STATUS_CONFIRMED)
+        .functions(new SetResolution(null))
+        .build())
+      .transition(Transition.builder(DefaultTransitions.CONFIRM)
+        .from(Issue.STATUS_REOPENED).to(Issue.STATUS_CONFIRMED)
+        .functions(new SetResolution(null))
+        .build())
+      .transition(Transition.builder(DefaultTransitions.UNCONFIRM)
+        .from(Issue.STATUS_CONFIRMED).to(Issue.STATUS_OPEN)
+        .functions(new SetResolution(null))
+        .build())
       .transition(Transition.builder(DefaultTransitions.RESOLVE)
         .from(Issue.STATUS_OPEN).to(Issue.STATUS_RESOLVED)
         .functions(new SetResolution(Issue.RESOLUTION_FIXED))
@@ -56,6 +68,10 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable
         .from(Issue.STATUS_REOPENED).to(Issue.STATUS_RESOLVED)
         .functions(new SetResolution(Issue.RESOLUTION_FIXED))
         .build())
+      .transition(Transition.builder(DefaultTransitions.RESOLVE)
+        .from(Issue.STATUS_CONFIRMED).to(Issue.STATUS_RESOLVED)
+        .functions(new SetResolution(Issue.RESOLUTION_FIXED))
+        .build())
       .transition(Transition.builder(DefaultTransitions.REOPEN)
         .from(Issue.STATUS_RESOLVED).to(Issue.STATUS_REOPENED)
         .functions(new SetResolution(null))
@@ -74,6 +90,11 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable
         .conditions(new IsManual(false))
         .functions(new SetResolution(Issue.RESOLUTION_FALSE_POSITIVE))
         .build())
+      .transition(Transition.builder(DefaultTransitions.FALSE_POSITIVE)
+        .from(Issue.STATUS_CONFIRMED).to(Issue.STATUS_RESOLVED)
+        .conditions(new IsManual(false))
+        .functions(new SetResolution(Issue.RESOLUTION_FALSE_POSITIVE))
+        .build())
 
         // automatic transitions
 
@@ -125,7 +146,6 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable
     return machine.state(issue.status()).outManualTransitions(issue);
   }
 
-
   public void doAutomaticTransition(DefaultIssue issue, IssueChangeContext issueChangeContext) {
     Transition transition = stateOf(issue).outAutomaticTransition(issue);
     if (transition != null) {
index e4a24c24668f7a3971f1c1f91b52dbdc0d5cff2e..7919a92219c4f8759c0013be09982ee83e85efd8 100644 (file)
@@ -28,6 +28,7 @@ import org.sonar.core.issue.IssueChangeContext;
 import org.sonar.core.issue.IssueUpdater;
 
 import javax.annotation.Nullable;
+
 import java.util.Collection;
 import java.util.Date;
 import java.util.List;
@@ -47,6 +48,7 @@ public class IssueWorkflowTest {
     workflow.start();
     assertThat(workflow.machine()).isNotNull();
     assertThat(workflow.machine().state(Issue.STATUS_OPEN)).isNotNull();
+    assertThat(workflow.machine().state(Issue.STATUS_CONFIRMED)).isNotNull();
     assertThat(workflow.machine().state(Issue.STATUS_CLOSED)).isNotNull();
     assertThat(workflow.machine().state(Issue.STATUS_REOPENED)).isNotNull();
     assertThat(workflow.machine().state(Issue.STATUS_RESOLVED)).isNotNull();
@@ -57,17 +59,47 @@ public class IssueWorkflowTest {
   public void should_list_statuses() throws Exception {
     workflow.start();
     // order is important for UI
-    assertThat(workflow.statusKeys()).containsSequence(Issue.STATUS_OPEN, Issue.STATUS_REOPENED, Issue.STATUS_RESOLVED, Issue.STATUS_CLOSED);
+    assertThat(workflow.statusKeys()).containsSequence(Issue.STATUS_OPEN, Issue.STATUS_CONFIRMED, Issue.STATUS_REOPENED, Issue.STATUS_RESOLVED, Issue.STATUS_CLOSED);
   }
 
   @Test
-  public void should_list_out_manual_transitions() throws Exception {
+  public void should_list_out_manual_transitions_from_status_open() throws Exception {
     workflow.start();
 
     DefaultIssue issue = new DefaultIssue().setStatus(Issue.STATUS_OPEN);
     List<Transition> transitions = workflow.outTransitions(issue);
-    assertThat(transitions).hasSize(2);
-    assertThat(keys(transitions)).containsOnly("falsepositive", "resolve");
+    assertThat(transitions).hasSize(3);
+    assertThat(keys(transitions)).containsOnly("confirm", "falsepositive", "resolve");
+  }
+
+  @Test
+  public void should_list_out_manual_transitions_from_status_confirmed() throws Exception {
+    workflow.start();
+
+    DefaultIssue issue = new DefaultIssue().setStatus(Issue.STATUS_CONFIRMED);
+    List<Transition> transitions = workflow.outTransitions(issue);
+    assertThat(transitions).hasSize(3);
+    assertThat(keys(transitions)).containsOnly("unconfirm", "falsepositive", "resolve");
+  }
+
+  @Test
+  public void should_list_out_manual_transitions_from_status_resolved() throws Exception {
+    workflow.start();
+
+    DefaultIssue issue = new DefaultIssue().setStatus(Issue.STATUS_RESOLVED);
+    List<Transition> transitions = workflow.outTransitions(issue);
+    assertThat(transitions).hasSize(1);
+    assertThat(keys(transitions)).containsOnly("reopen");
+  }
+
+  @Test
+  public void should_list_out_manual_transitions_from_status_reopen() throws Exception {
+    workflow.start();
+
+    DefaultIssue issue = new DefaultIssue().setStatus(Issue.STATUS_REOPENED);
+    List<Transition> transitions = workflow.outTransitions(issue);
+    assertThat(transitions).hasSize(3);
+    assertThat(keys(transitions)).containsOnly("confirm", "resolve", "falsepositive");
   }
 
   @Test
index 8ba23b9aa83cd530a92b4e502ab500fcd9a12e6d..0b66844d16e504b15d7ea8d216e11aca92496c19 100644 (file)
@@ -23,6 +23,8 @@ package org.sonar.api.issue;
  * @since 3.6
  */
 public interface DefaultTransitions {
+  String CONFIRM = "confirm";
+  String UNCONFIRM = "unconfirm";
   String REOPEN = "reopen";
   String RESOLVE = "resolve";
   String FALSE_POSITIVE = "falsepositive";
index 36bf2abc812defab5feffd0eff82874b81460ab6..4122e73212aa5feb37d17073648e97c3e4424017 100644 (file)
@@ -36,6 +36,7 @@ public interface Issue extends Serializable {
   int MESSAGE_MAX_SIZE = 4000;
 
   String STATUS_OPEN = "OPEN";
+  String STATUS_CONFIRMED = "CONFIRMED";
   String STATUS_REOPENED = "REOPENED";
   String STATUS_RESOLVED = "RESOLVED";
   String STATUS_CLOSED = "CLOSED";