From 980303089bff66290f91d867b756bfab9a0908d4 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 16 May 2013 15:09:24 +0200 Subject: [PATCH] SONAR-3755 save issue changes during automatic transitions --- .../org/sonar/core/issue/workflow/IssueWorkflow.java | 10 ++++++---- .../sonar/core/issue/workflow/IssueWorkflowTest.java | 5 ++++- 2 files changed, 10 insertions(+), 5 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 9ce287a3d59..dea050cb492 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 @@ -26,6 +26,7 @@ import org.sonar.api.issue.DefaultTransitions; import org.sonar.api.issue.Issue; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.IssueChangeContext; +import org.sonar.core.issue.IssueUpdater; import java.util.List; @@ -33,9 +34,11 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable private StateMachine machine; private final FunctionExecutor functionExecutor; + private final IssueUpdater updater; - public IssueWorkflow(FunctionExecutor functionExecutor) { + public IssueWorkflow(FunctionExecutor functionExecutor, IssueUpdater updater) { this.functionExecutor = functionExecutor; + this.updater = updater; } @Override @@ -109,7 +112,7 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable Transition transition = stateOf(issue).transition(transitionKey); if (transition != null && !transition.automatic()) { functionExecutor.execute(transition.functions(), issue, issueChangeContext); - issue.setStatus(transition.to()); + updater.setStatus(issue, transition.to(), issueChangeContext); return true; } return false; @@ -124,8 +127,7 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable Transition transition = stateOf(issue).outAutomaticTransition(issue); if (transition != null) { functionExecutor.execute(transition.functions(), issue, issueChangeContext); - issue.setStatus(transition.to()); - issue.setUpdateDate(issueChangeContext.date()); + updater.setStatus(issue, transition.to(), issueChangeContext); } } 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 0174a36c2e8..2d63c8a08b5 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 @@ -36,7 +36,10 @@ import static org.fest.assertions.Assertions.assertThat; import static org.fest.assertions.Fail.fail; public class IssueWorkflowTest { - IssueWorkflow workflow = new IssueWorkflow(new FunctionExecutor(new IssueUpdater())); + + + IssueUpdater updater = new IssueUpdater(); + IssueWorkflow workflow = new IssueWorkflow(new FunctionExecutor(updater), updater); @Test public void should_init_state_machine() throws Exception { -- 2.39.5