@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());
  }
 private AuthorizationGroupPE createAuthGroupInDB(String authGroupCode) {
   AuthorizationGroupPE group = new AuthorizationGroupPE();
   group.setCode(authGroupCode);
   group.setDatabaseInstance(daoFactory.getHomeDatabaseInstance());
   group.setDescription("Rivia users");
   group.setRegistrator(getSystemPerson());
   daoFactory.getAuthorizationGroupDAO().create(group);
   return daoFactory.getAuthorizationGroupDAO().tryFindByCode(authGroupCode);
 }