@Test void metadata() throws SQLException { Mockito.reset(connection); when(dataSource.getConnection()).thenReturn(connection); when(closer.add(connection)).thenReturn(connection); when(connection.getMetaData()).thenReturn(metadata); JdbcSqlExecutor sut = JdbcSqlExecutor.of(dataSource); DatabaseMetaData result = sut.metadata(closer); assertThat(result, sameInstance(metadata)); verify(dataSource, times(1)).getConnection(); verify(closer, times(1)).add(connection); verify(connection, times(1)).getMetaData(); verifyNoMoreInteractions(dataSource, connection, metadata); }
@Override public DatabaseMetaData metadata(CompositeAutoCloseable autoCloseable) { Connection connection = autoCloseable.add(connect()); return ConnectionUtil.getMetaData(connection); }
JdbcSqlExecutor implements SqlExecutor { @Override public DatabaseMetaData metadata(CompositeAutoCloseable autoCloseable) { Connection connection = autoCloseable.add(connect()); return ConnectionUtil.getMetaData(connection); } }
JdbcSqlExecutor implements SqlExecutor { @Override public DatabaseMetaData metadata(CompositeAutoCloseable autoCloseable) { Connection connection = autoCloseable.add(connect()); return ConnectionUtil.getMetaData(connection); } private  JdbcSqlExecutor(DataSource dataSource, int fetchSize, Executor executor); }
JdbcSqlExecutor implements SqlExecutor { @Override public DatabaseMetaData metadata(CompositeAutoCloseable autoCloseable) { Connection connection = autoCloseable.add(connect()); return ConnectionUtil.getMetaData(connection); } private  JdbcSqlExecutor(DataSource dataSource, int fetchSize, Executor executor); @Override Dialect dialect(); @Override JdbcTransaction beginTransaction(); @Override DatabaseMetaData metadata(CompositeAutoCloseable autoCloseable); @Override List<T> query(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); CompletableFuture<Integer> updateAsync(Connection connection, String sql, Object[] args); static JdbcSqlExecutor of(DataSource dataSource); static JdbcSqlExecutor of(DataSource dataSource, int fetchSize); static JdbcSqlExecutor of(DataSource dataSource, Executor executor); static JdbcSqlExecutor of(DataSource dataSource, int fetchSize, Executor executor); }
JdbcSqlExecutor implements SqlExecutor { @Override public DatabaseMetaData metadata(CompositeAutoCloseable autoCloseable) { Connection connection = autoCloseable.add(connect()); return ConnectionUtil.getMetaData(connection); } private  JdbcSqlExecutor(DataSource dataSource, int fetchSize, Executor executor); @Override Dialect dialect(); @Override JdbcTransaction beginTransaction(); @Override DatabaseMetaData metadata(CompositeAutoCloseable autoCloseable); @Override List<T> query(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); CompletableFuture<Integer> updateAsync(Connection connection, String sql, Object[] args); static JdbcSqlExecutor of(DataSource dataSource); static JdbcSqlExecutor of(DataSource dataSource, int fetchSize); static JdbcSqlExecutor of(DataSource dataSource, Executor executor); static JdbcSqlExecutor of(DataSource dataSource, int fetchSize, Executor executor);  }