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;
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
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;
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);
}
}
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 {