use of org.olat.group.model.LeaveOption in project openolat by klemens.
the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_withCourse.
@Test
public void allowToLeavingBusinessGroup_withCourse() {
// authors group
RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-5-");
BusinessGroup group = businessGroupService.createBusinessGroup(null, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, resource);
businessGroupRelationDao.addRole(participant, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
group = businessGroupService.updateAllowToLeaveBusinessGroup(group, false);
dbInstance.commitAndCloseSession();
// check the authors group leaving option
LeaveOption optionToLeave = businessGroupService.isAllowToLeaveBusinessGroup(participant, group);
Assert.assertNotNull(optionToLeave);
Assert.assertFalse(optionToLeave.isAllowToLeave());
ContactList contacts = optionToLeave.getContacts();
Collection<Identity> contactList = contacts.getIdentiEmails().values();
Assert.assertNotNull(contactList);
Assert.assertFalse(contactList.isEmpty());
for (Identity contact : contactList) {
Roles roles = securityManager.getRoles(contact);
Assert.assertNotNull(roles);
Assert.assertTrue(roles.isOLATAdmin());
}
}
use of org.olat.group.model.LeaveOption in project OpenOLAT by OpenOLAT.
the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_withCourse.
@Test
public void allowToLeavingBusinessGroup_withCourse() {
// authors group
RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-5-");
BusinessGroup group = businessGroupService.createBusinessGroup(null, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, resource);
businessGroupRelationDao.addRole(participant, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
group = businessGroupService.updateAllowToLeaveBusinessGroup(group, false);
dbInstance.commitAndCloseSession();
// check the authors group leaving option
LeaveOption optionToLeave = businessGroupService.isAllowToLeaveBusinessGroup(participant, group);
Assert.assertNotNull(optionToLeave);
Assert.assertFalse(optionToLeave.isAllowToLeave());
ContactList contacts = optionToLeave.getContacts();
Collection<Identity> contactList = contacts.getIdentiEmails().values();
Assert.assertNotNull(contactList);
Assert.assertFalse(contactList.isEmpty());
for (Identity contact : contactList) {
Roles roles = securityManager.getRoles(contact);
Assert.assertNotNull(roles);
Assert.assertTrue(roles.isOLATAdmin());
}
}
use of org.olat.group.model.LeaveOption in project OpenOLAT by OpenOLAT.
the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_overrideForbidden_notAllowForAuthorsAndLearnersGroups.
/**
* Override of allow is forbidden system-wide. If a group have the settings not "not allowed to leave",
* the setting must be ignored for learners group but not for authors group.
*/
@Test
public void allowToLeavingBusinessGroup_overrideForbidden_notAllowForAuthorsAndLearnersGroups() {
businessGroupModule.setAllowLeavingGroupOverride(false);
businessGroupModule.setAllowLeavingGroupCreatedByAuthors(false);
businessGroupModule.setAllowLeavingGroupCreatedByLearners(false);
// authors group
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("leave-auth-5-" + UUID.randomUUID().toString());
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-5-");
BusinessGroup authorsGroup = businessGroupService.createBusinessGroup(author, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, authorsGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
authorsGroup = businessGroupService.updateAllowToLeaveBusinessGroup(authorsGroup, false);
dbInstance.commitAndCloseSession();
// check the authors group leaving option
LeaveOption optionToLeaveAuthorsGroup = businessGroupService.isAllowToLeaveBusinessGroup(participant, authorsGroup);
Assert.assertNotNull(optionToLeaveAuthorsGroup);
Assert.assertFalse(optionToLeaveAuthorsGroup.isAllowToLeave());
// learners group
Identity learner = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-learn-5-" + UUID.randomUUID().toString());
BusinessGroup learnersGroup = businessGroupService.createBusinessGroup(learner, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, learnersGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
learnersGroup = businessGroupService.updateAllowToLeaveBusinessGroup(learnersGroup, false);
dbInstance.commitAndCloseSession();
// check the learners group leaving option
LeaveOption optionToLeaveLearnersGroup = businessGroupService.isAllowToLeaveBusinessGroup(participant, learnersGroup);
Assert.assertNotNull(optionToLeaveLearnersGroup);
Assert.assertFalse(optionToLeaveLearnersGroup.isAllowToLeave());
}
use of org.olat.group.model.LeaveOption in project OpenOLAT by OpenOLAT.
the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_overrideForbidden.
/**
* Override of allow is forbidden system-wide. If a group have the settings not "not allowed to leave",
* the setting must be ignored and the participants allowed to leave the group.
*/
@Test
public void allowToLeavingBusinessGroup_overrideForbidden() {
businessGroupModule.setAllowLeavingGroupOverride(false);
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("leave-auth-3-" + UUID.randomUUID().toString());
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-3-");
BusinessGroup group = businessGroupService.createBusinessGroup(author, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
group = businessGroupService.updateAllowToLeaveBusinessGroup(group, false);
dbInstance.commitAndCloseSession();
LeaveOption optionToLeave = businessGroupService.isAllowToLeaveBusinessGroup(participant, group);
Assert.assertNotNull(optionToLeave);
Assert.assertTrue(optionToLeave.isAllowToLeave());
}
use of org.olat.group.model.LeaveOption in project OpenOLAT by OpenOLAT.
the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_defaultSettings_groupOverride.
/**
* Test the default settings but the author set the business group to "leaving not allowed".
*/
@Test
public void allowToLeavingBusinessGroup_defaultSettings_groupOverride() {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("leave-auth-2-" + UUID.randomUUID().toString());
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-2-");
BusinessGroup group = businessGroupService.createBusinessGroup(author, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
businessGroupRelationDao.addRole(participant, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// set to not allowed to leave
group = businessGroupService.updateAllowToLeaveBusinessGroup(group, false);
dbInstance.commitAndCloseSession();
LeaveOption optionToLeave = businessGroupService.isAllowToLeaveBusinessGroup(participant, group);
Assert.assertNotNull(optionToLeave);
Assert.assertFalse(optionToLeave.isAllowToLeave());
ContactList contacts = optionToLeave.getContacts();
Assert.assertNotNull(contacts);
Collection<Identity> contactList = contacts.getIdentiEmails().values();
Assert.assertNotNull(contactList);
Assert.assertEquals(1, contactList.size());
Assert.assertTrue(contactList.contains(author));
}
Aggregations