コード例 #1
0
  @Test
  public void testRemoveCoach_withBusinessGroups() {
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
    // create a group with members
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("remp-proc-1");
    Identity member = JunitTestHelper.createAndPersistIdentityAsRndUser("remp-proc-2");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-3");

    repositoryEntryRelationDao.addRole(owner, re, GroupRoles.owner.name());
    repositoryEntryRelationDao.addRole(member, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(coach, re, GroupRoles.coach.name());

    BusinessGroup businessGroup =
        businessGroupDao.createAndPersist(
            coach, "mbr-proc-1", "mbr-proc-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRelationToResource(businessGroup, re);

    // create a publisher
    SubscriptionContext context = new SubscriptionContext(re.getOlatResource(), "");
    PublisherData publisherData = new PublisherData("testGroupPublishers", "e.g. something", null);
    Publisher publisher = notificationManager.getOrCreatePublisher(context, publisherData);
    Assert.assertNotNull(publisher);
    dbInstance.commitAndCloseSession();

    // subscribe
    notificationManager.subscribe(owner, context, publisherData);
    notificationManager.subscribe(member, context, publisherData);
    notificationManager.subscribe(coach, context, publisherData);
    dbInstance.commitAndCloseSession();

    // remove member and coach as coach of the repo entry
    List<Identity> removeIdentities = new ArrayList<>(2);
    removeIdentities.add(member);
    removeIdentities.add(coach);
    repositoryManager.removeTutors(owner, removeIdentities, re);

    // wait for the remove of subscription
    waitForCondition(
        new CheckUnsubscription(member, context, dbInstance, notificationManager), 5000);
    sleep(1000);

    // check that subscription of id1 was deleted but not the ones of id2 and coach
    boolean subscribedMember = notificationManager.isSubscribed(member, context);
    Assert.assertFalse(subscribedMember);
    boolean subscribedCoach = notificationManager.isSubscribed(coach, context);
    Assert.assertTrue(subscribedCoach);
    boolean subscribedOwner = notificationManager.isSubscribed(owner, context);
    Assert.assertTrue(subscribedOwner);
  }
コード例 #2
0
  @Test
  public void testRemoveParticipant() {
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
    // create a group with members
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("remp-proc-1");
    Identity member = JunitTestHelper.createAndPersistIdentityAsRndUser("remp-proc-2");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-3");

    repositoryEntryRelationDao.addRole(owner, re, GroupRoles.owner.name());
    repositoryEntryRelationDao.addRole(member, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(member, re, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(participant, re, GroupRoles.participant.name());

    // create a publisher
    SubscriptionContext context = new SubscriptionContext(re.getOlatResource(), "");
    PublisherData publisherData = new PublisherData("testGroupPublishers", "e.g. something", null);
    Publisher publisher = notificationManager.getOrCreatePublisher(context, publisherData);
    Assert.assertNotNull(publisher);
    dbInstance.commitAndCloseSession();

    // subscribe
    notificationManager.subscribe(owner, context, publisherData);
    notificationManager.subscribe(member, context, publisherData);
    notificationManager.subscribe(participant, context, publisherData);
    dbInstance.commitAndCloseSession();

    // remove member and participant as participant of the repo entry
    List<Identity> removeIdentities = new ArrayList<>(2);
    removeIdentities.add(member);
    removeIdentities.add(participant);
    MailPackage mailing = new MailPackage(false);
    repositoryManager.removeParticipants(owner, removeIdentities, re, mailing, false);

    // wait for the remove of subscription
    waitForCondition(
        new CheckUnsubscription(participant, context, dbInstance, notificationManager), 5000);
    sleep(1000);

    // check that subscription of id1 was deleted but not the ones of id2 and coach
    boolean subscribedPart = notificationManager.isSubscribed(participant, context);
    Assert.assertFalse(subscribedPart);
    boolean subscribedMember = notificationManager.isSubscribed(member, context);
    Assert.assertTrue(subscribedMember);
    boolean subscribedOwner = notificationManager.isSubscribed(owner, context);
    Assert.assertTrue(subscribedOwner);
  }
コード例 #3
0
  @Test
  public void deleteCourseSoftly() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("re-soft-");
    Identity coachGroup = JunitTestHelper.createAndPersistIdentityAsRndUser("re-soft-");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("re-soft-");
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("auth-del-1");
    RepositoryEntry re = JunitTestHelper.deployDemoCourse(initialAuthor);
    dbInstance.commitAndCloseSession();

    // add business group
    BusinessGroup group =
        businessGroupService.createBusinessGroup(
            coachGroup, "Relation 1", "tg", null, null, false, false, re);
    businessGroupService.addResourceTo(group, re);
    dbInstance.commit();

    // catalog
    List<CatalogEntry> rootEntries = catalogManager.getRootCatalogEntries();
    CatalogEntry catEntry = catalogManager.createCatalogEntry();
    catEntry.setName("Soft");
    catEntry.setRepositoryEntry(re);
    catEntry.setParent(rootEntries.get(0));
    catEntry.setOwnerGroup(securityManager.createAndPersistSecurityGroup());
    catalogManager.saveCatalogEntry(catEntry);
    dbInstance.commit();

    // check the catalog
    List<CatalogEntry> catEntries = catalogManager.getCatalogCategoriesFor(re);
    Assert.assertNotNull(catEntries);
    Assert.assertEquals(1, catEntries.size());

    // add owner, coach...
    repositoryEntryRelationDao.addRole(coach, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(participant, re, GroupRoles.participant.name());
    dbInstance.commit();

    // kill it softly like A. Keys
    repositoryService.deleteSoftly(re, initialAuthor, false);
    dbInstance.commit();

    // check that the members are removed
    List<Identity> coachAndParticipants =
        repositoryEntryRelationDao.getMembers(
            re,
            RepositoryEntryRelationType.both,
            GroupRoles.coach.name(),
            GroupRoles.participant.name());
    Assert.assertNotNull(coachAndParticipants);
    Assert.assertEquals(0, coachAndParticipants.size());

    // check the relations between course and business groups
    SearchBusinessGroupParams params = new SearchBusinessGroupParams();
    List<BusinessGroup> groups = businessGroupService.findBusinessGroups(params, re, 0, -1);
    Assert.assertNotNull(groups);
    Assert.assertEquals(0, groups.size());

    // check the catalog
    List<CatalogEntry> removedCatEntries = catalogManager.getCatalogCategoriesFor(re);
    Assert.assertNotNull(removedCatEntries);
    Assert.assertEquals(0, removedCatEntries.size());

    RepositoryEntry reloadEntry = repositoryService.loadByKey(re.getKey());
    Assert.assertNotNull(reloadEntry);
    Assert.assertEquals(0, reloadEntry.getAccess());
    Assert.assertNotNull(reloadEntry.getDeletionDate());
    Assert.assertEquals(initialAuthor, reloadEntry.getDeletedBy());
  }