RawJDBCExecutor { public boolean execute(final Collection<InputGroup<RawSQLExecuteUnit>> inputGroups, final RawSQLExecutorCallback callback) throws SQLException { List<ExecuteResult> results = doExecute(inputGroups, callback); if (null == results || results.isEmpty() || null == results.get(0)) { return false; } return results.get(0) instanceof ExecuteQueryResult; }  List<QueryResult> executeQuery(final Collection<InputGroup<RawSQLExecuteUnit>> inputGroups, final RawSQLExecutorCallback callback); int executeUpdate(final Collection<InputGroup<RawSQLExecuteUnit>> inputGroups, final RawSQLExecutorCallback callback); boolean execute(final Collection<InputGroup<RawSQLExecuteUnit>> inputGroups, final RawSQLExecutorCallback callback);  }
@Test public void assertExecuteForResultEmpty() throws SQLException { ExecutorKernel kernel = mock(ExecutorKernel.class); RawJDBCExecutor executor = new RawJDBCExecutor(kernel, true); assertFalse(executor.execute(null, null)); }
@Test public void assertExecuteForExecuteQueryResult() throws SQLException { ExecutorKernel kernel = mock(ExecutorKernel.class); when(kernel.execute(any(), any(), any(), anyBoolean())).thenReturn(Collections.singletonList(new ExecuteQueryResult(null, null))); RawJDBCExecutor executor = new RawJDBCExecutor(kernel, true); assertTrue(executor.execute(null, null)); }
@Test public void assertExecuteNotThrownSQLException() throws SQLException { ExecutorKernel kernel = mock(ExecutorKernel.class); when(kernel.execute(any(), any(), any(), anyBoolean())).thenThrow(new SQLException("TestSQLException")); RawJDBCExecutor rawJDBCExecutor = new RawJDBCExecutor(kernel, false); ExecutorExceptionHandler.setExceptionThrown(false); assertFalse(rawJDBCExecutor.execute(Collections.emptyList(), null)); }
@Test public void assertExecuteSQLException() { try { ExecutorKernel kernel = mock(ExecutorKernel.class); when(kernel.execute(any(), any(), any(), anyBoolean())).thenThrow(new SQLException("TestSQLException")); RawJDBCExecutor rawJDBCExecutor = new RawJDBCExecutor(kernel, false); rawJDBCExecutor.execute(Collections.emptyList(), null); } catch (final SQLException ex) { assertThat(ex.getMessage(), is("TestSQLException")); } }