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());
}
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());
}
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());
}
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));
}
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));
}
Aggregations