Package org.olat.course.run.userview

Examples of org.olat.course.run.userview.UserCourseEnvironment


    OLATResourceable ores = OresHelper.createOLATResourceableTypeWithoutCheck("TestCourse");
    CourseEnvironment cenv = CourseFactory.createEmptyCourse(ores, "Test", "Test", "learningObjectives").getCourseEnvironment();
    // 1. enroll wg1 user
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(wg1);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, cenv);
    CoursePropertyManager coursePropertyManager = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    enrollmentManager.doEnroll(wg1,bgWithWaitingList, enNode, coursePropertyManager,this /*WindowControl mock*/,testTranslator,
        new ArrayList()/*enrollableGroupNames*/, new ArrayList()/*enrollableAreaNames*/, userCourseEnv.getCourseEnvironment().getCourseGroupManager())
    assertTrue("Enrollment failed, user='wg1'", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg1,bgWithWaitingList))
    int participantsCounter = ManagerFactory.getManager().countIdentitiesOfSecurityGroup(bgWithWaitingList.getPartipiciantGroup());
    assertTrue("Wrong number of participants," + participantsCounter , participantsCounter == 1);
    // 2. enroll wg2 user
    ienv = new IdentityEnvironment();
    ienv.setIdentity(wg2);
    userCourseEnv = new UserCourseEnvironmentImpl(ienv, cenv);
    coursePropertyManager = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    enrollmentManager.doEnroll(wg2,bgWithWaitingList, enNode, coursePropertyManager,this /*WindowControl mock*/,testTranslator,
        new ArrayList()/*enrollableGroupNames*/, new ArrayList()/*enrollableAreaNames*/, userCourseEnv.getCourseEnvironment().getCourseGroupManager())
    assertTrue("Enrollment failed, user='wg2'", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg2,bgWithWaitingList))
    assertTrue("Enrollment failed, user='wg1'", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg1,bgWithWaitingList))
    participantsCounter = ManagerFactory.getManager().countIdentitiesOfSecurityGroup(bgWithWaitingList.getPartipiciantGroup());
    assertTrue("Wrong number of participants," + participantsCounter , participantsCounter == 2);
    // 3. enroll wg3 user => list is full => waiting-list
    ienv = new IdentityEnvironment();
    ienv.setIdentity(wg3);
    userCourseEnv = new UserCourseEnvironmentImpl(ienv, cenv);
    coursePropertyManager = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    enrollmentManager.doEnroll(wg3,bgWithWaitingList, enNode, coursePropertyManager,this /*WindowControl mock*/,testTranslator,
        new ArrayList()/*enrollableGroupNames*/, new ArrayList()/*enrollableAreaNames*/, userCourseEnv.getCourseEnvironment().getCourseGroupManager());   
    assertFalse("Wrong enrollment, user='wg3' is in PartipiciantGroup, must be on waiting-list", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg3,bgWithWaitingList))
    assertFalse("Wrong enrollment, user='wg3' is in PartipiciantGroup, must be on waiting-list", ManagerFactory.getManager().isIdentityInSecurityGroup(wg3, bgWithWaitingList.getPartipiciantGroup()));
    assertTrue("Wrong enrollment, user='wg3' must be on waiting-list", ManagerFactory.getManager().isIdentityInSecurityGroup(wg3, bgWithWaitingList.getWaitingGroup()));
    assertTrue("Enrollment failed, user='wg2'", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg2,bgWithWaitingList))
    assertTrue("Enrollment failed, user='wg1'", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg1,bgWithWaitingList))
    participantsCounter = ManagerFactory.getManager().countIdentitiesOfSecurityGroup(bgWithWaitingList.getPartipiciantGroup());
    assertTrue("Wrong number of participants," + participantsCounter , participantsCounter == 2);
    int waitingListCounter = ManagerFactory.getManager().countIdentitiesOfSecurityGroup(bgWithWaitingList.getWaitingGroup());
    assertTrue("Wrong number of waiting-list, must be 1, is " + waitingListCounter , waitingListCounter == 1);
    // cancel enrollment for wg2 => transfer wg3 from waiting-list to participants
    ienv = new IdentityEnvironment();
    ienv.setIdentity(wg2);
    userCourseEnv = new UserCourseEnvironmentImpl(ienv, cenv);
    coursePropertyManager = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    enrollmentManager.doCancelEnrollment(wg2,bgWithWaitingList, enNode, coursePropertyManager,this /*WindowControl mock*/,testTranslator);   
    assertFalse("Cancel enrollment failed, user='wg2' is still participants.", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg2,bgWithWaitingList))
    assertTrue("Enrollment failed, user='wg3'", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg3,bgWithWaitingList))
    assertTrue("Enrollment failed, user='wg1'", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg1,bgWithWaitingList))
    participantsCounter = ManagerFactory.getManager().countIdentitiesOfSecurityGroup(bgWithWaitingList.getPartipiciantGroup());
    assertTrue("Wrong number of participants, must be 2, is " + participantsCounter , participantsCounter == 2);
    waitingListCounter = ManagerFactory.getManager().countIdentitiesOfSecurityGroup(bgWithWaitingList.getWaitingGroup());
    assertTrue("Wrong number of waiting-list, must be 0, is " + waitingListCounter , waitingListCounter == 0);
    // cancel enrollment for wg1
    ienv = new IdentityEnvironment();
    ienv.setIdentity(wg1);
    userCourseEnv = new UserCourseEnvironmentImpl(ienv, cenv);
    coursePropertyManager = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    enrollmentManager.doCancelEnrollment(wg1,bgWithWaitingList, enNode, coursePropertyManager,this /*WindowControl mock*/,testTranslator);   
    assertFalse("Cancel enrollment failed, user='wg2' is still participants.", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg2,bgWithWaitingList))
    assertFalse("Cancel enrollment failed, user='wg1' is still participants.", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg1,bgWithWaitingList))
    assertTrue("Enrollment failed, user='wg3'", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg3,bgWithWaitingList))
    participantsCounter = ManagerFactory.getManager().countIdentitiesOfSecurityGroup(bgWithWaitingList.getPartipiciantGroup());
    assertTrue("Wrong number of participants, must be 1, is " + participantsCounter , participantsCounter == 1);
    waitingListCounter = ManagerFactory.getManager().countIdentitiesOfSecurityGroup(bgWithWaitingList.getWaitingGroup());
    assertTrue("Wrong number of waiting-list, must be 0, is " + waitingListCounter , waitingListCounter == 0);
    // cancel enrollment for wg3
    ienv = new IdentityEnvironment();
    ienv.setIdentity(wg3);
    userCourseEnv = new UserCourseEnvironmentImpl(ienv, cenv);
    coursePropertyManager = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    enrollmentManager.doCancelEnrollment(wg3,bgWithWaitingList, enNode, coursePropertyManager,this /*WindowControl mock*/,testTranslator);   
    assertFalse("Cancel enrollment failed, user='wg3' is still participants.", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg3,bgWithWaitingList))
    assertFalse("Cancel enrollment failed, user='wg2' is still participants.", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg2,bgWithWaitingList))
    assertFalse("Cancel enrollment failed, user='wg1' is still participants.", BusinessGroupManagerImpl.getInstance().isIdentityInBusinessGroup(wg1,bgWithWaitingList))
    participantsCounter = ManagerFactory.getManager().countIdentitiesOfSecurityGroup(bgWithWaitingList.getPartipiciantGroup());
View Full Code Here

TOP

Related Classes of org.olat.course.run.userview.UserCourseEnvironment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.