Search in sources :

Example 41 with RedirectResult

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

the class StudentProfilePictureEditActionTest method testActionForEmptyLeftX.

private void testActionForEmptyLeftX(AccountAttributes student) {
    ______TS("Failure case: empty parameter - leftx");
    String expectedUrl = getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, true, student.googleId);
    String[] submissionParams = createValidParamsForProfilePictureEdit();
    submissionParams[1] = "";
    StudentProfilePictureEditAction action = getAction(submissionParams);
    RedirectResult result = getRedirectResult(action);
    String expectedLogMessage = getExpectedLogMessageEmptyCoords(student);
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    assertEquals(expectedUrl, result.getDestinationWithParams());
}
Also used : RedirectResult(teammates.ui.controller.RedirectResult) StudentProfilePictureEditAction(teammates.ui.controller.StudentProfilePictureEditAction)

Example 42 with RedirectResult

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

the class StudentProfilePictureEditActionTest method testActionForZeroHeight.

private void testActionForZeroHeight(AccountAttributes student) {
    ______TS("Failure case: zero height");
    String expectedLogMessage = getExpectedLogMessageZeroDimensions(student);
    String expectedUrl = getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, true, student.googleId);
    String[] submissionParams = createValidParamsForProfilePictureEdit();
    submissionParams[9] = "0";
    StudentProfilePictureEditAction action = getAction(submissionParams);
    RedirectResult result = getRedirectResult(action);
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    assertEquals(expectedUrl, result.getDestinationWithParams());
}
Also used : RedirectResult(teammates.ui.controller.RedirectResult) StudentProfilePictureEditAction(teammates.ui.controller.StudentProfilePictureEditAction)

Example 43 with RedirectResult

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

the class StudentProfilePictureEditActionTest method testActionForEmptyRightY.

private void testActionForEmptyRightY(AccountAttributes student) {
    String[] submissionParams;
    ______TS("Failure case: empty parameter - rightx");
    String expectedLogMessage = getExpectedLogMessageEmptyCoords(student);
    String expectedUrl = getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, true, student.googleId);
    submissionParams = createValidParamsForProfilePictureEdit();
    submissionParams[3] = "";
    StudentProfilePictureEditAction action = getAction(submissionParams);
    RedirectResult result = getRedirectResult(action);
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    assertEquals(expectedUrl, result.getDestinationWithParams());
}
Also used : RedirectResult(teammates.ui.controller.RedirectResult) StudentProfilePictureEditAction(teammates.ui.controller.StudentProfilePictureEditAction)

Example 44 with RedirectResult

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

the class InstructorEditInstructorFeedbackSaveActionTest method testModifyResponses.

private void testModifyResponses() {
    FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
    FeedbackQuestionAttributes fq = fqDb.getFeedbackQuestion("First feedback session", "IEIFPTCourse", 1);
    assertNotNull("Feedback question not found in database", fq);
    FeedbackResponsesDb frDb = new FeedbackResponsesDb();
    FeedbackResponseAttributes fr = dataBundle.feedbackResponses.get("response1ForQ1");
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    InstructorAttributes instructor = dataBundle.instructors.get("IEIFPTCourseinstr");
    InstructorEditInstructorFeedbackSaveAction editInstructorFsAction;
    RedirectResult redirectResult;
    String moderatedInstructorEmail = "IEIFPTCoursehelper1@gmail.tmt";
    String[] submissionParams;
    gaeSimulation.loginAsInstructor(instructor.googleId);
    ______TS("edit existing answer");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-1-0", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-1-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "Edited" + fr.getResponseDetails().getAnswerString(), Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
    editInstructorFsAction = getAction(submissionParams);
    redirectResult = getRedirectResult(editInstructorFsAction);
    assertFalse(redirectResult.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, redirectResult.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_EDIT_INSTRUCTOR_FEEDBACK_PAGE, false, "IEIFPTCoursehelper1%40gmail.tmt", "IEIFPTCourseinstr", "IEIFPTCourse", "First+feedback+session"), redirectResult.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    // submission confirmation email not sent if parameter does not exist
    verifyNoEmailsSent(editInstructorFsAction);
    ______TS("deleted response");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-1-0", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-1-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "", Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail, Const.ParamsNames.SEND_SUBMISSION_EMAIL, "on" };
    editInstructorFsAction = getAction(submissionParams);
    redirectResult = getRedirectResult(editInstructorFsAction);
    assertFalse(redirectResult.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, redirectResult.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_EDIT_INSTRUCTOR_FEEDBACK_PAGE, false, "IEIFPTCoursehelper1%40gmail.tmt", "IEIFPTCourseinstr", "IEIFPTCourse", "First+feedback+session"), redirectResult.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    // submission confirmation email still not sent even if parameter is "on" because this is moderation
    verifyNoEmailsSent(editInstructorFsAction);
    // delete respondent task scheduled
    verifySpecifiedTasksAdded(editInstructorFsAction, Const.TaskQueue.FEEDBACK_SESSION_UPDATE_RESPONDENT_QUEUE_NAME, 1);
    ______TS("skipped question");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-1-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "", Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
    editInstructorFsAction = getAction(submissionParams);
    redirectResult = getRedirectResult(editInstructorFsAction);
    assertFalse(redirectResult.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, redirectResult.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_EDIT_INSTRUCTOR_FEEDBACK_PAGE, false, "IEIFPTCoursehelper1%40gmail.tmt", "IEIFPTCourseinstr", "IEIFPTCourse", "First+feedback+session"), redirectResult.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("new response");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-1-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "New " + fr.getResponseDetails().getAnswerString(), Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
    editInstructorFsAction = getAction(submissionParams);
    redirectResult = getRedirectResult(editInstructorFsAction);
    assertFalse(redirectResult.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, redirectResult.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_EDIT_INSTRUCTOR_FEEDBACK_PAGE, false, "IEIFPTCoursehelper1%40gmail.tmt", "IEIFPTCourseinstr", "IEIFPTCourse", "First+feedback+session"), redirectResult.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    // append respondent task scheduled
    verifySpecifiedTasksAdded(editInstructorFsAction, Const.TaskQueue.FEEDBACK_SESSION_UPDATE_RESPONDENT_QUEUE_NAME, 1);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) RedirectResult(teammates.ui.controller.RedirectResult) InstructorEditInstructorFeedbackSaveAction(teammates.ui.controller.InstructorEditInstructorFeedbackSaveAction) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackResponsesDb(teammates.storage.api.FeedbackResponsesDb) FeedbackQuestionsDb(teammates.storage.api.FeedbackQuestionsDb) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 45 with RedirectResult

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

the class InstructorEditInstructorFeedbackSaveActionTest method testClosedSession.

private void testClosedSession() {
    FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
    FeedbackQuestionAttributes fq = fqDb.getFeedbackQuestion("Closed feedback session", "IEIFPTCourse", 1);
    assertNotNull("Feedback question not found in database", fq);
    FeedbackResponsesDb frDb = new FeedbackResponsesDb();
    FeedbackResponseAttributes fr = dataBundle.feedbackResponses.get("response1ForQ1InClosedSession");
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    InstructorAttributes instructor = dataBundle.instructors.get("IEIFPTCourseinstr");
    InstructorEditInstructorFeedbackSaveAction editInstructorFsAction;
    RedirectResult redirectResult;
    String moderatedInstructorEmail = "IEIFPTCourseintr@gmail.tmt";
    String[] submissionParams;
    gaeSimulation.loginAsInstructor(instructor.googleId);
    ______TS("Success case: modifying responses in closed session");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-1-0", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-1-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "Edited" + fr.getResponseDetails().getAnswerString(), Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
    editInstructorFsAction = getAction(submissionParams);
    redirectResult = getRedirectResult(editInstructorFsAction);
    assertFalse(redirectResult.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, redirectResult.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_EDIT_INSTRUCTOR_FEEDBACK_PAGE, false, "IEIFPTCourseintr%40gmail.tmt", "IEIFPTCourseinstr", "IEIFPTCourse", "Closed+feedback+session"), redirectResult.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) RedirectResult(teammates.ui.controller.RedirectResult) InstructorEditInstructorFeedbackSaveAction(teammates.ui.controller.InstructorEditInstructorFeedbackSaveAction) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackResponsesDb(teammates.storage.api.FeedbackResponsesDb) FeedbackQuestionsDb(teammates.storage.api.FeedbackQuestionsDb) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Aggregations

RedirectResult (teammates.ui.controller.RedirectResult)68 Test (org.testng.annotations.Test)49 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)46 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)27 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)17 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)15 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)12 NullPostParameterException (teammates.common.exception.NullPostParameterException)10 ShowPageResult (teammates.ui.controller.ShowPageResult)10 DataBundle (teammates.common.datatransfer.DataBundle)9 StudentProfilePictureEditAction (teammates.ui.controller.StudentProfilePictureEditAction)9 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)8 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)8 InstructorFeedbackQuestionAddAction (teammates.ui.controller.InstructorFeedbackQuestionAddAction)8 InstructorFeedbackQuestionEditAction (teammates.ui.controller.InstructorFeedbackQuestionEditAction)8 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)5 FeedbackSessionsDb (teammates.storage.api.FeedbackSessionsDb)5 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)4 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)4 TaskWrapper (teammates.common.util.TaskWrapper)4