BaseWizard implements Wizard { @Override public boolean runSteps() { for (WizardScreen wizardScreen : this) { Step currentStep = wizardScreen.getStep(getAnswers()); if (!currentStep.run()) { return false; } Optional<String> answer = Optional.ofNullable(currentStep.getAnswer()); if (answer.isPresent()) { Class<? extends Step> stepClass = currentStep.getClass(); getAnswers().putAnswer(stepClass, answer.get()); } } return true; }  @Override boolean runSteps(); @Override boolean hasNext(); @Override WizardScreen next(); @Override Iterator<WizardScreen> iterator(); abstract String getCommand();  }
@Test public void testRunSteps() { assertThat(mockBaseWizard.runSteps(), is(true)); assertThat(mockBaseWizard.getCommand(), equalTo("^two$ n")); }
@Test public void testFailingStep() { mockBaseWizard.setAllStepsPass(false); assertThat(mockBaseWizard.runSteps(), is(false)); }