Search in sources :

Example 36 with Group

use of org.olat.basesecurity.Group in project openolat by klemens.

the class InvitationDAOTest method findInvitation_group.

@Test
public void findInvitation_group() {
    Invitation invitation = invitationDao.createAndPersistInvitation();
    Group baseGroup = invitation.getBaseGroup();
    Assert.assertNotNull(invitation);
    dbInstance.commitAndCloseSession();
    Invitation reloadedInvitation = invitationDao.findInvitation(baseGroup);
    Assert.assertNotNull(reloadedInvitation);
    Assert.assertNotNull(reloadedInvitation.getKey());
    Assert.assertEquals(baseGroup, reloadedInvitation.getBaseGroup());
    Assert.assertEquals(invitation, reloadedInvitation);
    Assert.assertEquals(invitation.getToken(), reloadedInvitation.getToken());
}
Also used : Group(org.olat.basesecurity.Group) Invitation(org.olat.basesecurity.Invitation) Test(org.junit.Test)

Example 37 with Group

use of org.olat.basesecurity.Group in project openolat by klemens.

the class InvitationDAOTest method loadOrCreateIdentityAndPersistInvitation.

@Test
public void loadOrCreateIdentityAndPersistInvitation() {
    Invitation invitation = invitationDao.createAndPersistInvitation();
    String uuid = UUID.randomUUID().toString().replace("-", "");
    invitation = invitationDao.update(invitation, "Flora", uuid, uuid + "@frentix.com");
    Group group = groupDao.createGroup();
    dbInstance.commit();
    // use the create part of the method
    Identity identity = invitationDao.loadOrCreateIdentityAndPersistInvitation(invitation, group, Locale.ENGLISH);
    Assert.assertNotNull(identity);
    Assert.assertNotNull(identity.getKey());
    dbInstance.commitAndCloseSession();
    // reload and check
    Identity reloadIdentity = securityManager.loadIdentityByKey(identity.getKey());
    Assert.assertNotNull(reloadIdentity);
    Assert.assertNotNull(reloadIdentity.getUser());
    Assert.assertEquals(identity.getKey(), reloadIdentity.getKey());
    Assert.assertEquals("Flora", reloadIdentity.getUser().getFirstName());
    Assert.assertEquals(uuid, reloadIdentity.getUser().getLastName());
    Assert.assertEquals(uuid + "@frentix.com", reloadIdentity.getUser().getEmail());
}
Also used : Group(org.olat.basesecurity.Group) Invitation(org.olat.basesecurity.Invitation) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 38 with Group

use of org.olat.basesecurity.Group in project openolat by klemens.

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());
}
Also used : BGRights(org.olat.group.right.BGRights) Group(org.olat.basesecurity.Group) BusinessGroup(org.olat.group.BusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 39 with Group

use of org.olat.basesecurity.Group in project openolat by klemens.

the class LectureBlockDAOTest method getParticipants_lectureBlock.

@Test
public void getParticipants_lectureBlock() {
    Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-3");
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-3");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-4");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    dbInstance.commit();
    // add teacher
    lectureService.addTeacher(lectureBlock, teacher);
    dbInstance.commit();
    // add participants
    repositoryEntryRelationDao.addRole(participant1, entry, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(participant2, entry, GroupRoles.participant.name());
    // add the course to the lectures
    Group defGroup = repositoryService.getDefaultGroup(entry);
    lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
    dbInstance.commitAndCloseSession();
    List<Identity> participants = lectureBlockDao.getParticipants(lectureBlock);
    Assert.assertNotNull(participants);
    Assert.assertEquals(2, participants.size());
    Assert.assertTrue(participants.contains(participant1));
    Assert.assertTrue(participants.contains(participant2));
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 40 with Group

use of org.olat.basesecurity.Group in project openolat by klemens.

the class LectureBlockDAOTest method getParticipants_repositoryEntryTeacher.

@Test
public void getParticipants_repositoryEntryTeacher() {
    Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-6");
    Identity coach1 = JunitTestHelper.createAndPersistIdentityAsRndUser("coach-2");
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-7");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-8");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    dbInstance.commit();
    // add teacher
    lectureService.addTeacher(lectureBlock, teacher);
    // add a participant to the course itself as noise
    repositoryEntryRelationDao.addRole(coach1, entry, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(participant1, entry, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(participant2, entry, GroupRoles.participant.name());
    // add the course to the lectures
    Group defGroup = repositoryService.getDefaultGroup(entry);
    lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
    dbInstance.commitAndCloseSession();
    List<Identity> participants = lectureBlockDao.getParticipants(entry, teacher);
    Assert.assertNotNull(participants);
    Assert.assertEquals(2, participants.size());
    Assert.assertTrue(participants.contains(participant1));
    Assert.assertTrue(participants.contains(participant2));
    Assert.assertFalse(participants.contains(coach1));
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

Group (org.olat.basesecurity.Group)170 Test (org.junit.Test)92 Identity (org.olat.core.id.Identity)80 BusinessGroup (org.olat.group.BusinessGroup)72 RepositoryEntry (org.olat.repository.RepositoryEntry)46 ArrayList (java.util.ArrayList)28 GroupMembership (org.olat.basesecurity.GroupMembership)26 LectureBlock (org.olat.modules.lecture.LectureBlock)26 OLATResource (org.olat.resource.OLATResource)26 LectureBlockToGroup (org.olat.modules.lecture.LectureBlockToGroup)20 Date (java.util.Date)16 SecurityGroup (org.olat.basesecurity.SecurityGroup)16 EPStructureElementToGroupRelation (org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)14 HashSet (java.util.HashSet)12 RepositoryEntryToGroupRelation (org.olat.repository.model.RepositoryEntryToGroupRelation)11 HashMap (java.util.HashMap)8 Grant (org.olat.basesecurity.Grant)8 Calendar (java.util.Calendar)6 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)6 BGRights (org.olat.group.right.BGRights)5