@Test void stream() 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"; when(sqlExecutor.stream(eq(connection), eq(sql), eq(args), eq(rowMapper), any())).thenReturn(stream); Stream<String> result = sut.stream(sql, args, rowMapper); assertThat(result, sameInstance(stream)); verify(connection).setAutoCommit(false); verify(sqlExecutor).stream(eq(connection), eq(sql), eq(args), eq(rowMapper), any()); verifyNoMoreInteractions(sqlExecutor, connection); }
@Override public <T> Stream<T> stream(String sql, Object[] args, RowMapper<T> rowMapper) { return autoCloseable.add(sqlExecutor.stream(connection, sql, args, rowMapper, new CompositeAutoCloseable())); }
JdbcTransaction implements Transaction { @Override public <T> Stream<T> stream(String sql, Object[] args, RowMapper<T> rowMapper) { return autoCloseable.add(sqlExecutor.stream(connection, sql, args, rowMapper, new CompositeAutoCloseable())); } }
JdbcTransaction implements Transaction { @Override public <T> Stream<T> stream(String sql, Object[] args, RowMapper<T> rowMapper) { return autoCloseable.add(sqlExecutor.stream(connection, sql, args, rowMapper, new CompositeAutoCloseable())); } JdbcTransaction(JdbcSqlExecutor sqlExecutor); }
JdbcTransaction implements Transaction { @Override public <T> Stream<T> stream(String sql, Object[] args, RowMapper<T> rowMapper) { return autoCloseable.add(sqlExecutor.stream(connection, sql, args, rowMapper, new CompositeAutoCloseable())); } 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> Stream<T> stream(String sql, Object[] args, RowMapper<T> rowMapper) { return autoCloseable.add(sqlExecutor.stream(connection, sql, args, rowMapper, new CompositeAutoCloseable())); } 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();  }