YesNoStep extends AbstractStep { @Override public boolean run() { yes = null; printMessageWithDefaultAnswer(); String answer = waitForAnswer(); while (!validateAnswer(answer)) { logger.warn("Answer should be y or n. Please try again or type q to quit:"); answer = waitForAnswer(); } if (isExitKey(answer)) { return false; } yes = answer; return anyAnswerIsCorrect() || isYesKey(yes); }  @Override boolean run(); @Override String getAnswer();  }
@Test public void testQuit() throws Exception { MockYesNoStep step = applicationContext.getBean(MockYesNoStep.class); step.setConsoleReader(mockConsoleReader(QUIT + "\n")); assertThat(step.run(), is(false)); }
@Test public void testRun() throws Exception { testRun(false, false); }