Search in sources :

Example 1 with FeedbackSessionStatsPageAction

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

the class FeedbackSessionStatsPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    String instructorId = instructor1OfCourse1.googleId;
    String[] submissionParams;
    gaeSimulation.loginAsInstructor(instructorId);
    ______TS("typical: instructor accesses feedback stats of his/her course");
    FeedbackSessionAttributes accessableFeedbackSession = typicalBundle.feedbackSessions.get("session1InCourse1");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, accessableFeedbackSession.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
    FeedbackSessionStatsPageAction a = getAction(addUserIdToParams(instructorId, submissionParams));
    AjaxResult r = getAjaxResult(a);
    FeedbackSessionStatsPageData data = (FeedbackSessionStatsPageData) r.data;
    assertEquals(getPageResultDestination("", false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
    assertEquals(10, data.sessionDetails.stats.expectedTotal);
    assertEquals(4, data.sessionDetails.stats.submittedTotal);
    assertEquals("", r.getStatusMessage());
    ______TS("fail: instructor accesses stats of non-existent feedback session");
    String nonexistentFeedbackSession = "nonexistentFeedbackSession";
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, nonexistentFeedbackSession, Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
    boolean hasThrownUnauthorizedAccessException = false;
    String exceptionMessage = "";
    a = getAction(addUserIdToParams(instructorId, submissionParams));
    try {
        r = getAjaxResult(a);
    } catch (UnauthorizedAccessException e) {
        hasThrownUnauthorizedAccessException = true;
        exceptionMessage = e.getMessage();
    }
    assertTrue(hasThrownUnauthorizedAccessException);
    assertEquals("Trying to access system using a non-existent feedback session entity", exceptionMessage);
    assertEquals("", r.getStatusMessage());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) AjaxResult(teammates.ui.controller.AjaxResult) FeedbackSessionStatsPageAction(teammates.ui.controller.FeedbackSessionStatsPageAction) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) FeedbackSessionStatsPageData(teammates.ui.pagedata.FeedbackSessionStatsPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)1 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)1 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)1 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)1 AjaxResult (teammates.ui.controller.AjaxResult)1 FeedbackSessionStatsPageAction (teammates.ui.controller.FeedbackSessionStatsPageAction)1 FeedbackSessionStatsPageData (teammates.ui.pagedata.FeedbackSessionStatsPageData)1