@Test public void deleteCoursePermanently() { Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("auth-del-1"); RepositoryEntry re = JunitTestHelper.deployDemoCourse(initialAuthor); dbInstance.commitAndCloseSession(); Roles roles = new Roles(false, false, false, true, false, false, false); ErrorList errors = repositoryService.deletePermanently(re, initialAuthor, roles, Locale.ENGLISH); Assert.assertNotNull(errors); Assert.assertFalse(errors.hasErrors()); }
@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()); }