]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3755 Closed issues should be reopened only if manual issues
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 7 Jun 2013 08:27:00 +0000 (10:27 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 7 Jun 2013 08:27:00 +0000 (10:27 +0200)
sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java
sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java

index acc539876daa3d63d96aa2ea0313f4d519afc74c..c532611afeaf6cbf250cbed64f4c72b9f543cb68 100644 (file)
@@ -78,6 +78,7 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable
         .functions(new SetResolution(null))
         .build())
       .transition(Transition.builder(DefaultTransitions.REOPEN)
+        .conditions(new IsManual(true))
         .from(Issue.STATUS_CLOSED).to(Issue.STATUS_REOPENED)
         .functions(new SetResolution(null), new SetCloseDate(false))
         .build())
index 5d21f7767ef656579b9b4adb90ee6e9af841016e..da014a9c532889d6216938a4e3727d4d38d3df9a 100644 (file)
@@ -104,6 +104,31 @@ public class IssueWorkflowTest {
     assertThat(keys(transitions)).containsOnly("confirm", "resolve", "falsepositive");
   }
 
+  @Test
+  public void should_list_no_out_transition_from_status_closed() throws Exception {
+    workflow.start();
+
+    DefaultIssue issue = new DefaultIssue().setStatus(Issue.STATUS_CLOSED);
+    List<Transition> transitions = workflow.outTransitions(issue);
+    assertThat(transitions).isEmpty();
+  }
+
+  @Test
+  public void should_list_out_transitions_from_status_closed_on_manual_issue() throws Exception {
+    workflow.start();
+
+    // Manual issue because of reporter
+    DefaultIssue issue = new DefaultIssue()
+      .setKey("ABCDE")
+      .setStatus(Issue.STATUS_CLOSED)
+      .setRuleKey(RuleKey.of("manual", "Performance"))
+      .setReporter("simon");
+
+    List<Transition> transitions = workflow.outTransitions(issue);
+    assertThat(transitions).hasSize(1);
+    assertThat(keys(transitions)).containsOnly("reopen");
+  }
+
   @Test
   public void should_fail_if_unknown_status_when_listing_transitions() throws Exception {
     workflow.start();