@Test public void testFindAll() { List<User> actual = userRepository.findAll(); assertArrayEquals(EXPECTED_USERS.toArray(), actual.toArray()); }
@Override public List<User> findAll() { try { PreparedStatement statement = connection.prepareStatement(SQL_SELECT_ALL); ResultSet resultSet = statement.executeQuery(); List<User> users = new ArrayList<>(); while (resultSet.next()) { User newUser = rowMapper.rowMap(resultSet); users.add(newUser); } return users; } catch (SQLException e) { throw new IllegalArgumentException(e); } }
UsersRepositoryConnectionImpl implements UsersRepository { @Override public List<User> findAll() { try { PreparedStatement statement = connection.prepareStatement(SQL_SELECT_ALL); ResultSet resultSet = statement.executeQuery(); List<User> users = new ArrayList<>(); while (resultSet.next()) { User newUser = rowMapper.rowMap(resultSet); users.add(newUser); } return users; } catch (SQLException e) { throw new IllegalArgumentException(e); } } }
UsersRepositoryConnectionImpl implements UsersRepository { @Override public List<User> findAll() { try { PreparedStatement statement = connection.prepareStatement(SQL_SELECT_ALL); ResultSet resultSet = statement.executeQuery(); List<User> users = new ArrayList<>(); while (resultSet.next()) { User newUser = rowMapper.rowMap(resultSet); users.add(newUser); } return users; } catch (SQLException e) { throw new IllegalArgumentException(e); } } UsersRepositoryConnectionImpl(Connection connection); }
UsersRepositoryConnectionImpl implements UsersRepository { @Override public List<User> findAll() { try { PreparedStatement statement = connection.prepareStatement(SQL_SELECT_ALL); ResultSet resultSet = statement.executeQuery(); List<User> users = new ArrayList<>(); while (resultSet.next()) { User newUser = rowMapper.rowMap(resultSet); users.add(newUser); } return users; } catch (SQLException e) { throw new IllegalArgumentException(e); } } UsersRepositoryConnectionImpl(Connection connection); @Override Optional<User> findOne(Long id); @Override void save(User model); @Override void delete(Long id); @Override List<User> findAll(); }
UsersRepositoryConnectionImpl implements UsersRepository { @Override public List<User> findAll() { try { PreparedStatement statement = connection.prepareStatement(SQL_SELECT_ALL); ResultSet resultSet = statement.executeQuery(); List<User> users = new ArrayList<>(); while (resultSet.next()) { User newUser = rowMapper.rowMap(resultSet); users.add(newUser); } return users; } catch (SQLException e) { throw new IllegalArgumentException(e); } } UsersRepositoryConnectionImpl(Connection connection); @Override Optional<User> findOne(Long id); @Override void save(User model); @Override void delete(Long id); @Override List<User> findAll();  }