Search in sources :

Example 1 with InstructorFeedbackQuestionCopyPageAction

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

the class InstructorFeedbackQuestionCopyPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1OfCourse1.googleId);
    ______TS("typical success case");
    FeedbackSessionAttributes feedbackSessionAttributes = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackSessionAttributes.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionAttributes.getFeedbackSessionName() };
    InstructorFeedbackQuestionCopyPageAction action = getAction(submissionParams);
    ShowPageResult result = getShowPageResult(action);
    String expectedString = getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_QUESTION_COPY_MODAL, false, instructor1OfCourse1.googleId);
    assertEquals(expectedString, result.getDestinationWithParams());
    assertTrue(result.getStatusMessage().isEmpty());
    ______TS("failure: non-existent feedback session");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackSessionAttributes.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, "Non-existent Session Name" };
    action = getAction(submissionParams);
    try {
        result = getShowPageResult(action);
        signalFailureToDetectException();
    } catch (UnauthorizedAccessException uae) {
        assertEquals("Trying to access system using a non-existent feedback session entity", uae.getMessage());
    }
    ______TS("failure: unsufficient permissions");
    gaeSimulation.loginAsInstructor(typicalBundle.accounts.get("helperOfCourse1").googleId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackSessionAttributes.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionAttributes.getFeedbackSessionName() };
    action = getAction(submissionParams);
    try {
        result = getShowPageResult(action);
        signalFailureToDetectException();
    } catch (UnauthorizedAccessException uae) {
        assertEquals("Feedback session [First feedback session] is not accessible " + "to instructor [helper@course1.tmt] for privilege [canmodifysession]", uae.getMessage());
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ShowPageResult(teammates.ui.controller.ShowPageResult) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) InstructorFeedbackQuestionCopyPageAction(teammates.ui.controller.InstructorFeedbackQuestionCopyPageAction) 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 InstructorFeedbackQuestionCopyPageAction (teammates.ui.controller.InstructorFeedbackQuestionCopyPageAction)1 ShowPageResult (teammates.ui.controller.ShowPageResult)1