Search in sources :

Example 31 with ShowPageResult

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

the class InstructorCoursesPageActionTest 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 instructorId = instructor1OfCourse1.googleId;
    String[] submissionParams = new String[] { Const.ParamsNames.IS_USING_AJAX, "true" };
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    /* Explanation: If the action is supposed to verify parameters,
         * we should check here the correctness of parameter verification.
         * e.g.

             ______TS("Invalid parameters");
            //both parameters missing.
            verifyAssumptionFailure(new String[] {});

            //null student email, only course ID is set
            String[] invalidParams = new String[] {
                    Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId
            };
            verifyAssumptionFailure(invalidParams);

         * In this action, there is no parameter verification.
         */
    ______TS("Typical case, 2 courses");
    if (CoursesLogic.inst().isCoursePresent("new-course")) {
        CoursesLogic.inst().deleteCourseCascade("new-course");
    }
    CoursesLogic.inst().createCourseAndInstructor(instructorId, "new-course", "New course", "UTC");
    gaeSimulation.loginAsInstructor(instructorId);
    InstructorCoursesPageAction a = getAction(submissionParams);
    ShowPageResult r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSES, false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals("", r.getStatusMessage());
    InstructorCoursesPageData pageData = (InstructorCoursesPageData) r.data;
    assertEquals(instructorId, pageData.account.googleId);
    assertEquals(2, pageData.getActiveCourses().getRows().size() + pageData.getArchivedCourses().getRows().size());
    assertEquals(0, pageData.getArchivedCourses().getRows().size());
    assertEquals("", pageData.getCourseIdToShow());
    assertEquals("", pageData.getCourseNameToShow());
    String expectedLogMessage = "TEAMMATESLOG|||instructorCoursesPage|||instructorCoursesPage" + "|||true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1" + "|||instr1@course1.tmt|||instructorCourse Page Load<br>Total courses: 2" + "|||/page/instructorCoursesPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("Masquerade mode, 0 courses");
    String adminUserId = "admin.user";
    gaeSimulation.loginAsAdmin(adminUserId);
    CoursesLogic.inst().deleteCourseCascade(instructor1ofCourse1.courseId);
    CoursesLogic.inst().deleteCourseCascade("new-course");
    a = getAction(addUserIdToParams(instructorId, submissionParams));
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSES, false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
    assertEquals("You have not created any courses yet. Use the form above to create a course.", r.getStatusMessage());
    assertFalse(r.isError);
    pageData = (InstructorCoursesPageData) r.data;
    assertEquals(instructorId, pageData.account.googleId);
    assertEquals(0, pageData.getArchivedCourses().getRows().size());
    assertEquals(0, pageData.getActiveCourses().getRows().size());
    assertEquals("", pageData.getCourseIdToShow());
    assertEquals("", pageData.getCourseNameToShow());
    expectedLogMessage = "TEAMMATESLOG|||instructorCoursesPage|||instructorCoursesPage" + "|||true|||Instructor(M)|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1" + "|||instr1@course1.tmt|||instructorCourse Page Load<br>Total courses: 0" + "|||/page/instructorCoursesPage";
    AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedLogMessage, a.getLogMessage(), adminUserId);
}
Also used : InstructorCoursesPageAction(teammates.ui.controller.InstructorCoursesPageAction) ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorCoursesPageData(teammates.ui.pagedata.InstructorCoursesPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 32 with ShowPageResult

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

the class InstructorEditInstructorFeedbackPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor = dataBundle.instructors.get("IEIFPTCourseinstr");
    InstructorAttributes moderatedInstructor = dataBundle.instructors.get("IEIFPTCoursehelper1");
    InstructorEditInstructorFeedbackPageAction editInstructorFpAction;
    ShowPageResult showPageResult;
    String courseId = moderatedInstructor.courseId;
    String feedbackSessionName = "";
    String moderatedInstructorEmail = "IEIFPTCoursehelper1@gmail.tmt";
    String[] submissionParams;
    gaeSimulation.loginAsInstructor(instructor.googleId);
    ______TS("typical success case");
    feedbackSessionName = "First feedback session";
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
    editInstructorFpAction = getAction(submissionParams);
    showPageResult = getShowPageResult(editInstructorFpAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), showPageResult.getDestinationWithParams());
    assertEquals("", showPageResult.getStatusMessage());
    AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorEditInstructorFeedbackPage|||instructorEditInstructorFeedbackPage" + "|||true|||Instructor|||IEIFPTCourseinstr|||IEIFPTCourseinstr|||IEIFPTCourseintr@course1.tmt|||" + "Moderating feedback session for instructor (" + moderatedInstructor.email + ")<br>" + "Session Name: First feedback session<br>Course ID: IEIFPTCourse|||" + "/page/instructorEditInstructorFeedbackPage", editInstructorFpAction.getLogMessage());
    ______TS("success: another feedback");
    feedbackSessionName = "Another feedback session";
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
    editInstructorFpAction = getAction(submissionParams);
    showPageResult = getShowPageResult(editInstructorFpAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), showPageResult.getDestinationWithParams());
    assertEquals("", showPageResult.getStatusMessage());
    String logMessage = "TEAMMATESLOG|||instructorEditInstructorFeedbackPage|||" + "instructorEditInstructorFeedbackPage|||true|||Instructor|||IEIFPTCourseinstr|||" + "IEIFPTCourseinstr|||IEIFPTCourseintr@course1.tmt|||" + "Moderating feedback session for instructor (" + moderatedInstructor.email + ")<br>" + "Session Name: Another feedback session<br>Course ID: IEIFPTCourse|||" + "/page/instructorEditInstructorFeedbackPage";
    AssertHelper.assertLogMessageEquals(logMessage, editInstructorFpAction.getLogMessage());
    ______TS("failure: accessing non-existent moderatedinstructor email");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    moderatedInstructorEmail = "non-exIstentEmail@gsail.tmt";
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
    try {
        editInstructorFpAction = getAction(submissionParams);
        editInstructorFpAction.executeAndPostProcess();
        signalFailureToDetectException();
    } catch (EntityNotFoundException enfe) {
        assertEquals("Instructor Email " + moderatedInstructorEmail + " does not exist in " + courseId + ".", enfe.getMessage());
    }
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorEditInstructorFeedbackPageAction(teammates.ui.controller.InstructorEditInstructorFeedbackPageAction) EntityNotFoundException(teammates.common.exception.EntityNotFoundException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 33 with ShowPageResult

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

the class InstructorEditStudentFeedbackPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor = dataBundle.instructors.get("IESFPTCourseinstr");
    InstructorAttributes instructorHelper = dataBundle.instructors.get("IESFPTCoursehelper1");
    String idOfInstructor = instructor.googleId;
    String idOfInstructorHelper = instructorHelper.googleId;
    StudentAttributes student = dataBundle.students.get("student1InCourse1");
    gaeSimulation.loginAsInstructor(idOfInstructor);
    ______TS("typical success case");
    String feedbackSessionName = "First feedback session";
    String courseId = student.course;
    String moderatedStudentEmail = student.email;
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
    InstructorEditStudentFeedbackPageAction editPageAction = getAction(submissionParams);
    ShowPageResult showPageResult = getShowPageResult(editPageAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, false, idOfInstructor), showPageResult.getDestinationWithParams());
    assertEquals("", showPageResult.getStatusMessage());
    AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorEditStudentFeedbackPage|||instructorEditStudentFeedbackPage|||true|||" + "Instructor|||IESFPTCourseinstr|||IESFPTCourseinstr|||IESFPTCourseintr@course1.tmt|||" + "Moderating feedback session for student (" + student.email + ")<br>" + "Session Name: First feedback session<br>Course ID: IESFPTCourse|||" + "/page/instructorEditStudentFeedbackPage", editPageAction.getLogMessage());
    ______TS("success: another feedback");
    feedbackSessionName = "Another feedback session";
    courseId = student.course;
    moderatedStudentEmail = student.email;
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
    editPageAction = getAction(submissionParams);
    showPageResult = getShowPageResult(editPageAction);
    ______TS("success case: closed session");
    feedbackSessionName = "Closed feedback session";
    courseId = student.course;
    moderatedStudentEmail = student.email;
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
    editPageAction = getAction(submissionParams);
    showPageResult = getShowPageResult(editPageAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, false, idOfInstructor), showPageResult.getDestinationWithParams());
    assertEquals("", showPageResult.getStatusMessage());
    gaeSimulation.loginAsInstructor(idOfInstructor);
    ______TS("success case: moderate team");
    feedbackSessionName = "Closed feedback session";
    courseId = student.course;
    String moderatedStudentTeam = student.team;
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentTeam };
    editPageAction = getAction(submissionParams);
    showPageResult = getShowPageResult(editPageAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, false, idOfInstructor), showPageResult.getDestinationWithParams());
    assertEquals("", showPageResult.getStatusMessage());
    AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorEditStudentFeedbackPage|||instructorEditStudentFeedbackPage|||true|||" + "Instructor|||IESFPTCourseinstr|||IESFPTCourseinstr|||IESFPTCourseintr@course1.tmt|||" + "Moderating feedback session for student (" + student.email + ")<br>" + "Session Name: Closed feedback session<br>Course ID: IESFPTCourse|||" + "/page/instructorEditStudentFeedbackPage", editPageAction.getLogMessage());
    gaeSimulation.loginAsInstructor(idOfInstructorHelper);
    ______TS("failure: does not have privilege");
    feedbackSessionName = "First feedback session";
    courseId = "IESFPTCourse";
    moderatedStudentEmail = student.email;
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
    try {
        editPageAction = getAction(submissionParams);
        showPageResult = getShowPageResult(editPageAction);
    } catch (UnauthorizedAccessException e) {
        assertEquals("Feedback session [First feedback session] is not accessible to instructor [" + instructorHelper.email + "] for privilege [" + Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS + "] on section [Section 1]", e.getMessage());
    }
    gaeSimulation.loginAsInstructor(idOfInstructor);
    ______TS("failure: non-existent moderatedstudent email");
    moderatedStudentEmail = "non-exIstentEmail@gsail.tmt";
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
    try {
        editPageAction = getAction(submissionParams);
        showPageResult = getShowPageResult(editPageAction);
        signalFailureToDetectException();
    } catch (EntityNotFoundException enfe) {
        assertEquals("An entity with the identifier " + moderatedStudentEmail + " does not exist in " + courseId + ".", enfe.getMessage());
    }
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) EntityNotFoundException(teammates.common.exception.EntityNotFoundException) InstructorEditStudentFeedbackPageAction(teammates.ui.controller.InstructorEditStudentFeedbackPageAction) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 34 with ShowPageResult

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

the class InstructorFeedbackAddActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    String expectedString = "";
    String teammatesLog = "TEAMMATESLOG|||instructorFeedbackAdd|||instructorFeedbackAdd|||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 = createParamsCombinationForFeedbackSession(instructor1ofCourse1.courseId, "ifaat tca fs", 0);
    InstructorFeedbackAddAction a = getAction(params);
    RedirectResult rr = getRedirectResult(a);
    expectedString = getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "ifaat+tca+fs", instructor1ofCourse1.googleId, false);
    assertEquals(expectedString, rr.getDestinationWithParams());
    expectedString = "TEAMMATESLOG|||instructorFeedbackAdd|||instructorFeedbackAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||New Feedback Session " + "<span class=\"bold\">(ifaat tca fs)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-01-31T16:00:00Z" + "<span class=\"bold\"> to</span> 2014-12-31T16:00:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 2011-12-31T16:00:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 1970-06-22T00:00:00Z<br>" + "<br><span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||/page/instructorFeedbackAdd";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_ADDED, rr.getStatusMessage());
    ______TS("Error: try to add the same session again");
    params = createParamsCombinationForFeedbackSession(instructor1ofCourse1.courseId, "ifaat tca fs", 0);
    a = getAction(params);
    ShowPageResult pr = getShowPageResult(a);
    expectedString = getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SESSIONS, true, "idOfInstructor1OfCourse1");
    assertEquals(expectedString, pr.getDestinationWithParams());
    assertTrue(pr.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_EXISTS, pr.getStatusMessage());
    ______TS("Error: Invalid parameters (fixed offset time zone and invalid session name, > 38 characters)");
    String longFsName = StringHelperExtension.generateStringOfLength(39);
    params = createParamsCombinationForFeedbackSession(instructor1ofCourse1.courseId, longFsName, 0);
    params[25] = "UTC+08:00";
    a = getAction(params);
    pr = getShowPageResult(a);
    expectedString = getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SESSIONS, true, "idOfInstructor1OfCourse1");
    assertEquals(expectedString, pr.getDestinationWithParams());
    assertTrue(pr.isError);
    expectedString = teammatesLog + "Servlet Action Failure : " + "\"" + longFsName + "\" " + "is not acceptable to TEAMMATES as a/an feedback session name because it is too long. " + "The value of a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.<br>" + "\"UTC+08:00\" is not acceptable to TEAMMATES as a/an time zone because it is not " + "available as a choice. The value must be one of the values from the time zone dropdown selector." + "|||/page/instructorFeedbackAdd";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("Error: Overlap publish time with invalid parameters (invalid session name, > 38 characters)");
    longFsName = StringHelperExtension.generateStringOfLength(39);
    params = createParamsCombinationForFeedbackSession(instructor1ofCourse1.courseId, longFsName, 1);
    params[25] = "Asia/Jerusalem";
    // After Sun, 25 Oct 2015, 01:59:59 AM: clocks fell back to Sun, 25 Oct 2015, 01:00:00 AM
    params[21] = "Sun, 25 Oct, 2015";
    params[23] = "1";
    a = getAction(params);
    pr = getShowPageResult(a);
    expectedString = getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SESSIONS, true, "idOfInstructor1OfCourse1");
    assertEquals(expectedString, pr.getDestinationWithParams());
    assertTrue(pr.isError);
    String overlapWarning = String.format(Const.StatusMessages.AMBIGUOUS_LOCAL_DATE_TIME_OVERLAP, "time when the results will be visible", "Sun, 25 Oct 2015, 01:00 AM", "Sun, 25 Oct 2015, 01:00 AM IDT (UTC+0300)", "Sun, 25 Oct 2015, 01:00 AM IST (UTC+0200)", "Sun, 25 Oct 2015, 01:00 AM IDT (UTC+0300)");
    String lengthError = "\"" + longFsName + "\" " + "is not acceptable to TEAMMATES as a/an feedback session name because it is too long. " + "The value of a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.";
    verifyStatusMessage(pr.getStatusToUser().get(0), overlapWarning, StatusMessageColor.WARNING);
    verifyStatusMessage(pr.getStatusToUser().get(1), lengthError, StatusMessageColor.DANGER);
    expectedString = teammatesLog + "Servlet Action Failure : " + lengthError + "|||/page/instructorFeedbackAdd";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("Add course with extra space (in middle and trailing)");
    params = createParamsCombinationForFeedbackSession(instructor1ofCourse1.courseId, "Course with extra  space ", 1);
    a = getAction(params);
    rr = getRedirectResult(a);
    expectedString = getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "Course+with+extra+space", instructor1ofCourse1.googleId, false);
    assertEquals(expectedString, rr.getDestinationWithParams());
    expectedString = "TEAMMATESLOG|||instructorFeedbackAdd|||instructorFeedbackAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||New Feedback Session " + "<span class=\"bold\">(Course with extra space)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-01-31T16:00:00Z" + "<span class=\"bold\"> to</span> 2014-12-31T16:00:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 1970-12-31T00:00:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 2014-05-07T18:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||/page/instructorFeedbackAdd";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_ADDED, rr.getStatusMessage());
    ______TS("DST time zone, gap end time");
    params = createParamsForTypicalFeedbackSession(instructor1ofCourse1.courseId, "Course with DST time zone");
    params[25] = "Asia/Jerusalem";
    // After Fri, 28 Mar 2014, 01:59:59 AM: clocks sprang forward to Fri, 28 Mar 2014, 03:00:00 AM
    params[9] = "Fri, 28 Mar, 2014";
    params[11] = "2";
    a = getAction(params);
    rr = getRedirectResult(a);
    expectedString = getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "Course+with+DST+time+zone", instructor1ofCourse1.googleId, false);
    assertEquals(expectedString, rr.getDestinationWithParams());
    expectedString = "TEAMMATESLOG|||instructorFeedbackAdd|||instructorFeedbackAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||New Feedback Session " + "<span class=\"bold\">(Course with DST time zone)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-01-31T22:00:00Z" + "<span class=\"bold\"> to</span> 2014-03-28T00:00:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 2011-12-31T22:00:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 1970-06-22T00:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||" + "/page/instructorFeedbackAdd";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    expectedString = String.format(Const.StatusMessages.AMBIGUOUS_LOCAL_DATE_TIME_GAP, "end time", "Fri, 28 Mar 2014, 02:00 AM", "Fri, 28 Mar 2014, 03:00 AM IDT (UTC+0300)") + "<br>" + Const.StatusMessages.FEEDBACK_SESSION_ADDED;
    assertEquals(expectedString, rr.getStatusMessage());
    ______TS("Masquerade mode");
    String adminUserId = "admin.user";
    gaeSimulation.loginAsAdmin(adminUserId);
    params = createParamsCombinationForFeedbackSession(instructor1ofCourse1.courseId, "masquerade session", 3);
    params = addUserIdToParams(instructor1ofCourse1.googleId, params);
    a = getAction(params);
    rr = getRedirectResult(a);
    expectedString = getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "masquerade+session", instructor1ofCourse1.googleId, false);
    assertEquals(expectedString, rr.getDestinationWithParams());
    expectedString = "TEAMMATESLOG|||instructorFeedbackAdd|||instructorFeedbackAdd|||true|||" + "Instructor(M)|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||New Feedback Session " + "<span class=\"bold\">(masquerade session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-01-31T16:00:00Z" + "<span class=\"bold\"> to</span> 2014-12-31T16:00:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 2011-12-31T16:00:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 1970-01-01T00:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: >|||/page/instructorFeedbackAdd";
    AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedString, a.getLogMessage(), adminUserId);
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_ADDED, rr.getStatusMessage());
    ______TS("Unsuccessful case: test null time zone parameter");
    params = ArrayUtils.remove(params, 26);
    params = ArrayUtils.remove(params, 26);
    try {
        a = getAction(params);
        getRedirectResult(a);
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.FEEDBACK_SESSION_TIMEZONE), e.getMessage());
    }
    ______TS("Unsuccessful case: test null course ID parameter");
    params = new String[] {};
    try {
        a = getAction(params);
        getRedirectResult(a);
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.COURSE_ID), e.getMessage());
    }
    // remove the sessions that were added
    FeedbackSessionsLogic.inst().deleteFeedbackSessionsForCourseCascade(instructor1ofCourse1.courseId);
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) NullPostParameterException(teammates.common.exception.NullPostParameterException) InstructorFeedbackAddAction(teammates.ui.controller.InstructorFeedbackAddAction) RedirectResult(teammates.ui.controller.RedirectResult) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 35 with ShowPageResult

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

the class InstructorFeedbackEditPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1OfCourse1.googleId);
    // declare all variables to be used
    String expectedString = "";
    FeedbackSessionAttributes feedbackSessionAttributes;
    String[] submissionParams;
    InstructorFeedbackEditPageAction instructorFeedbackEditPageAction;
    ShowPageResult showPageResult;
    ______TS("typical success case");
    feedbackSessionAttributes = typicalBundle.feedbackSessions.get("session1InCourse1");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackSessionAttributes.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionAttributes.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_SESSION_ENABLE_EDIT, "true" };
    instructorFeedbackEditPageAction = getAction(submissionParams);
    showPageResult = getShowPageResult(instructorFeedbackEditPageAction);
    expectedString = getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_EDIT, false, instructor1OfCourse1.googleId);
    assertEquals(expectedString, showPageResult.getDestinationWithParams());
    assertEquals("", showPageResult.getStatusMessage());
    expectedString = "TEAMMATESLOG|||instructorFeedbackEditPage|||instructorFeedbackEditPage|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||instructorFeedbackEdit " + "Page Load<br>Editing information for Feedback Session " + "<span class=\"bold\">[" + feedbackSessionAttributes.getFeedbackSessionName() + "]</span>" + "in Course: <span class=\"bold\">[idOfTypicalCourse1]</span>" + "|||/page/instructorFeedbackEditPage";
    AssertHelper.assertLogMessageEquals(expectedString, instructorFeedbackEditPageAction.getLogMessage());
    ______TS("failure 1: non-existent feedback session");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackSessionAttributes.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, "randomName for Session123", Const.ParamsNames.FEEDBACK_SESSION_ENABLE_EDIT, "true" };
    instructorFeedbackEditPageAction = getAction(submissionParams);
    try {
        showPageResult = getShowPageResult(instructorFeedbackEditPageAction);
        signalFailureToDetectException();
    } catch (UnauthorizedAccessException uae) {
        assertEquals("Trying to access system using a non-existent feedback session entity", uae.getMessage());
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ShowPageResult(teammates.ui.controller.ShowPageResult) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) InstructorFeedbackEditPageAction(teammates.ui.controller.InstructorFeedbackEditPageAction) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Aggregations

ShowPageResult (teammates.ui.controller.ShowPageResult)51 Test (org.testng.annotations.Test)42 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)31 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)15 RedirectResult (teammates.ui.controller.RedirectResult)10 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)8 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)8 EntityNotFoundException (teammates.common.exception.EntityNotFoundException)5 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)4 NullPostParameterException (teammates.common.exception.NullPostParameterException)4 ArrayList (java.util.ArrayList)3 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)3 AdminActivityLogPageAction (teammates.ui.controller.AdminActivityLogPageAction)3 AdminEmailLogPageAction (teammates.ui.controller.AdminEmailLogPageAction)3 AjaxResult (teammates.ui.controller.AjaxResult)3 InstructorCourseEnrollPageAction (teammates.ui.controller.InstructorCourseEnrollPageAction)3 InstructorCourseEnrollPageData (teammates.ui.pagedata.InstructorCourseEnrollPageData)3 Instant (java.time.Instant)2 AdminEmailAttributes (teammates.common.datatransfer.attributes.AdminEmailAttributes)2 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)2