QueryCommand implements DynamicCommand { @Override public boolean accept(final ConsoleState state) { Assertions.checkNotNull("state", state); if (state.getActiveCommand() != null && state.getActiveCommand() instanceof QueryCommand) { return true; } else if (validateStatement(state, "select") || validateStatement(state, "use") || validateStatement(state, "define")) { if (state.getInput().trim().contains(";")) { if (state.getInput().trim().contains("; > ")) { return true; } if (state.getInput().trim().endsWith(";")) { return true; } return false; } return true; } else if (state.getInput().trim().contains("; > ")) { return true; } else if (state.getInput().trim().endsWith(";")) { return true; } return false; }  @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 public void testAcceptInValidParameter() { state.setInput("selecx "); assertThat(command.accept(state), is(false)); }
@Test public void testAcceptInValidParameter2() { final ConsoleState state = new ConsoleState(null); state.setInput("add select"); assertThat(command.accept(state), is(false)); }
@Test public void testAcceptInValidParameter3() { final ConsoleState state = new ConsoleState(null); state.setInput("selectx"); assertThat(command.accept(state), is(false)); }
@Test public void testAcceptInValidParameter4() { final ConsoleState state = new ConsoleState(null); state.setInput("selectx xx"); assertThat(command.accept(state), is(false)); }
@Test public void testAcceptInValidParameter5() { final ConsoleState state = new ConsoleState(null); state.setInput("select *; > "); assertThat(command.accept(state), is(false)); }
@Test public void testAcceptInValidParameter6() { final ConsoleState state = new ConsoleState(null); state.setInput("select *; < "); assertThat(command.accept(state), is(false)); }
@Test(expected = IllegalArgumentException.class) public void testAcceptNull() { assertThat(command.accept(null), is(false)); }
@Test public void testAcceptNullInout() { state.setInput(null); assertThat(command.accept(state), is(false)); }
@Test public void testAcceptValidParameter() { state.setInput("select *; > test.out"); assertThat(command.accept(state), is(true)); }
@Test public void testAcceptValidParameter2() { state.setInput("select *;"); assertThat(command.accept(state), is(true)); }
@Test public void testAcceptValidParameter3() { state.setInput("select"); assertThat(command.accept(state), is(true)); }
@Test public void testAcceptValidParameter4() { state.setInput("use"); assertThat(command.accept(state), is(true)); }
@Test public void testAcceptValidParameter5() { state.setInput("define"); assertThat(command.accept(state), is(true)); }