Search in sources :

Example 6 with RedirectResult

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

the class StudentProfilePictureEditActionTest method testActionForEmptyHeight.

private void testActionForEmptyHeight(AccountAttributes student) {
    ______TS("Failure case: empty parameter - height");
    String expectedLogMessage = getExpectedLogMessageEmptyDimensions(student);
    String expectedUrl = getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, true, student.googleId);
    String[] submissionParams = createValidParamsForProfilePictureEdit();
    submissionParams[9] = "";
    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 7 with RedirectResult

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

the class StudentProfilePictureEditActionTest method testActionForZeroWidth.

private void testActionForZeroWidth(AccountAttributes student) {
    ______TS("Failure case: zero width");
    String expectedLogMessage = getExpectedLogMessageZeroDimensions(student);
    String expectedUrl = getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, true, student.googleId);
    String[] submissionParams = createValidParamsForProfilePictureEdit();
    submissionParams[11] = "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 8 with RedirectResult

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

the class StudentProfilePictureEditActionTest method testActionForEmptyBottomY.

private void testActionForEmptyBottomY(AccountAttributes student) {
    ______TS("Failure case: empty parameter - bottomy");
    String expectedLogMessage = getExpectedLogMessageEmptyCoords(student);
    String expectedUrl = getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, true, student.googleId);
    String[] submissionParams = createValidParamsForProfilePictureEdit();
    submissionParams[7] = "";
    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 9 with RedirectResult

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

the class StudentProfilePictureEditActionTest method testActionForEmptyWidth.

private void testActionForEmptyWidth(AccountAttributes student) {
    ______TS("Failure case: empty parameter - width");
    String expectedLogMessage = getExpectedLogMessageEmptyDimensions(student);
    String expectedUrl = getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, true, student.googleId);
    String[] submissionParams = createValidParamsForProfilePictureEdit();
    submissionParams[11] = "";
    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 10 with RedirectResult

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

the class InstructorFeedbackQuestionEditActionTest method testExecuteAndPostProcessNumScale.

@Test
public void testExecuteAndPostProcessNumScale() {
    DataBundle dataBundle = loadDataBundle("/FeedbackSessionQuestionTypeTest.json");
    removeAndRestoreDataBundle(dataBundle);
    InstructorAttributes instructor1ofCourse1 = dataBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
    FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("numscaleSession");
    FeedbackQuestionAttributes fq = FeedbackQuestionsLogic.inst().getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), 1);
    FeedbackNumericalScaleQuestionDetails numscaleDetails = (FeedbackNumericalScaleQuestionDetails) fq.getQuestionDetails();
    FeedbackResponsesDb frDb = new FeedbackResponsesDb();
    ______TS("Edit text");
    // There are already responses for this question
    assertFalse(frDb.getFeedbackResponsesForQuestion(fq.getId()).isEmpty());
    String[] editTextParams = { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, fq.giverType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, fq.recipientType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, Integer.toString(fq.questionNumber), Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "NUMSCALE", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, numscaleDetails.getQuestionText() + " (edited)", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MIN, Integer.toString(numscaleDetails.getMinScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MAX, Integer.toString(numscaleDetails.getMaxScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_STEP, StringHelper.toDecimalFormatString(numscaleDetails.getStep()), Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "max", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
    InstructorFeedbackQuestionEditAction a = getAction(editTextParams);
    RedirectResult r = getRedirectResult(a);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, "FSQTT.idOfTypicalCourse1", "NUMSCALE+Session", "FSQTT.idOfInstructor1OfCourse1", false), r.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_EDITED, r.getStatusMessage());
    assertFalse(r.isError);
    // All existing response should remain
    assertFalse(frDb.getFeedbackResponsesForQuestion(fq.getId()).isEmpty());
    ______TS("Edit scales");
    String[] editScalesParams = { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, fq.giverType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, fq.recipientType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, Integer.toString(fq.questionNumber), Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "NUMSCALE", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, numscaleDetails.getQuestionText() + " (edited)", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MIN, Integer.toString(1), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MAX, Integer.toString(10), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_STEP, StringHelper.toDecimalFormatString(1.0), Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "max", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
    a = getAction(editScalesParams);
    r = getRedirectResult(a);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, "FSQTT.idOfTypicalCourse1", "NUMSCALE+Session", "FSQTT.idOfInstructor1OfCourse1", false), r.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_EDITED, r.getStatusMessage());
    assertFalse(r.isError);
    // All existing response should be deleted as the scales are edited
    assertTrue(frDb.getFeedbackResponsesForQuestion(fq.getId()).isEmpty());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackQuestionEditAction(teammates.ui.controller.InstructorFeedbackQuestionEditAction) DataBundle(teammates.common.datatransfer.DataBundle) RedirectResult(teammates.ui.controller.RedirectResult) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackResponsesDb(teammates.storage.api.FeedbackResponsesDb) FeedbackNumericalScaleQuestionDetails(teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

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