@Test
  public void testAddGroupAdminRoleToAuthorizationGroup() throws Exception {
    String code = AUTH_GROUP_ID;
    AuthorizationGroupPE authGroup = createAuthGroupInDB(code);
    AssertJUnit.assertEquals(
        0,
        daoFactory
            .getRoleAssignmentDAO()
            .listRoleAssignmentsByAuthorizationGroup(authGroup)
            .size());

    GroupPE group = daoFactory.getGroupDAO().listGroups().get(0);
    RoleAssignmentPE roleAssignment = new RoleAssignmentPE();
    roleAssignment.setRole(RoleCode.ADMIN);
    roleAssignment.setGroup(group);
    roleAssignment.setRegistrator(getSystemPerson());

    authGroup.addRoleAssignment(roleAssignment);
    AssertJUnit.assertEquals(
        1,
        daoFactory
            .getRoleAssignmentDAO()
            .listRoleAssignmentsByAuthorizationGroup(authGroup)
            .size());
  }
  @Test
  public void testAddGroupAdminRoleToUser() throws Exception {
    String userId = USER_ID;
    PersonPE user = createUserInDB(userId);
    AssertJUnit.assertEquals(
        0, daoFactory.getPersonDAO().tryFindPersonByUserId(userId).getRoleAssignments().size());
    AssertJUnit.assertEquals(
        0, daoFactory.getRoleAssignmentDAO().listRoleAssignmentsByPerson(user).size());

    GroupPE group = daoFactory.getGroupDAO().listGroups().get(0);
    RoleAssignmentPE roleAssignment = new RoleAssignmentPE();
    roleAssignment.setRole(RoleCode.ADMIN);
    roleAssignment.setGroup(group);
    roleAssignment.setRegistrator(getSystemPerson());

    user.addRoleAssignment(roleAssignment);
    AssertJUnit.assertEquals(
        1, daoFactory.getPersonDAO().tryFindPersonByUserId(userId).getRoleAssignments().size());
    AssertJUnit.assertEquals(
        1, daoFactory.getRoleAssignmentDAO().listRoleAssignmentsByPerson(user).size());
  }