From bc33f4aee5e1c43e3a1784b97d464208c590943a Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 7 Jun 2013 10:27:00 +0200 Subject: [PATCH] SONAR-3755 Closed issues should be reopened only if manual issues --- .../core/issue/workflow/IssueWorkflow.java | 1 + .../issue/workflow/IssueWorkflowTest.java | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) 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 acc539876da..c532611afea 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 @@ -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()) 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 5d21f7767ef..da014a9c532 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 @@ -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 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 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(); -- 2.39.5