ShowQueryCommand implements DynamicCommand { @Override public void execute(final ConsoleReader reader, final PrintWriter out, final ConsoleState state) { Assertions.checkNotNull("reader", reader); Assertions.checkNotNull("out", out); Assertions.checkNotNull("state", state); if (!accept(state)) { return; } out.println("query: "); out.println(state.getLastQuery()); out.flush(); state.setInput(null); state.clearBuffer(); }  @Override boolean accept(final ConsoleState state); @Override void execute(final ConsoleReader reader,
                         final PrintWriter out,
                         final ConsoleState state); @Override String getAutoCompleteCommand(); @Override String getCommand(); @Override String getDescription(); @Override String getFileCompletionCommand(); @Override FileCompletionMode getFileCompletionMode(); @Override boolean hasFileCompletion();  }
@Test(expected = IllegalArgumentException.class) public void testExecuteNull() { command.execute(null, null, null); }
@Test public void testValidParameter() { final ConsoleState state = new ConsoleState(null); state.setInput("show query"); state.appendBuffer("something"); command.execute(reader, out, state); assertThat(state.getBuffer().length(), is(0)); assertThat(state.getInput(), is("")); }