Search in sources :

Example 1 with InstructorFeedbackCopyAction

use of teammates.ui.controller.InstructorFeedbackCopyAction in project teammates by TEAMMATES.

the class InstructorFeedbackCopyActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    // TODO: find a way to test status message from session
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    String expectedString = "";
    String teammatesLogMessage = "TEAMMATESLOG|||instructorFeedbackCopy|||instructorFeedbackCopy|||true|||Instructor|||" + "Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||instr1@course1.tmt|||";
    ______TS("Not enough parameters");
    gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
    verifyAssumptionFailure();
    // TODO make sure IFAA does assertNotNull for required parameters then uncomment
    // verifyAssumptionFailure(Const.ParamsNames.COURSE_ID, instructor1ofCourse1.courseId);
    ______TS("Typical case");
    String[] params = new String[] { Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "Copied Session", Const.ParamsNames.COPIED_COURSE_ID, "idOfTypicalCourse1", Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1" };
    InstructorFeedbackCopyAction a = getAction(params);
    RedirectResult rr = getRedirectResult(a);
    expectedString = getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "Copied+Session", instructor1ofCourse1.googleId, false);
    assertEquals(expectedString, rr.getDestinationWithParams());
    expectedString = "TEAMMATESLOG|||instructorFeedbackCopy|||instructorFeedbackCopy|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||New Feedback Session " + "<span class=\"bold\">(Copied Session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-04-01T21:59:00Z" + "<span class=\"bold\"> to</span> 2027-04-30T21:59:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 2012-03-28T21:59:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 2027-05-01T21:59:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: Please please fill in the following questions.>|||/page/instructorFeedbackCopy";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("Error: Trying to copy with existing feedback session name");
    params = new String[] { Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "Second feedback session", Const.ParamsNames.COPIED_COURSE_ID, "idOfTypicalCourse1", Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1" };
    a = getAction(params);
    RedirectResult pageResult = getRedirectResult(a);
    assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withParam(Const.ParamsNames.ERROR, Boolean.TRUE.toString()).withParam(Const.ParamsNames.USER_ID, instructor1ofCourse1.googleId).toString(), pageResult.getDestinationWithParams());
    assertTrue(pageResult.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_EXISTS, pageResult.getStatusMessage());
    expectedString = "TEAMMATESLOG|||instructorFeedbackCopy|||instructorFeedbackCopy|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Servlet Action Failure : Trying to create a Feedback Session that exists: " + "Second feedback session/idOfTypicalCourse1|||" + "/page/instructorFeedbackCopy";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("Error: Trying to copy with invalid feedback session name");
    params = new String[] { Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "", Const.ParamsNames.COPIED_COURSE_ID, "idOfTypicalCourse1", Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1" };
    a = getAction(params);
    pageResult = getRedirectResult(a);
    assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withParam(Const.ParamsNames.ERROR, Boolean.TRUE.toString()).withParam(Const.ParamsNames.USER_ID, instructor1ofCourse1.googleId).toString(), pageResult.getDestinationWithParams());
    assertTrue(pageResult.isError);
    assertEquals(getPopulatedEmptyStringErrorMessage(FieldValidator.SIZE_CAPPED_NON_EMPTY_STRING_ERROR_MESSAGE_EMPTY_STRING, FieldValidator.FEEDBACK_SESSION_NAME_FIELD_NAME, FieldValidator.FEEDBACK_SESSION_NAME_MAX_LENGTH), pageResult.getStatusMessage());
    expectedString = teammatesLogMessage + "Servlet Action Failure : " + "The field 'feedback session name' is empty. " + "The value of a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.|||/page/instructorFeedbackCopy";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("Masquerade mode");
    String adminUserId = "admin.user";
    gaeSimulation.loginAsAdmin(adminUserId);
    params = new String[] { Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "Second copied feedback session", Const.ParamsNames.COPIED_COURSE_ID, "idOfTypicalCourse1", Const.ParamsNames.FEEDBACK_SESSION_NAME, "Second feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1" };
    params = addUserIdToParams(instructor1ofCourse1.googleId, params);
    a = getAction(params);
    rr = getRedirectResult(a);
    expectedString = getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "Second+copied+feedback+session", instructor1ofCourse1.googleId, false);
    assertEquals(expectedString, rr.getDestinationWithParams());
    expectedString = "TEAMMATESLOG|||instructorFeedbackCopy|||instructorFeedbackCopy|||true|||" + "Instructor(M)|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||New Feedback Session " + "<span class=\"bold\">(Second copied feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2013-06-01T21:59:00Z" + "<span class=\"bold\"> to</span> 2026-04-28T21:59:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 2013-03-20T21:59:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 2026-04-29T21:59:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: Please please fill in the following questions.>|||/page/instructorFeedbackCopy";
    AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedString, a.getLogMessage(), adminUserId);
}
Also used : RedirectResult(teammates.ui.controller.RedirectResult) InstructorFeedbackCopyAction(teammates.ui.controller.InstructorFeedbackCopyAction) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)1 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)1 InstructorFeedbackCopyAction (teammates.ui.controller.InstructorFeedbackCopyAction)1 RedirectResult (teammates.ui.controller.RedirectResult)1