-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from NitorCreations/check-stop-state-type
Check stop state type
- Loading branch information
Showing
4 changed files
with
104 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...ine/src/test/java/com/nitorcreations/nflow/engine/workflow/definition/NextActionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.nitorcreations.nflow.engine.workflow.definition; | ||
|
||
import static com.nitorcreations.nflow.engine.workflow.definition.WorkflowStateType.end; | ||
import static com.nitorcreations.nflow.engine.workflow.definition.WorkflowStateType.manual; | ||
import static com.nitorcreations.nflow.engine.workflow.definition.WorkflowStateType.normal; | ||
import static com.nitorcreations.nflow.engine.workflow.definition.WorkflowStateType.start; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.nullValue; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import org.junit.Test; | ||
|
||
import com.nitorcreations.nflow.engine.internal.executor.InvalidNextActionException; | ||
|
||
public class NextActionTest { | ||
|
||
@Test(expected = InvalidNextActionException.class) | ||
public void stopInStartStateThrowsException() { | ||
NextAction.stopInState(TestState.initial, "stop reason"); | ||
} | ||
|
||
@Test(expected = InvalidNextActionException.class) | ||
public void stopInNormalStateThrowsException() { | ||
NextAction.stopInState(TestState.state1, "stop reason"); | ||
} | ||
|
||
@Test | ||
public void stopInManualStateSetsActivationToNull() { | ||
NextAction nextAction = NextAction.stopInState(TestState.error, "stop reason"); | ||
assertThat(nextAction.getActivation(), is(nullValue())); | ||
} | ||
|
||
@Test | ||
public void stopInEndStateSetsActivationToNull() { | ||
NextAction nextAction = NextAction.stopInState(TestState.done, "stop reason"); | ||
assertThat(nextAction.getActivation(), is(nullValue())); | ||
} | ||
|
||
static enum TestState implements WorkflowState { | ||
initial(start), state1(normal), error(manual), done(end); | ||
|
||
private final WorkflowStateType stateType; | ||
|
||
private TestState(WorkflowStateType stateType) { | ||
this.stateType = stateType; | ||
} | ||
|
||
@Override | ||
public WorkflowStateType getType() { | ||
return stateType; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name(); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return name(); | ||
} | ||
} | ||
} |