UserServiceImpl implements UserService { @Override public Collection<User> getByGroup(UserGroup group) { Search searchByGroup = new Search(User.class); if (group.getGroupName() != null) { searchByGroup.addFilterSome("groups", Filter.equal("groupName", group.getGroupName())); } else { searchByGroup.addFilterSome("groups", Filter.equal("id", group.getId())); } return userDAO.search(searchByGroup); }  void setUserGroupDAO(UserGroupDAO userGroupDAO); void setUserAttributeDAO(UserAttributeDAO userAttributeDAO); void setUserDAO(UserDAO userDAO); @Override long insert(User user); @Override long update(User user); @Override void updateAttributes(long id, List<UserAttribute> attributes); @Override User get(long id); @Override User get(String name); @Override boolean delete(long id); @Override List<User> getAll(Integer page, Integer entries); @Override List<User> getAll(Integer page, Integer entries, String nameLike,
            boolean includeAttributes); @Override long getCount(String nameLike); @Override boolean insertSpecialUsers(); @Override Collection<User> getByAttribute(UserAttribute attribute); @Override Collection<User> getByGroup(UserGroup group);  }
@Test public void testGetByGroupId() throws Exception { long groupId = createGroup("testgroup"); createUser("test", Role.USER, "tesPW", groupId); UserGroup group = new UserGroup(); group.setId(groupId); Collection<User> users = userService.getByGroup(group); assertEquals(1, users.size()); }
@Test public void testGetByGroupName() throws Exception { long groupId = createGroup("testgroup"); createUser("test", Role.USER, "tesPW", groupId); UserGroup group = new UserGroup(); group.setGroupName("testgroup"); Collection<User> users = userService.getByGroup(group); assertEquals(1, users.size()); }