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