Example #1
0
  @Test
  public void getOrganizationsTest() {
    User user = getUser(UserRole.ROLE_ORG_ADMIN, UserRole.ROLE_GROUP_USER);
    user = userService.getByEmail(user.getEmail());

    List<Organization> organizations = userService.getOrganizations(user);
    assertTrue(organizations.size() == 1);
  }
Example #2
0
  @Test
  public void addUserToOrganizationTest() {
    User user = getUser(UserRole.ROLE_ORG_USER, UserRole.ROLE_GROUP_USER);

    Organization newOrganization = new Organization();
    newOrganization.setName("New Organization");
    organizationService.add(newOrganization);

    organizationService.getAll();

    userService.addUserToOrganization(user, newOrganization.getId(), UserRole.ROLE_ORG_USER);
    List<Organization> organizations = userService.getOrganizations(user);
    assertTrue(organizations.size() == 2);
    assertTrue(userService.isUserInOrganization(user, newOrganization, UserRole.ROLE_ORG_USER));
  }
Example #3
0
  @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);
    }
  }