@Test public void accessesExistingCustomerActor() { Actor actualCustomer = modelBuilder.actor(CUSTOMER); assertEquals(customer, actualCustomer); }
@Before public void setup() { setupWithRecordingModelRunner(); this.secondActor = modelBuilder.actor("Second Actor"); }
protected void setupWithRecordingModelRunner() { this.modelRunner = new ModelRunner().startRecording(); this.modelBuilder = Model.builder(); this.customer = modelBuilder.actor(CUSTOMER); this.displayedText = null; }
public Model buildWith(ModelBuilder modelBuilder) { normalUser = modelBuilder.actor("Normal User"); anonymousUser = modelBuilder.actor("Anonymous User"); Model model = modelBuilder.useCase("Get greeted") .basicFlow() .step("S1").as(normalUser).system(this::promptsUserToEnterFirstName) .step("S2").as(normalUser).user(ENTERS_FIRST_NAME).system(this::savesFirstName) .step("S3").as(normalUser, anonymousUser).system(this::promptsUserToEnterAge) .step("S4").as(normalUser, anonymousUser).user(ENTERS_AGE).system(this::savesAge) .step("S5").as(normalUser).system(this::greetsUserWithFirstName) .step("S6").as(normalUser, anonymousUser).system(this::greetsUserWithAge) .step("S7").as(normalUser, anonymousUser).system(this::stops) .flow("Handle out-of-bounds age").insteadOf("S5").condition(this::ageIsOutOfBounds) .step("S5a_1").system(this::informsUserAboutOutOfBoundsAge) .step("S5a_2").continuesAt("S3") .flow("Handle non-numerical age").insteadOf("S5") .step("S5b_1").on(NON_NUMERICAL_AGE).system(this::informsUserAboutNonNumericalAge) .step("S5b_2").continuesAt("S3") .flow("Anonymous greeted with age only").insteadOf("S5").condition(this::ageIsOk) .step("S5c_1").as(anonymousUser).continuesAt("S6") .flow("Anonymous does not enter name").insteadOf("S1") .step("S1a_1").as(anonymousUser).continuesAt("S3") .build(); return model; }
@Test public void createsTwoActorsWithSingleUseCaseStep() { Actor anotherActor = modelBuilder.actor("Another Actor"); UseCasePart useCasePart = modelBuilder.useCase(USE_CASE); Model model = useCasePart.basicFlow() .step(CUSTOMER_ENTERS_TEXT).as(customer, anotherActor).user(EntersText.class).system(displaysEnteredText()) .build(); Actor customerActor = model.findActor(customer.getName()); List<Step> steps = customerActor.getStepsOf(useCasePart.getUseCase()); Step step = steps.get(0); assertEquals(CUSTOMER_ENTERS_TEXT, step.getName()); assertEquals(CUSTOMER_ENTERS_TEXT, step.toString()); assertEquals(USE_CASE, step.getUseCase().getName()); assertEquals(customer, step.getActors()[0]); steps = anotherActor.getStepsOf(useCasePart.getUseCase()); step = steps.get(0); assertEquals(CUSTOMER_ENTERS_TEXT, step.getName()); assertEquals(anotherActor, step.getActors()[1]); }