use of teammates.ui.controller.InstructorFeedbackQuestionCopyAction in project teammates by TEAMMATES.
the class InstructorFeedbackQuestionCopyActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
______TS("Not enough parameters");
gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
verifyAssumptionFailure();
// This is commented out as InstructorFeedbackAddAction already assertNotNull using Assumption
// verifyAssumptionFailure(Const.ParamsNames.COURSE_ID, instructor1ofCourse1.courseId);
______TS("Typical case");
FeedbackSessionAttributes session1 = typicalBundle.feedbackSessions.get("session1InCourse1");
FeedbackQuestionAttributes question1 = FeedbackQuestionsLogic.inst().getFeedbackQuestion(session1.getFeedbackSessionName(), session1.getCourseId(), 1);
FeedbackQuestionAttributes question2 = FeedbackQuestionsLogic.inst().getFeedbackQuestion(session1.getFeedbackSessionName(), session1.getCourseId(), 2);
String[] params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "Second feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1", Const.ParamsNames.FEEDBACK_SESSION_NAME + "-0", question1.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID + "-0", question1.getCourseId(), Const.ParamsNames.FEEDBACK_QUESTION_ID + "-0", question1.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME + "-1", question2.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID + "-1", question2.getCourseId(), Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", question2.getId() };
InstructorFeedbackQuestionCopyAction a = getAction(params);
RedirectResult rr = getRedirectResult(a);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "Second+feedback+session", instructor1ofCourse1.googleId, false), rr.getDestinationWithParams());
String expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionCopy|||" + "instructorFeedbackQuestionCopy|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:" + "<span class=\"bold\">(Second feedback session)" + "</span> for Course <span class=\"bold\">[idOfTypicalCourse1]</span> " + "created.<br><span class=\"bold\">" + "Essay question:</span> What is the best selling point of your product?" + "Created Feedback Question for " + "Feedback Session:<span class=\"bold\">(Second feedback session)</span> " + "for Course <span class=\"bold\">" + "[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">Essay question:</span> Rate 1 other student's " + "product|||/page/instructorFeedbackQuestionCopy";
AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
______TS("Question text requires sanitization");
FeedbackSessionAttributes sanitizationSession = typicalBundle.feedbackSessions.get("session1InTestingSanitizationCourse");
question1 = FeedbackQuestionsLogic.inst().getFeedbackQuestion(sanitizationSession.getFeedbackSessionName(), sanitizationSession.getCourseId(), 1);
params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "Second feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1", Const.ParamsNames.FEEDBACK_QUESTION_ID + "-0", question1.getId() };
a = getAction(params);
rr = getRedirectResult(a);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "Second+feedback+session", instructor1ofCourse1.googleId, false), rr.getDestinationWithParams());
expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionCopy|||" + "instructorFeedbackQuestionCopy|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:" + "<span class=\"bold\">(Second feedback session)" + "</span> for Course <span class=\"bold\">[idOfTypicalCourse1]</span> " + "created.<br><span class=\"bold\">" + "Essay question:</span> " + "Testing quotation marks '" " + "Testing unclosed tags </td></div> " + "Testing script injection <script> alert('hello'); </script>" + "|||/page/instructorFeedbackQuestionCopy";
AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
______TS("Error: Indicate no questions to be copied");
params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "Second feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1" };
a = getAction(params);
rr = getRedirectResult(a);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "Second+feedback+session", instructor1ofCourse1.googleId, true), rr.getDestinationWithParams());
expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionCopy|||" + "instructorFeedbackQuestionCopy|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "|||/page/instructorFeedbackQuestionCopy";
AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
______TS("Masquerade mode");
FeedbackQuestionAttributes question3 = FeedbackQuestionsLogic.inst().getFeedbackQuestion(session1.getFeedbackSessionName(), session1.getCourseId(), 3);
String adminUserId = "admin.user";
gaeSimulation.loginAsAdmin(adminUserId);
params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "Second feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1", Const.ParamsNames.FEEDBACK_SESSION_NAME + "-0", question3.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID + "-0", question3.getCourseId(), Const.ParamsNames.FEEDBACK_QUESTION_ID + "-0", question3.getId() };
params = addUserIdToParams(instructor1ofCourse1.googleId, params);
a = getAction(params);
rr = getRedirectResult(a);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "Second+feedback+session", instructor1ofCourse1.googleId, false), rr.getDestinationWithParams());
expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionCopy|||" + "instructorFeedbackQuestionCopy|||true|||" + "Instructor(M)|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:" + "<span class=\"bold\">(Second feedback session)</span> " + "for Course <span class=\"bold\">[idOfTypicalCourse1]</span> " + "created.<br><span class=\"bold\">" + "Essay question:</span> My comments on the class|||" + "/page/instructorFeedbackQuestionCopy";
AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedLogMessage, a.getLogMessage(), adminUserId);
}
Aggregations