/** Same workflow as the repository. This workflow is pretty critical. */ @Test public void isStructuredMapOwner() { final OLATResource resource = epStructureManager.createPortfolioMapTemplateResource(); // create a repository entry final RepositoryEntry addedEntry = repositoryManager.createRepositoryEntryInstance(ident1.getName()); addedEntry.setCanDownload(false); addedEntry.setCanLaunch(true); addedEntry.setDisplayname("test repo"); addedEntry.setResourcename("-"); addedEntry.setAccess(RepositoryEntry.ACC_OWNERS); // Set the resource on the repository entry and save the entry. final OLATResource ores = resourceManager.findOrPersistResourceable(resource); addedEntry.setOlatResource(ores); // create security group final SecurityGroup newGroup = securityManager.createAndPersistSecurityGroup(); securityManager.createAndPersistPolicy(newGroup, Constants.PERMISSION_ACCESS, newGroup); securityManager.createAndPersistPolicy( newGroup, Constants.PERMISSION_HASROLE, EPStructureManager.ORES_MAPOWNER); securityManager.addIdentityToSecurityGroup(ident1, newGroup); addedEntry.setOwnerGroup(newGroup); repositoryManager.saveRepositoryEntry(addedEntry); dbInstance.commitAndCloseSession(); // create the template owned by ident1 final PortfolioStructureMap template = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(ident1, addedEntry); final PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(template, "Page title", "Page description"); assertNotNull(page1); dbInstance.commitAndCloseSession(); // assign the template to ident2 final PortfolioStructureMap map = epFrontendManager.assignStructuredMapToUser(ident2, template, null, null, null, null); assertNotNull(map); dbInstance.commitAndCloseSession(); // check if ident2 is owner of the map assertTrue(epFrontendManager.isMapOwner(ident2, map.getOlatResource())); // check if ident1 is not the owner of the map assertFalse(epFrontendManager.isMapOwner(ident1, map.getOlatResource())); // check if ident1 is owner of the template assertTrue(epFrontendManager.isMapOwner(ident1, template.getOlatResource())); }