]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3755 save issue changes during automatic transitions
authorSimon Brandhof <simon.brandhof@gmail.com>
Thu, 16 May 2013 13:09:24 +0000 (15:09 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Thu, 16 May 2013 13:09:24 +0000 (15:09 +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 9ce287a3d599fa1ff7602d4e45c18e9ea1f1b54b..dea050cb4928ebab373090d1d0e213f8c5951029 100644 (file)
@@ -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);
     }
   }
 
index 0174a36c2e881a84368668aee4155c994623a6ae..2d63c8a08b59ea3a3a4c4fe6463094f275d6121c 100644 (file)
@@ -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 {