Search in sources :

Example 11 with AjaxResult

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

the class InstructorFeedbackEditCopyActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor = dataBundle.instructors.get("teammates.test.instructor2");
    String instructorId = instructor.googleId;
    FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("openSession");
    CourseAttributes course = dataBundle.courses.get("course");
    gaeSimulation.loginAsInstructor(instructorId);
    String expectedString = "";
    ______TS("Failure case: No parameters");
    verifyAssumptionFailure();
    ______TS("Failure case: Courses not passed in, instructor home page");
    String[] params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name" };
    InstructorFeedbackEditCopyAction a = getAction(params);
    AjaxResult ajaxResult = getAjaxResult(a);
    InstructorFeedbackEditCopyData editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_COPY_NONESELECTED, editCopyData.errorMessage);
    ______TS("Failure case: Courses not passed in, instructor feedbacks page");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name" };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_COPY_NONESELECTED, editCopyData.errorMessage);
    ______TS("Failure case: Courses not passed in, instructor feedback copy page");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name" };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_COPY_NONESELECTED, editCopyData.errorMessage);
    ______TS("Failure case: Courses not passed in, instructor feedback edit page");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name" };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_COPY_NONESELECTED, editCopyData.errorMessage);
    ______TS("Failure case: copying non-existing fs");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "non.existing.fs", Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name", Const.ParamsNames.COPIED_COURSES_ID, course.getId() };
    a = getAction(params);
    try {
        ajaxResult = getAjaxResult(a);
        signalFailureToDetectException();
    } catch (UnauthorizedAccessException uae) {
        assertEquals("Trying to access system using a non-existent feedback session entity", uae.getMessage());
    }
    ______TS("Failure case: copying to non-existing course");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name", Const.ParamsNames.COPIED_COURSES_ID, "non.existing.course" };
    a = getAction(params);
    try {
        ajaxResult = getAjaxResult(a);
        signalFailureToDetectException();
    } catch (UnauthorizedAccessException uae) {
        assertEquals("Trying to access system using a non-existent instructor entity", uae.getMessage());
    }
    ______TS("Failure case: course already has feedback session with same name, instructor home page");
    CourseAttributes course6 = dataBundle.courses.get("course6");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COPIED_COURSES_ID, course.getId(), Const.ParamsNames.COPIED_COURSES_ID, course6.getId() };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals("", editCopyData.redirectUrl);
    expectedString = "A feedback session with the name \"First Session\" already exists in " + "the following course(s): FeedbackEditCopy.CS2104.";
    assertEquals(expectedString, editCopyData.errorMessage);
    ______TS("Failure case: course already has feedback session with same name, instructor feedbacks page");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COPIED_COURSES_ID, course.getId(), Const.ParamsNames.COPIED_COURSES_ID, course6.getId() };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals("", editCopyData.redirectUrl);
    expectedString = "A feedback session with the name \"First Session\" already exists in " + "the following course(s): FeedbackEditCopy.CS2104.";
    assertEquals(expectedString, editCopyData.errorMessage);
    ______TS("Failure case: course already has feedback session with same name, instructor feedback copy page");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COPIED_COURSES_ID, course.getId(), Const.ParamsNames.COPIED_COURSES_ID, course6.getId() };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals("", editCopyData.redirectUrl);
    expectedString = "A feedback session with the name \"First Session\" already exists in " + "the following course(s): FeedbackEditCopy.CS2104.";
    assertEquals(expectedString, editCopyData.errorMessage);
    ______TS("Failure case: course already has feedback session with same name, instructor feedback edit page");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COPIED_COURSES_ID, course.getId(), Const.ParamsNames.COPIED_COURSES_ID, course6.getId() };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals("", editCopyData.redirectUrl);
    expectedString = "A feedback session with the name \"First Session\" already exists in " + "the following course(s): FeedbackEditCopy.CS2104.";
    assertEquals(expectedString, editCopyData.errorMessage);
    ______TS("Failure case: empty name, instructor home page");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "", Const.ParamsNames.COPIED_COURSES_ID, course.getId(), Const.ParamsNames.COPIED_COURSES_ID, course6.getId() };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals("", editCopyData.redirectUrl);
    expectedString = "The field 'feedback session name' is empty. " + "The value of a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.";
    assertEquals(expectedString, editCopyData.errorMessage);
    expectedString = "TEAMMATESLOG|||instructorFeedbackEditCopy|||instructorFeedbackEditCopy|||true|||" + "Instructor|||Instructor 2|||FeedbackEditCopyinstructor2|||tmms.instr@gmail.tmt|||" + "Servlet Action Failure : The field 'feedback session name' is empty. The value of " + "a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.|||/page/instructorFeedbackEditCopy";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("Failure case: empty name, instructor feedbacks page");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "", Const.ParamsNames.COPIED_COURSES_ID, course.getId(), Const.ParamsNames.COPIED_COURSES_ID, course6.getId() };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals("", editCopyData.redirectUrl);
    expectedString = "The field 'feedback session name' is empty. " + "The value of a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.";
    assertEquals(expectedString, editCopyData.errorMessage);
    expectedString = "TEAMMATESLOG|||instructorFeedbackEditCopy|||instructorFeedbackEditCopy|||true|||" + "Instructor|||Instructor 2|||FeedbackEditCopyinstructor2|||tmms.instr@gmail.tmt|||" + "Servlet Action Failure : The field 'feedback session name' is empty. The value of " + "a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.|||/page/instructorFeedbackEditCopy";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("Failure case: empty name, instructor feedback copy page");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "", Const.ParamsNames.COPIED_COURSES_ID, course.getId(), Const.ParamsNames.COPIED_COURSES_ID, course6.getId() };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals("", editCopyData.redirectUrl);
    expectedString = "The field 'feedback session name' is empty. " + "The value of a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.";
    assertEquals(expectedString, editCopyData.errorMessage);
    expectedString = "TEAMMATESLOG|||instructorFeedbackEditCopy|||instructorFeedbackEditCopy|||true|||" + "Instructor|||Instructor 2|||FeedbackEditCopyinstructor2|||tmms.instr@gmail.tmt|||" + "Servlet Action Failure : The field 'feedback session name' is empty. The value of " + "a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.|||/page/instructorFeedbackEditCopy";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("Failure case: empty name, instructor feedback edit page");
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "", Const.ParamsNames.COPIED_COURSES_ID, course.getId(), Const.ParamsNames.COPIED_COURSES_ID, course6.getId() };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    assertEquals("", editCopyData.redirectUrl);
    expectedString = "The field 'feedback session name' is empty. " + "The value of a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.";
    assertEquals(expectedString, editCopyData.errorMessage);
    expectedString = "TEAMMATESLOG|||instructorFeedbackEditCopy|||instructorFeedbackEditCopy|||true|||" + "Instructor|||Instructor 2|||FeedbackEditCopyinstructor2|||tmms.instr@gmail.tmt|||" + "Servlet Action Failure : The field 'feedback session name' is empty. The value of " + "a/an feedback session name should be no longer than 38 characters. " + "It should not be empty.|||/page/instructorFeedbackEditCopy";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("Successful case");
    CourseAttributes course7 = dataBundle.courses.get("course7");
    String copiedCourseName = "Session with valid name";
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First Session", Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, copiedCourseName, Const.ParamsNames.COPIED_COURSES_ID, course6.getId(), Const.ParamsNames.COPIED_COURSES_ID, course7.getId() };
    a = getAction(params);
    ajaxResult = getAjaxResult(a);
    editCopyData = (InstructorFeedbackEditCopyData) ajaxResult.data;
    expectedString = getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE, false, instructor.googleId);
    assertEquals(expectedString, editCopyData.redirectUrl);
    expectedString = "TEAMMATESLOG|||instructorFeedbackEditCopy|||instructorFeedbackEditCopy|||" + "true|||Instructor|||Instructor 2|||FeedbackEditCopyinstructor2|||" + "tmms.instr@gmail.tmt|||Copying to multiple feedback sessions.<br>" + "New Feedback Session <span class=\"bold\">(Session with valid name)</span> " + "for Courses: <br>FeedbackEditCopy.CS2103R,FeedbackEditCopy.CS2102<br>" + "<span class=\"bold\">From:</span> 2012-04-01T21:59:00Z<span class=\"bold\"> " + "to</span> 2026-04-30T21:59:00Z<br><span class=\"bold\">Session visible from:</span> " + "2012-04-01T21:59:00Z<br><span class=\"bold\">Results visible from:</span> " + "2026-05-01T21:59:00Z<br><br><span class=\"bold\">Instructions:</span> " + "<Text: Instructions for first session><br>Copied from " + "<span class=\"bold\">(First Session)</span> " + "for Course <span class=\"bold\">[FeedbackEditCopy.CS2104]</span> created.<br>|||" + "/page/instructorFeedbackEditCopy";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) AjaxResult(teammates.ui.controller.AjaxResult) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) InstructorFeedbackEditCopyData(teammates.ui.pagedata.InstructorFeedbackEditCopyData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorFeedbackEditCopyAction(teammates.ui.controller.InstructorFeedbackEditCopyAction) Test(org.testng.annotations.Test)

Example 12 with AjaxResult

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

the class InstructorFeedbackEditSaveActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1");
    String expectedString = "";
    ______TS("failure: Not enough parameters");
    gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
    verifyAssumptionFailure();
    // TODO make sure IFESA does assertNotNull for required parameters then uncomment
    // verifyAssumptionFailure(Const.ParamsNames.COURSE_ID, instructor1ofCourse1.courseId,
    // Const.ParamsNames.FEEDBACK_SESSION_NAME, session.feedbackSessionName);
    ______TS("success: Typical case");
    String[] params = createParamsForTypicalFeedbackSession(instructor1ofCourse1.courseId, session.getFeedbackSessionName());
    InstructorFeedbackEditSaveAction a = getAction(params);
    AjaxResult ar = getAjaxResult(a);
    InstructorFeedbackEditPageData pageData = (InstructorFeedbackEditPageData) ar.data;
    StatusMessage statusMessage = pageData.getStatusMessagesToUser().get(0);
    verifyStatusMessage(statusMessage, Const.StatusMessages.FEEDBACK_SESSION_EDITED, StatusMessageColor.SUCCESS);
    assertFalse(pageData.getHasError());
    expectedString = "TEAMMATESLOG|||instructorFeedbackEditSave|||instructorFeedbackEditSave|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Updated Feedback Session " + "<span class=\"bold\">(First feedback 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-06-22T00:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||/page/instructorFeedbackEditSave";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("failure: Fixed offset time zone");
    params[25] = "UTC+08:00";
    a = getAction(params);
    ar = getAjaxResult(a);
    pageData = (InstructorFeedbackEditPageData) ar.data;
    expectedString = "\"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.";
    statusMessage = pageData.getStatusMessagesToUser().get(0);
    verifyStatusMessage(statusMessage, expectedString, StatusMessageColor.DANGER);
    assertTrue(pageData.getHasError());
    ______TS("failure: Invalid parameters");
    params[15] = "Thu, 01 Mar, 2012";
    params[25] = "UTC";
    a = getAction(params);
    ar = getAjaxResult(a);
    pageData = (InstructorFeedbackEditPageData) ar.data;
    expectedString = "The start time for this feedback session cannot be " + "earlier than the time when the session will be visible.";
    statusMessage = pageData.getStatusMessagesToUser().get(0);
    verifyStatusMessage(statusMessage, expectedString, StatusMessageColor.DANGER);
    assertTrue(pageData.getHasError());
    ______TS("success: Time zone with DST, gap start time, overlap end time");
    params[25] = "Europe/Andorra";
    // After Sun, 25 Mar 2012, 01:59:59 AM: clocks sprang forward to Sun, 25 Mar 2012, 03:00:00 AM
    params[5] = "Sun, 25 Mar, 2012";
    params[7] = "2";
    // After Sun, 28 Oct 2012, 02:59:59 AM: clocks fell back to Sun, 28 Oct 2012, 02:00:00 AM
    params[9] = "Sun, 28 Oct, 2012";
    params[11] = "2";
    a = getAction(params);
    ar = getAjaxResult(a);
    pageData = (InstructorFeedbackEditPageData) ar.data;
    expectedString = String.format(Const.StatusMessages.AMBIGUOUS_LOCAL_DATE_TIME_GAP, "start time", "Sun, 25 Mar 2012, 02:00 AM", "Sun, 25 Mar 2012, 03:00 AM CEST (UTC+0200)");
    verifyStatusMessage(pageData.getStatusMessagesToUser().get(0), expectedString, StatusMessageColor.WARNING);
    expectedString = String.format(Const.StatusMessages.AMBIGUOUS_LOCAL_DATE_TIME_OVERLAP, "end time", "Sun, 28 Oct 2012, 02:00 AM", "Sun, 28 Oct 2012, 02:00 AM CEST (UTC+0200)", "Sun, 28 Oct 2012, 02:00 AM CET (UTC+0100)", "Sun, 28 Oct 2012, 02:00 AM CEST (UTC+0200)");
    verifyStatusMessage(pageData.getStatusMessagesToUser().get(1), expectedString, StatusMessageColor.WARNING);
    expectedString = Const.StatusMessages.FEEDBACK_SESSION_EDITED;
    verifyStatusMessage(pageData.getStatusMessagesToUser().get(2), expectedString, StatusMessageColor.SUCCESS);
    assertFalse(pageData.getHasError());
    ______TS("success: Custom time zone, 'never' show session, 'custom' show results");
    params = createParamsForTypicalFeedbackSession(instructor1ofCourse1.courseId, session.getFeedbackSessionName());
    params[25] = "Asia/Kathmandu";
    params[13] = Const.INSTRUCTOR_FEEDBACK_SESSION_VISIBLE_TIME_NEVER;
    params[19] = Const.INSTRUCTOR_FEEDBACK_RESULTS_VISIBLE_TIME_LATER;
    a = getAction(params);
    ar = getAjaxResult(a);
    pageData = (InstructorFeedbackEditPageData) ar.data;
    statusMessage = pageData.getStatusMessagesToUser().get(0);
    verifyStatusMessage(statusMessage, Const.StatusMessages.FEEDBACK_SESSION_EDITED, StatusMessageColor.SUCCESS);
    assertFalse(pageData.getHasError());
    expectedString = "TEAMMATESLOG|||instructorFeedbackEditSave|||instructorFeedbackEditSave|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Updated Feedback Session " + "<span class=\"bold\">(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-01-31T18:15:00Z" + "<span class=\"bold\"> to</span> 2014-12-31T18:15:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 1970-11-27T00:00:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 1970-01-01T00:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||/page/instructorFeedbackEditSave";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("success: At open session visible time, custom results visible time, UTC");
    params = createParamsCombinationForFeedbackSession(instructor1ofCourse1.courseId, session.getFeedbackSessionName(), 1);
    params[25] = "UTC";
    a = getAction(params);
    ar = getAjaxResult(a);
    pageData = (InstructorFeedbackEditPageData) ar.data;
    statusMessage = pageData.getStatusMessagesToUser().get(0);
    verifyStatusMessage(statusMessage, Const.StatusMessages.FEEDBACK_SESSION_EDITED, StatusMessageColor.SUCCESS);
    assertFalse(pageData.getHasError());
    expectedString = "TEAMMATESLOG|||instructorFeedbackEditSave|||instructorFeedbackEditSave|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Updated Feedback Session " + "<span class=\"bold\">(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-02-01T00:00:00Z" + "<span class=\"bold\"> to</span> 2015-01-01T00: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-08T02:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||/page/instructorFeedbackEditSave";
    AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
    ______TS("success: Masquerade mode, manual release results, UTC");
    String adminUserId = "admin.user";
    gaeSimulation.loginAsAdmin(adminUserId);
    params = createParamsForTypicalFeedbackSession(instructor1ofCourse1.courseId, session.getFeedbackSessionName());
    params[19] = Const.INSTRUCTOR_FEEDBACK_RESULTS_VISIBLE_TIME_LATER;
    params[25] = "UTC";
    params = addUserIdToParams(instructor1ofCourse1.googleId, params);
    a = getAction(params);
    ar = getAjaxResult(a);
    pageData = (InstructorFeedbackEditPageData) ar.data;
    statusMessage = pageData.getStatusMessagesToUser().get(0);
    verifyStatusMessage(statusMessage, Const.StatusMessages.FEEDBACK_SESSION_EDITED, StatusMessageColor.SUCCESS);
    assertFalse(pageData.getHasError());
    expectedString = "TEAMMATESLOG|||instructorFeedbackEditSave|||instructorFeedbackEditSave|||true|||" + "Instructor(M)|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Updated Feedback Session " + "<span class=\"bold\">(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-02-01T00:00:00Z" + "<span class=\"bold\"> to</span> 2015-01-01T00:00:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 2012-01-01T00:00:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 1970-01-01T00:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||/page/instructorFeedbackEditSave";
    AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedString, a.getLogMessage(), adminUserId);
    ______TS("failure: Invalid time zone");
    params[27] = "invalid time zone";
    verifyAssumptionFailure(params);
    ______TS("failure: Null time zone");
    params = ArrayUtils.remove(params, 26);
    params = ArrayUtils.remove(params, 26);
    verifyAssumptionFailure(params);
    ______TS("failure: Invalid grace period");
    params[25] = "12dsf";
    verifyAssumptionFailure(params);
    ______TS("failure: Null grace period");
    params = ArrayUtils.remove(params, 26);
    params = ArrayUtils.remove(params, 26);
    verifyAssumptionFailure(params);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackEditPageData(teammates.ui.pagedata.InstructorFeedbackEditPageData) AjaxResult(teammates.ui.controller.AjaxResult) InstructorFeedbackEditSaveAction(teammates.ui.controller.InstructorFeedbackEditSaveAction) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage) Test(org.testng.annotations.Test)

Example 13 with AjaxResult

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

the class InstructorFeedbackResponseCommentAddActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    FeedbackQuestionsDb feedbackQuestionsDb = new FeedbackQuestionsDb();
    FeedbackResponsesDb feedbackResponsesDb = new FeedbackResponsesDb();
    FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1");
    int questionNumber = 1;
    FeedbackQuestionAttributes question = feedbackQuestionsDb.getFeedbackQuestion(session.getFeedbackSessionName(), session.getCourseId(), questionNumber);
    String giverEmail = "student1InCourse1@gmail.tmt";
    String receiverEmail = "student1InCourse1@gmail.tmt";
    FeedbackResponseAttributes response = feedbackResponsesDb.getFeedbackResponse(question.getId(), giverEmail, receiverEmail);
    InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    ______TS("Unsuccessful case: not enough parameters");
    verifyAssumptionFailure();
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response" };
    verifyAssumptionFailure(submissionParams);
    ______TS("typical successful case for unpublished session");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    InstructorFeedbackResponseCommentAddAction action = getAction(submissionParams);
    ShowPageResult result = getShowPageResult(action);
    InstructorFeedbackResponseCommentAjaxPageData data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("typical successful case for unpublished session empty giver permissions");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Empty giver permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("typical successful case for unpublished session shown to various recipients");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Null comment permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Empty comment permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to giver", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to receiver", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to own team members", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "OWN_TEAM_MEMBERS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to receiver team members", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER_TEAM_MEMBERS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to students", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "STUDENTS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("typical successful case for published session");
    FeedbackSessionsLogic.inst().publishFeedbackSession(session);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response, published session", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "GIVER,INSTRUCTORS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("Unsuccessful case: empty comment text");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    AjaxResult ajaxResult = getAjaxResult(action);
    assertEquals("", ajaxResult.getStatusMessage());
    data = (InstructorFeedbackResponseCommentAjaxPageData) ajaxResult.data;
    assertTrue(data.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSE_COMMENT_EMPTY, data.errorMessage);
}
Also used : FeedbackResponsesDb(teammates.storage.api.FeedbackResponsesDb) InstructorFeedbackResponseCommentAjaxPageData(teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) AjaxResult(teammates.ui.controller.AjaxResult) ShowPageResult(teammates.ui.controller.ShowPageResult) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) InstructorFeedbackResponseCommentAddAction(teammates.ui.controller.InstructorFeedbackResponseCommentAddAction) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackQuestionsDb(teammates.storage.api.FeedbackQuestionsDb) Test(org.testng.annotations.Test)

Example 14 with AjaxResult

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

the class AdminActivityLogPageActionTest method verifyLoadingLocalTimeAjaxResult.

private void verifyLoadingLocalTimeAjaxResult(String expected, String role, String googleId, long timeInMillis) {
    String[] params = new String[] { "logRole", role, "logGoogleId", googleId, "logUnixTimeMillis", String.valueOf(timeInMillis) };
    AdminActivityLogPageAction action = getAction(params);
    AjaxResult result = getAjaxResult(action);
    AdminActivityLogPageData pageData = (AdminActivityLogPageData) result.data;
    assertEquals(expected, pageData.getLogLocalTime());
}
Also used : AjaxResult(teammates.ui.controller.AjaxResult) AdminActivityLogPageAction(teammates.ui.controller.AdminActivityLogPageAction) AdminActivityLogPageData(teammates.ui.pagedata.AdminActivityLogPageData)

Aggregations

AjaxResult (teammates.ui.controller.AjaxResult)14 Test (org.testng.annotations.Test)11 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)8 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)7 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)4 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)3 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)3 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)3 ShowPageResult (teammates.ui.controller.ShowPageResult)3 InstructorFeedbackResponseCommentAjaxPageData (teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData)3 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)2 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)2 FeedbackResponseCommentsDb (teammates.storage.api.FeedbackResponseCommentsDb)2 StudentProfileCreateFormUrlAction (teammates.ui.controller.StudentProfileCreateFormUrlAction)2 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)1 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)1 EmailWrapper (teammates.common.util.EmailWrapper)1 StatusMessage (teammates.common.util.StatusMessage)1 Logic (teammates.logic.api.Logic)1 AdminActivityLogPageAction (teammates.ui.controller.AdminActivityLogPageAction)1