### Question:
UserHibernateDao extends GenericDao<JCUser> implements UserDao { @Override public List<JCUser> getByUsernames(Set<String> usernames) { return (List<JCUser>) session().getNamedQuery("getByUsernames") .setParameterList("usernames", usernames) .list(); } UserHibernateDao(SessionFactory sessionFactory); @Override User getCommonUserByUsername(String username); @SuppressWarnings("unchecked") @Override JCUser getByUsername(String username); @Override JCUser getByEmail(String email); @SuppressWarnings("unchecked") @Override Collection<JCUser> getNonActivatedUsers(); @Override JCUser getByUuid(String uuid); @Override List<JCUser> getByUsernames(Set<String> usernames); @SuppressWarnings("unchecked") @Override List<String> getUsernames(String pattern, int count); @SuppressWarnings("unchecked") @Override List<JCUser> findByUsernameOrEmail(String pattern, int count); @Override JCUser loadById(Long id); @SuppressWarnings("unchecked") @Override List<UserDto> findByUsernameOrEmailNotInGroup(String pattern, long groupId, int count);  }### Answer:
@Test public void getByUsernamesShouldReturnExistsInRepoUsers() { String firstExistsUsername = "Shogun"; JCUser firstExistsUser = givenJCUserWithUsernameStoredInDb(firstExistsUsername); Set<String> existsUsernames = new HashSet<>(asList(firstExistsUsername)); List<JCUser> foundByUsernames = userDao.getByUsernames(existsUsernames); assertTrue(foundByUsernames.size() == existsUsernames.size(), "It should return all users by their names."); assertTrue(foundByUsernames.contains(firstExistsUser), firstExistsUser.getUsername() + "should be found by his name."); }
@Test public void getByUsernamesShouldReturnEmptyListWhenFoundUsersDoNotExist() { Set<String> existsUsernames = new HashSet<>(asList("Shogun", "jk1", "masyan")); List<JCUser> foundByUsernames = userDao.getByUsernames(existsUsernames); assertTrue(foundByUsernames.isEmpty(), "It should return empty list, cause found users not exist."); }