use of org.olat.group.right.BGRights in project OpenOLAT by OpenOLAT.
the class BGRightManagerTest method findBGRights_wrapped.
@Test
public void findBGRights_wrapped() {
// create
RepositoryEntry resource1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry resource2 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry resource3 = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "findRights", null, -1, -1, false, false, resource1);
businessGroupService.addResourceTo(group1, resource2);
BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "findRights", null, -1, -1, false, false, resource3);
rightManager.addBGRight("bgr.fr1", group1.getBaseGroup(), resource1.getOlatResource(), BGRightsRole.tutor);
rightManager.addBGRight("bgr.fr2", group1.getBaseGroup(), resource1.getOlatResource(), BGRightsRole.participant);
rightManager.addBGRight("bgr.fr3", group2.getBaseGroup(), resource1.getOlatResource(), BGRightsRole.tutor);
rightManager.addBGRight("bgr.fr4", group2.getBaseGroup(), resource2.getOlatResource(), BGRightsRole.tutor);
rightManager.addBGRight("bgr.fr5", group2.getBaseGroup(), resource3.getOlatResource(), BGRightsRole.participant);
dbInstance.commitAndCloseSession();
// check
List<BGRights> rights1_1 = rightManager.findBGRights(Collections.singletonList(group1.getBaseGroup()), resource1.getOlatResource());
Assert.assertNotNull(rights1_1);
Assert.assertEquals(2, rights1_1.size());
List<BGRights> rights2_2 = rightManager.findBGRights(Collections.singletonList(group2.getBaseGroup()), resource2.getOlatResource());
Assert.assertNotNull(rights2_2);
Assert.assertEquals(1, rights2_2.size());
List<BGRights> rights2_3 = rightManager.findBGRights(Collections.singletonList(group2.getBaseGroup()), resource3.getOlatResource());
Assert.assertNotNull(rights2_3);
Assert.assertEquals(1, rights2_3.size());
List<Group> groups = new ArrayList<>();
groups.add(group1.getBaseGroup());
groups.add(group2.getBaseGroup());
List<BGRights> rightsAll_1 = rightManager.findBGRights(groups, resource1.getOlatResource());
Assert.assertNotNull(rightsAll_1);
Assert.assertEquals(3, rightsAll_1.size());
}
Aggregations