private void measuresPerformance(StepToBeRun stepToBeRun) { long timeBefore = System.nanoTime(); stepToBeRun.run(); long timeAfter = System.nanoTime(); long timeElapsed = timeAfter - timeBefore; System.out.println("Step " + stepToBeRun.getStepName() + " took " + timeElapsed + " nanoseconds."); }
private Consumer<StepToBeRun> recordStepDetails() { return stepToBeRun -> { stepName = stepToBeRun.getStepName(); optionalCondition = stepToBeRun.getCondition(); optionalEvent = stepToBeRun.getEvent(); systemReaction = stepToBeRun.getSystemReaction(); stepToBeRun.run(); }; }
@Override public void accept(StepToBeRun stepToBeRun) { stepToBeRun.run(); } }
/** * Constructor for creating a runner with standard system reaction, that is: the * system reaction, as defined in the step, simply accepts an event. */ public ModelRunner() { this.stepToBeRun = new StepToBeRun(); this.recordedStepNames = new ArrayList<>(); this.recordedEvents = new ArrayList<>(); handleWith(new DirectCallToRunMethodOfStepToBeRun()); }
private <T> Step triggerSystemReactionForStep(T event, Step step) { if (step.getSystemReaction() == null) { throw new MissingUseCaseStepPart(step, "system"); } stepToBeRun.setupWith(event, step); recordStepNameAndEvent(step, event); setLatestStep(step); try { eventHandler.accept(stepToBeRun); } catch (Exception e) { handleException(e); } continueAfterIncludeStepWhenEndOfIncludedFlowIsReached(); triggerAutonomousSystemReaction(); return step; }