@Test public void shouldFilterActiveUsers() { User user1 = new User(1L, "user1"); user1.setActive(true); User user2 = new User(2L, "user2"); user2.setActive(false); User user3 = new User(3L, "user3"); user3.setActive(true); ArrayList<User> users = new ArrayList<>(); users.add(user1); users.add(user2); users.add(user3); ArrayList<User> activeUsers = userService.filterForActiveUsers(users); assertThat(activeUsers.size(), is(2)); assertThat(activeUsers.get(0), is(user1)); assertThat(activeUsers.get(1), is(user3)); }
public ArrayList<User> filterForActiveUsers(List<User> userList) { Set<User> users = new LinkedHashSet<>(userList); CollectionUtils.filter(users, new Predicate() { @Override public boolean evaluate(Object o) { return ((User) o).getActive(); } }); return new ArrayList<>(users); }
UserService { public ArrayList<User> filterForActiveUsers(List<User> userList) { Set<User> users = new LinkedHashSet<>(userList); CollectionUtils.filter(users, new Predicate() { @Override public boolean evaluate(Object o) { return ((User) o).getActive(); } }); return new ArrayList<>(users); } }
UserService { public ArrayList<User> filterForActiveUsers(List<User> userList) { Set<User> users = new LinkedHashSet<>(userList); CollectionUtils.filter(users, new Predicate() { @Override public boolean evaluate(Object o) { return ((User) o).getActive(); } }); return new ArrayList<>(users); }  }
UserService { public ArrayList<User> filterForActiveUsers(List<User> userList) { Set<User> users = new LinkedHashSet<>(userList); CollectionUtils.filter(users, new Predicate() { @Override public boolean evaluate(Object o) { return ((User) o).getActive(); } }); return new ArrayList<>(users); }  static String getCommaSeparatedIds(List<Long> idList); @Transactional void create(User user, String resetPasswordLink); void createUser(User user, String passwordResetLink); @Transactional void update(User user); LinkedHashMap getPreferences(Long userId); void sendForgotPasswordEmail(User user, String resetPasswordLink); List<User> searchUser(String searchParam, Pagination pagination); User getUserWithRolesById(Long id); User getById(Long id); Long getUserIdByPasswordResetToken(String token); @Transactional void updateUserPassword(String token, String password); User getByUserName(String userName); User selectUserByUserNameAndPassword(String userName, String password); void updateUserPassword(Long userId, String password); @Transactional void disable(Long userId, Long modifiedBy); List<User> getUsersWithRightInNodeForProgram(Program program, SupervisoryNode node, String rightName); List<User> getUsersWithRightInHierarchyUsingBaseNode(Long nodeId, Program program, String rightName); List<User> getUsersWithRightOnWarehouse(Long id, String rightName); ArrayList<User> filterForActiveUsers(List<User> userList); Integer getTotalSearchResultCount(String searchParam); @Transactional String updateUserPreferences(Long userId, User user, Long programId, Long facilityId, List<Long> products); List<String> getSupervisoryRights(Long userId); }
UserService { public ArrayList<User> filterForActiveUsers(List<User> userList) { Set<User> users = new LinkedHashSet<>(userList); CollectionUtils.filter(users, new Predicate() { @Override public boolean evaluate(Object o) { return ((User) o).getActive(); } }); return new ArrayList<>(users); }  static String getCommaSeparatedIds(List<Long> idList); @Transactional void create(User user, String resetPasswordLink); void createUser(User user, String passwordResetLink); @Transactional void update(User user); LinkedHashMap getPreferences(Long userId); void sendForgotPasswordEmail(User user, String resetPasswordLink); List<User> searchUser(String searchParam, Pagination pagination); User getUserWithRolesById(Long id); User getById(Long id); Long getUserIdByPasswordResetToken(String token); @Transactional void updateUserPassword(String token, String password); User getByUserName(String userName); User selectUserByUserNameAndPassword(String userName, String password); void updateUserPassword(Long userId, String password); @Transactional void disable(Long userId, Long modifiedBy); List<User> getUsersWithRightInNodeForProgram(Program program, SupervisoryNode node, String rightName); List<User> getUsersWithRightInHierarchyUsingBaseNode(Long nodeId, Program program, String rightName); List<User> getUsersWithRightOnWarehouse(Long id, String rightName); ArrayList<User> filterForActiveUsers(List<User> userList); Integer getTotalSearchResultCount(String searchParam); @Transactional String updateUserPreferences(Long userId, User user, Long programId, Long facilityId, List<Long> products); List<String> getSupervisoryRights(Long userId);  }