@Test public void getGroupsForOrgAdminTest() { User user = getUser(UserRole.ROLE_ORG_ADMIN, UserRole.ROLE_GROUP_USER); user = userService.getByEmail(user.getEmail()); List<Group> groups = userService.getGroups(user); assertTrue(groups.size() == 1); }
@Test public void deleteTest() { User user = getUser(UserRole.ROLE_ORG_USER, UserRole.ROLE_GROUP_USER); List<Group> groups = userService.getGroups(user); assertTrue(groups.size() == 1); List<UserDomain> userGroupDomains = userDomainService.getAll(groups.get(0).getId(), DomainType.GROUP); assertTrue(userGroupDomains.size() == 1); userService.delete(user.getId()); userGroupDomains = userDomainService.getAll(groups.get(0).getId(), DomainType.GROUP); assertTrue(userGroupDomains.size() == 0); }
@Test public void addUserToGroupTest() { User user = getUser(UserRole.ROLE_ORG_USER, UserRole.ROLE_GROUP_USER); Group newGroup = new Group(); newGroup.setName("New Group"); groupService.add(newGroup); groupService.getAll(); userService.addUserToGroup(user, newGroup.getId(), UserRole.ROLE_GROUP_USER); List<Group> groups = userService.getGroups(user); assertTrue(groups.size() == 2); assertTrue(userService.isUserInGroup(user, newGroup)); assertTrue(userService.isUserInGroup(user, newGroup, UserRole.ROLE_GROUP_USER)); }
@Test public void isUserInDomainTest() { User user = getUser(UserRole.ROLE_ORG_USER, UserRole.ROLE_GROUP_USER); List<Group> groups = userService.getGroups(user); for (Group group : groups) { boolean isInDomain = userService.isUserInDomain( user, group.getId(), DomainType.GROUP, UserRole.ROLE_GROUP_USER); assertTrue(isInDomain); } List<Organization> organizations = userService.getOrganizations(user); for (Organization organization : organizations) { boolean isInDomain = userService.isUserInDomain( user, organization.getId(), DomainType.ORGANIZATION, UserRole.ROLE_ORG_USER); assertTrue(isInDomain); } }