@Test void query() throws SQLException { when(sqlExecutor.connect()).thenReturn(connection); JdbcTransaction sut = new JdbcTransaction(sqlExecutor); String sql = RandomStringUtils.randomAlphabetic(20, 30); Object[] args = new Object[0]; RowMapper<String> rowMapper = s -> "Hello"; List<String> list = ImmutableList.of("A", "B"); when(sqlExecutor.query(connection, sql, args, rowMapper)).thenReturn(list); List<String> result = sut.query(sql, args, rowMapper); assertThat(result, sameInstance(list)); verify(connection).setAutoCommit(false); verify(sqlExecutor).query(connection, sql, args, rowMapper); verifyNoMoreInteractions(sqlExecutor, connection); }
@Override public <T> List<T> query(String sql, Object[] args, RowMapper<T> rowMapper) { return sqlExecutor.query(connection, sql, args, rowMapper); }
JdbcTransaction implements Transaction { @Override public <T> List<T> query(String sql, Object[] args, RowMapper<T> rowMapper) { return sqlExecutor.query(connection, sql, args, rowMapper); } }
JdbcTransaction implements Transaction { @Override public <T> List<T> query(String sql, Object[] args, RowMapper<T> rowMapper) { return sqlExecutor.query(connection, sql, args, rowMapper); } JdbcTransaction(JdbcSqlExecutor sqlExecutor); }
JdbcTransaction implements Transaction { @Override public <T> List<T> query(String sql, Object[] args, RowMapper<T> rowMapper) { return sqlExecutor.query(connection, sql, args, rowMapper); } 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 <T> List<T> query(String sql, Object[] args, RowMapper<T> rowMapper) { return sqlExecutor.query(connection, sql, args, rowMapper); } 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();  }