public ContinuesAfter(String stepName, UseCase useCase) { super(stepName, (FlowStep)useCase.findStep(stepName)); } }
public ContinuesAt(String stepName, UseCase useCase) { super(stepName, ((FlowStep)useCase.findStep(stepName)).getPreviousStepInFlow().orElse(null)); } }
public ContinuesWithoutAlternativeAt(String continueAtStepName, FlowStep currentStep) { super(continueAtStepName); FlowStep continueAtStep = ((FlowStep) currentStep.getUseCase().findStep(continueAtStepName)); continueAtStep.orAfter(currentStep); }
/** * Starts the flow as an alternative to the specified step, in this flow's use * case. * * @param stepName * the name of the specified step * @return the flow position part, to ease creation of the condition and the * first step of the flow * @throws NoSuchElementInModel * if the specified step is not found in this * flow's use case */ public FlowPositionPart insteadOf(String stepName) { FlowStep step = (FlowStep) useCase.findStep(stepName); InsteadOf insteadOf = new InsteadOf(step); optionalFlowPositionPart = new FlowPositionPart(insteadOf, this); return optionalFlowPositionPart; }
/** * Starts the flow after the specified step has been run, in this flow's use * case. * * Note: You should use after to handle exceptions that occurred in the * specified step. * * @param stepName * the name of the step to start the flow after * @return the flow position part, to ease creation of the condition and the * first step of the flow * @throws NoSuchElementInModel * if the specified step is not found in a flow * of this use case * */ public FlowPositionPart after(String stepName) { Step step = useCase.findStep(stepName); After after = new After((FlowStep) step); optionalFlowPositionPart = new FlowPositionPart(after, this); return optionalFlowPositionPart; }
@Test public void createsTwoStepsAndPreviousStepOfSecondOneIsFirstOne() { UseCasePart useCasePart = modelBuilder.useCase(USE_CASE); useCasePart.basicFlow() .step(SYSTEM_DISPLAYS_TEXT).system(displaysConstantText()) .step(SYSTEM_DISPLAYS_TEXT_AGAIN).system(displaysConstantText()); FlowStep firstUseCaseStep = (FlowStep)useCasePart.getUseCase().findStep(SYSTEM_DISPLAYS_TEXT); FlowStep secondUseCaseStep = (FlowStep)useCasePart.getUseCase().findStep(SYSTEM_DISPLAYS_TEXT_AGAIN); assertEquals(firstUseCaseStep, secondUseCaseStep.getPreviousStepInFlow().get()); }
@Test public void createsTwoStepsInDifferentFlowsThatBothHaveNoPreviousSteps() { UseCasePart useCasePart = modelBuilder.useCase(USE_CASE); useCasePart .basicFlow() .step(SYSTEM_DISPLAYS_TEXT).system(displaysConstantText()) .flow(ALTERNATIVE_FLOW) .step(SYSTEM_DISPLAYS_TEXT_AGAIN).system(displaysConstantText()); FlowStep firstUseCaseStep = (FlowStep)useCasePart.getUseCase().findStep(SYSTEM_DISPLAYS_TEXT); FlowStep secondUseCaseStep = (FlowStep)useCasePart.getUseCase().findStep(SYSTEM_DISPLAYS_TEXT_AGAIN); assertFalse(firstUseCaseStep.getPreviousStepInFlow().isPresent()); assertFalse(secondUseCaseStep.getPreviousStepInFlow().isPresent()); }
@Test public void createsTwoStepsIncrementally() { UseCasePart useCasePart = modelBuilder.useCase(USE_CASE); modelBuilder.useCase(USE_CASE).basicFlow().step(SYSTEM_DISPLAYS_TEXT).system(displaysConstantText()); useCasePart = modelBuilder.useCase(USE_CASE); modelBuilder.useCase(USE_CASE).basicFlow() .step(SYSTEM_DISPLAYS_TEXT_AGAIN).system(displaysConstantText()); FlowStep firstUseCaseStep = (FlowStep)useCasePart.getUseCase().findStep(SYSTEM_DISPLAYS_TEXT); FlowStep secondUseCaseStep = (FlowStep)useCasePart.getUseCase().findStep(SYSTEM_DISPLAYS_TEXT_AGAIN); assertEquals(firstUseCaseStep, secondUseCaseStep.getPreviousStepInFlow().get()); }