use of com.dangdang.ddframe.rdb.sharding.executor.wrapper.PreparedStatementExecutorWrapper in project sharding-jdbc by dangdangdotcom.
the class PreparedStatementExecutorTest method assertExecuteUpdateForSinglePreparedStatementSuccess.
@Test
public void assertExecuteUpdateForSinglePreparedStatementSuccess() throws SQLException {
PreparedStatement preparedStatement = mock(PreparedStatement.class);
PreparedStatementExecutorWrapper wrapper = createPreparedStatementExecutorWrapperForDML(preparedStatement, "ds_0");
when(preparedStatement.executeUpdate()).thenReturn(10);
PreparedStatementExecutor actual = new PreparedStatementExecutor(executorEngine, Collections.singleton(wrapper));
assertThat(actual.executeUpdate(), is(10));
verify(preparedStatement).executeUpdate();
verify(eventCaller, times(2)).verifyDataSource("ds_0");
verify(eventCaller, times(2)).verifySQL("DELETE FROM dual");
verify(eventCaller, times(2)).verifyParameters(Collections.emptyList());
verify(eventCaller).verifyEventExecutionType(EventExecutionType.BEFORE_EXECUTE);
verify(eventCaller).verifyEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
verify(eventCaller, times(0)).verifyException(null);
}
Aggregations