/** * Creates a use case with the specified name that belongs to the specified model. * * @param useCaseName * the name of the use case to be created * @param model * the model that will contain the new use case */ UseCase(String useCaseName, Model model) { super(useCaseName, model); this.nameToFlowMap = new LinkedHashMap<>(); this.nameToStepMap = new LinkedHashMap<>(); this.basicFlow = newFlow(BASIC_FLOW); }
/** * Start a flow with the specified name. * * @param flowName * the name of the flow. * * @return the flow part to create the steps of the flow. */ public FlowPart flow(String flowName) { Flow useCaseFlow = getUseCase().newFlow(flowName); return new FlowPart(useCaseFlow, this); }
@Test public void flowsAreUniquelyIdentifiedByName() { UseCasePart useCasePart = modelBuilder.useCase(USE_CASE); UseCase useCase = useCasePart.getUseCase(); useCase.newFlow(ALTERNATIVE_FLOW); Flow existingFlow = useCase.findFlow(ALTERNATIVE_FLOW); assertEquals(2, useCase.getFlows().size()); // This is 2 because the basic flow always exists Iterator<Flow> flowIt = useCase.getFlows().iterator(); assertEquals(useCase.getBasicFlow(), flowIt.next()); assertEquals(existingFlow, flowIt.next()); }