### Question:
UserHibernateDao extends GenericDao<PoulpeUser> implements UserDao { @Override public List<PoulpeUser> findUsersNotInList(String availableFilterText, List<PoulpeUser> listUsers, Pagination paginate) { availableFilterText = SqlLikeEscaper.escapeControlCharacters(availableFilterText); ArrayList<Long> ids = new ArrayList<Long>(); for (PoulpeUser b : listUsers) { ids.add(b.getId()); } Query query = null; if (ids.size() == 0) { query = session().getNamedQuery("findEnabledUsersByLikeUsername"); } else { query = session().getNamedQuery("findEnabledUsersByLikeUsernameNotInList"); query.setParameterList("listUsers", ids); } query.setString("username", MessageFormat.format(FORMAT, availableFilterText)); paginate.addPagination(query); return query.list(); } UserHibernateDao(SessionFactory sessionFactory); @Override List<PoulpeUser> findPoulpeUsersPaginated(String searchString, Pagination paginate); @Override List<PoulpeUser> findPoulpeUsersBySearchRequest(UserSearchRequest searchRequest); @Override int countUsernameMatches(String searchString); @Override PoulpeUser getByUsername(String username); @Override PoulpeUser getByEmail(String email); @Override PoulpeUser getByUUID(String uuid); @Override List<PoulpeUser> getUsersInGroups(List<Group> groups); @Override List<PoulpeUser> findUsersByUsernameAndPasswordHash(String username, String passwordHash); @Override List<PoulpeUser> findUsersNotInGroups(String availableFilterText,
                                                 List<Group> groups, Pagination paginate); @Override List<PoulpeUser> findUsersNotInList(String availableFilterText,
                                               List<PoulpeUser> listUsers, Pagination paginate); @Override void save(User user);  }### Answer:
@Test public void testFindUsersNotInList(){ List<PoulpeUser> allUsers = TestFixtures.usersListOf(6); allUsers.get(4).setEnabled(false); List<PoulpeUser> usersInGroup = allUsers.subList(0,3); saveAndEvict(allUsers); int limit = 5; List<PoulpeUser> actual = dao.findUsersNotInList(NO_FILTER, usersInGroup, Pages.paginate(0, limit)); int expectedUserCount = 2; assertEquals(actual.size(), expectedUserCount); }
@Test public void testFindUsersNotInList_EmptyGroup(){ List<PoulpeUser> allUsers = TestFixtures.usersListOf(6); allUsers.get(4).setEnabled(false); allUsers.get(3).setEnabled(false); List<PoulpeUser> usersInGroup = new ArrayList<PoulpeUser>(); saveAndEvict(allUsers); int limit = 5; List<PoulpeUser> actual = dao.findUsersNotInList(NO_FILTER, usersInGroup, Pages.paginate(0, limit)); int expectedUsersCount = 4; assertEquals(actual.size(), expectedUsersCount); }