@Test void update() throws SQLException { when(sqlExecutor.connect()).thenReturn(connection); JdbcTransaction sut = new JdbcTransaction(sqlExecutor); String sql = RandomStringUtils.randomAlphabetic(20, 30); Object[] args = new Object[0]; int rowsUpdated = RandomValues.randomShort(); when(sqlExecutor.update(connection, sql, args)).thenReturn(rowsUpdated); int result = sut.update(sql, args); assertThat(result, is(rowsUpdated)); verify(connection).setAutoCommit(false); verify(sqlExecutor).update(connection, sql, args); verifyNoMoreInteractions(sqlExecutor, connection); }
@Override public int update(String sql, Object[] args) { return sqlExecutor.update(connection, sql, args); }
JdbcTransaction implements Transaction { @Override public int update(String sql, Object[] args) { return sqlExecutor.update(connection, sql, args); } }
JdbcTransaction implements Transaction { @Override public int update(String sql, Object[] args) { return sqlExecutor.update(connection, sql, args); } JdbcTransaction(JdbcSqlExecutor sqlExecutor); }
JdbcTransaction implements Transaction { @Override public int update(String sql, Object[] args) { return sqlExecutor.update(connection, sql, args); } JdbcTransaction(JdbcSqlExecutor sqlExecutor); @Override void commit(); @Override void rollback(); @Override List<T> query(String sql, Object[] args, RowMapper<T> rowMapper); @Override CompletableFuture<List<T>> queryAsync(String sql, Object[] args, RowMapper<T> rowMapper); @Override Stream<T> stream(String sql, Object[] args, RowMapper<T> rowMapper); @Override int update(String sql, Object[] args); @Override boolean execute(String sql, Object[] args); @Override CompletableFuture<Integer> updateAsync(String sql, Object[] args); @Override void close(); }
JdbcTransaction implements Transaction { @Override public int update(String sql, Object[] args) { return sqlExecutor.update(connection, sql, args); } JdbcTransaction(JdbcSqlExecutor sqlExecutor); @Override void commit(); @Override void rollback(); @Override List<T> query(String sql, Object[] args, RowMapper<T> rowMapper); @Override CompletableFuture<List<T>> queryAsync(String sql, Object[] args, RowMapper<T> rowMapper); @Override Stream<T> stream(String sql, Object[] args, RowMapper<T> rowMapper); @Override int update(String sql, Object[] args); @Override boolean execute(String sql, Object[] args); @Override CompletableFuture<Integer> updateAsync(String sql, Object[] args); @Override void close();  }