String nextFlowType2 = flowTestingUtils.addFlowDefinition(newFlowActivity());
TransitionFlowActivity transitionFlowActivity2 = new TransitionFlowActivity();
transitionFlowActivity2.setNextFlowType(nextFlowType2);
String flowTypeName = flowTestingUtils.addFlowDefinition(newFlowActivity(), transitionFlowActivity0, transitionFlowActivity1, transitionFlowActivity2);
FlowManagement flowManagement = flowTestingUtils.getFlowManager().getFlowManagement();
FlowState flowState = flowManagement.startFlowState(flowTypeName, true, null, returnToFlowLookupKey);
flowTestingUtils.advanceToEnd(flowState);
FlowState nextFlowState = flowManagement.getCurrentFlowState();
// the alternate condition was not met.
assertNotNull(nextFlowState);
assertEquals(nextFlowState.getFlowTypeName(), nextFlowType2);
flowState = flowManagement.startFlowState(flowTypeName, true, null, returnToFlowLookupKey);
flowState.setFinishKey(TransitionType.alternate.toString());
flowTestingUtils.advanceToEnd(flowState);
nextFlowState = flowManagement.getCurrentFlowState();
assertNotNull(nextFlowState);
assertEquals(nextFlowState.getFlowTypeName(), nextFlowType0);
flowState = flowManagement.startFlowState(flowTypeName, true, null, returnToFlowLookupKey);
flowState.setFinishKey("foo1");
flowTestingUtils.advanceToEnd(flowState);
nextFlowState = flowManagement.getCurrentFlowState();
assertNotNull(nextFlowState);
assertEquals(nextFlowState.getFlowTypeName(), nextFlowType1);
}