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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations