コード例 #1
0
ファイル: UserServiceIT.java プロジェクト: shaan360/knappsack
  @Test
  public void addUserAdminToGroup() {
    User user = getUser(UserRole.ROLE_ORG_USER, UserRole.ROLE_GROUP_USER);

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

    Group group = new Group();
    group.setAccessCode(UUID.randomUUID().toString());
    group.setName("New Group");
    group.setOrganization(newOrganization);
    groupService.save(group);
    groupService.getAll();

    GroupUserRequest groupUserRequest =
        requestService.createGroupUserRequest(user, group.getAccessCode());
    requestService.getAll(group.getId());

    boolean isAdded =
        userService.addUserToGroup(
            groupUserRequest.getUser(),
            groupUserRequest.getGroup().getId(),
            UserRole.ROLE_GROUP_ADMIN);
    assertTrue(isAdded);
  }
コード例 #2
0
ファイル: UserServiceIT.java プロジェクト: shaan360/knappsack
  @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));
  }
コード例 #3
0
ファイル: UserServiceIT.java プロジェクト: shaan360/knappsack
  private Group createGroup(Organization organization) {
    Group group = new Group();
    group.setAccessCode(UUID.randomUUID().toString());
    group.setName("Test Group");
    group.setOrganization(organization);
    groupService.save(group);

    return group;
  }