String nextFlowType = flowTestingUtils.addFlowDefinition(newFlowActivity());
TransitionFlowActivity transitionFlowActivity = new TransitionFlowActivity();
transitionFlowActivity.setTransitionType(TransitionType.alternate);
transitionFlowActivity.setNextFlowType(nextFlowType);
String flowTypeName = flowTestingUtils.addFlowDefinition(newFlowActivity(), transitionFlowActivity);
FlowManagement flowManagement = flowTestingUtils.getFlowManager().getFlowManagement();
FlowStateImplementor flowState = flowManagement.startFlowState(flowTypeName, true, null, returnToFlowLookupKey);
flowTestingUtils.advanceToEnd(flowState);
FlowState nextFlowState = flowManagement.getCurrentFlowState();
// the alternate condition was not met.
assertNull(nextFlowState);
flowState = flowManagement.startFlowState(flowTypeName, true, null, returnToFlowLookupKey);
flowState.setFinishKey(TransitionType.alternate.toString());
// make sure cache can't help 'cheat'
flowState.clearCache();
flowTestingUtils.advanceToEnd(flowState);
nextFlowState = flowManagement.getCurrentFlowState();
assertNotNull(nextFlowState);
assertEquals(nextFlowState.getFlowTypeName(), nextFlowType);
assertNull(nextFlowState.getFinishKey(), "nextFlowState="+nextFlowState);
}