private boolean messageIsForThisActor(ActorPerformanceEvent event) { return event.getName().equals(actor.getName()); }
private <T extends Performable> void notifyPerformanceOf(T todo) { Broadcaster.getEventBus().post(new ActorPerforms(todo, getName())); }
public Actor shineSpotlightOn(String actorName) { Optional<Actor> knownActor = cast.getActors() .stream() .filter(actor -> actor.getName().equalsIgnoreCase(actorName)) .findFirst(); actorInTheSpotlight = knownActor.orElseGet(() -> cast.actorNamed(actorName)); return theActorInTheSpotlight().withNoPronoun(); }
public void assignDescriptionToActor(String description) { StepEventBus.getEventBus().getBaseStepListener().latestTestOutcome().ifPresent( testOutcome -> testOutcome.assignDescriptionToActor(getName(), description) ); } }
public void assignFactToActor(Actor actor, String fact) { if (!StepEventBus.getEventBus().isBaseStepListenerRegistered()) { return; } StepEventBus.getEventBus().getBaseStepListener().latestTestOutcome().ifPresent( testOutcome -> testOutcome.assignFact(actor.getName(), fact) ); }
public static BrowseTheWeb as(Actor actor) { if (actor.abilityTo(BrowseTheWeb.class) == null) { throw new ActorCannotBrowseTheWebException(actor.getName()); } return actor.abilityTo(BrowseTheWeb.class).asActor(actor); }
@Override public void evaluateFor(Actor actor) { if (thisStepShouldBeIgnored() && !StepEventBus.getEventBus().softAssertsActive()) { return; } Broadcaster.getEventBus().post(new ActorAsksQuestion(question, actor.getName())); try { optionalPrecondition.orElse(DO_NOTHING).performAs(actor); assertThat(reason(), question.answeredBy(actor), is(true)); } catch (Throwable actualError) { throwComplaintTypeErrorIfSpecified(errorFrom(actualError)); throwDiagosticErrorIfProvided(errorFrom(actualError)); throw actualError; } }
public void assignAbilityToActor(Actor actor, String ability) { if (!StepEventBus.getEventBus().isBaseStepListenerRegistered()) { return; } if (StepEventBus.getEventBus().getBaseStepListener().latestTestOutcome() == null) { return; } StepEventBus.getEventBus().getBaseStepListener().latestTestOutcome().ifPresent( testOutcome -> testOutcome.assignAbility(actor.getName(), ability) ); }
@Override public void evaluateFor(Actor actor) { if (thisStepShouldBeIgnored() && !StepEventBus.getEventBus().softAssertsActive()) { return; } Broadcaster.getEventBus().post(new ActorAsksQuestion(question, actor.getName())); Serenity.injectScenarioStepsInto(question); try { optionalPrecondition.orElse(DO_NOTHING).performAs(actor); assertTrue("predicate failed", expected.test(question.answeredBy(actor))); } catch (Throwable actualError) { throwComplaintTypeErrorIfSpecified(errorFrom(actualError)); throwDiagosticErrorIfProvided(errorFrom(actualError)); throw actualError; } }
@Override public void evaluateFor(Actor actor) { if (thisStepShouldBeIgnored() && !StepEventBus.getEventBus().softAssertsActive()) { return; } Broadcaster.getEventBus().post(new ActorAsksQuestion(question, actor.getName())); Serenity.injectScenarioStepsInto(question); try { optionalPrecondition.orElse(DO_NOTHING).performAs(actor); addHints(fromAssertion(expected)).to(question); assertThat(question.answeredBy(actor), expected); } catch (Throwable actualError) { throwComplaintTypeErrorIfSpecified(errorFrom(actualError)); throwDiagosticErrorIfProvided(errorFrom(actualError)); throw actualError; } }