use of teammates.common.exception.UnauthorizedAccessException in project teammates by TEAMMATES.
the class InstructorEditInstructorFeedbackSaveActionTest method testSubmitResponseForInvalidQuestion.
private void testSubmitResponseForInvalidQuestion() {
FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
FeedbackQuestionAttributes fq;
FeedbackResponsesDb frDb = new FeedbackResponsesDb();
FeedbackResponseAttributes fr;
InstructorAttributes instructor = dataBundle.instructors.get("IEIFPTCourseinstr");
InstructorEditInstructorFeedbackSaveAction editInstructorFsAction;
String moderatedInstructorEmail = "IEIFPTCoursehelper1@gmail.tmt";
String[] submissionParams;
gaeSimulation.loginAsInstructor(instructor.googleId);
______TS("Failure case: submit response for question in session, but should not be editable by instructor " + "(unable to see recipient)");
fq = fqDb.getFeedbackQuestion("First feedback session", "IEIFPTCourse", 4);
assertNotNull("Feedback question not found in database", fq);
fr = dataBundle.feedbackResponses.get("response1ForQ4");
fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
assertNotNull("Feedback response not found in database", fr);
submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-1-0", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-1-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "Edited" + fr.getResponseDetails().getAnswerString(), Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
try {
editInstructorFsAction = getAction(submissionParams);
editInstructorFsAction.executeAndPostProcess();
signalFailureToDetectException("Did not detect that this instructor cannot access this particular question.");
} catch (UnauthorizedAccessException e) {
assertEquals("Feedback session [First feedback session] question [" + fr.feedbackQuestionId + "] " + "is not accessible to instructor [" + instructor.email + "]", e.getMessage());
}
______TS("Failure case: submit response for question in session, but should not be editable by instructor " + "(unable to see giver)");
fq = fqDb.getFeedbackQuestion("First feedback session", "IEIFPTCourse", 5);
assertNotNull("Feedback question not found in database", fq);
fr = dataBundle.feedbackResponses.get("response1ForQ5");
fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
assertNotNull("Feedback response not found in database", fr);
submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-1-0", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-1-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "Edited" + fr.getResponseDetails().getAnswerString(), Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
try {
editInstructorFsAction = getAction(submissionParams);
editInstructorFsAction.executeAndPostProcess();
signalFailureToDetectException("Did not detect that this instructor cannot access this particular question.");
} catch (UnauthorizedAccessException e) {
assertEquals("Feedback session [First feedback session] question [" + fr.feedbackQuestionId + "] " + "is not accessible to instructor [" + instructor.email + "]", e.getMessage());
}
}
use of teammates.common.exception.UnauthorizedAccessException in project teammates by TEAMMATES.
the class InstructorEditStudentFeedbackPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor = dataBundle.instructors.get("IESFPTCourseinstr");
InstructorAttributes instructorHelper = dataBundle.instructors.get("IESFPTCoursehelper1");
String idOfInstructor = instructor.googleId;
String idOfInstructorHelper = instructorHelper.googleId;
StudentAttributes student = dataBundle.students.get("student1InCourse1");
gaeSimulation.loginAsInstructor(idOfInstructor);
______TS("typical success case");
String feedbackSessionName = "First feedback session";
String courseId = student.course;
String moderatedStudentEmail = student.email;
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
InstructorEditStudentFeedbackPageAction editPageAction = getAction(submissionParams);
ShowPageResult showPageResult = getShowPageResult(editPageAction);
assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, false, idOfInstructor), showPageResult.getDestinationWithParams());
assertEquals("", showPageResult.getStatusMessage());
AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorEditStudentFeedbackPage|||instructorEditStudentFeedbackPage|||true|||" + "Instructor|||IESFPTCourseinstr|||IESFPTCourseinstr|||IESFPTCourseintr@course1.tmt|||" + "Moderating feedback session for student (" + student.email + ")<br>" + "Session Name: First feedback session<br>Course ID: IESFPTCourse|||" + "/page/instructorEditStudentFeedbackPage", editPageAction.getLogMessage());
______TS("success: another feedback");
feedbackSessionName = "Another feedback session";
courseId = student.course;
moderatedStudentEmail = student.email;
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
editPageAction = getAction(submissionParams);
showPageResult = getShowPageResult(editPageAction);
______TS("success case: closed session");
feedbackSessionName = "Closed feedback session";
courseId = student.course;
moderatedStudentEmail = student.email;
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
editPageAction = getAction(submissionParams);
showPageResult = getShowPageResult(editPageAction);
assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, false, idOfInstructor), showPageResult.getDestinationWithParams());
assertEquals("", showPageResult.getStatusMessage());
gaeSimulation.loginAsInstructor(idOfInstructor);
______TS("success case: moderate team");
feedbackSessionName = "Closed feedback session";
courseId = student.course;
String moderatedStudentTeam = student.team;
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentTeam };
editPageAction = getAction(submissionParams);
showPageResult = getShowPageResult(editPageAction);
assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, false, idOfInstructor), showPageResult.getDestinationWithParams());
assertEquals("", showPageResult.getStatusMessage());
AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorEditStudentFeedbackPage|||instructorEditStudentFeedbackPage|||true|||" + "Instructor|||IESFPTCourseinstr|||IESFPTCourseinstr|||IESFPTCourseintr@course1.tmt|||" + "Moderating feedback session for student (" + student.email + ")<br>" + "Session Name: Closed feedback session<br>Course ID: IESFPTCourse|||" + "/page/instructorEditStudentFeedbackPage", editPageAction.getLogMessage());
gaeSimulation.loginAsInstructor(idOfInstructorHelper);
______TS("failure: does not have privilege");
feedbackSessionName = "First feedback session";
courseId = "IESFPTCourse";
moderatedStudentEmail = student.email;
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
try {
editPageAction = getAction(submissionParams);
showPageResult = getShowPageResult(editPageAction);
} catch (UnauthorizedAccessException e) {
assertEquals("Feedback session [First feedback session] is not accessible to instructor [" + instructorHelper.email + "] for privilege [" + Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS + "] on section [Section 1]", e.getMessage());
}
gaeSimulation.loginAsInstructor(idOfInstructor);
______TS("failure: non-existent moderatedstudent email");
moderatedStudentEmail = "non-exIstentEmail@gsail.tmt";
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
try {
editPageAction = getAction(submissionParams);
showPageResult = getShowPageResult(editPageAction);
signalFailureToDetectException();
} catch (EntityNotFoundException enfe) {
assertEquals("An entity with the identifier " + moderatedStudentEmail + " does not exist in " + courseId + ".", enfe.getMessage());
}
}
use of teammates.common.exception.UnauthorizedAccessException 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());
}
use of teammates.common.exception.UnauthorizedAccessException in project teammates by TEAMMATES.
the class InstructorFeedbackEditPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor1OfCourse1.googleId);
// declare all variables to be used
String expectedString = "";
FeedbackSessionAttributes feedbackSessionAttributes;
String[] submissionParams;
InstructorFeedbackEditPageAction instructorFeedbackEditPageAction;
ShowPageResult showPageResult;
______TS("typical success case");
feedbackSessionAttributes = typicalBundle.feedbackSessions.get("session1InCourse1");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackSessionAttributes.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionAttributes.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_SESSION_ENABLE_EDIT, "true" };
instructorFeedbackEditPageAction = getAction(submissionParams);
showPageResult = getShowPageResult(instructorFeedbackEditPageAction);
expectedString = getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_EDIT, false, instructor1OfCourse1.googleId);
assertEquals(expectedString, showPageResult.getDestinationWithParams());
assertEquals("", showPageResult.getStatusMessage());
expectedString = "TEAMMATESLOG|||instructorFeedbackEditPage|||instructorFeedbackEditPage|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||instructorFeedbackEdit " + "Page Load<br>Editing information for Feedback Session " + "<span class=\"bold\">[" + feedbackSessionAttributes.getFeedbackSessionName() + "]</span>" + "in Course: <span class=\"bold\">[idOfTypicalCourse1]</span>" + "|||/page/instructorFeedbackEditPage";
AssertHelper.assertLogMessageEquals(expectedString, instructorFeedbackEditPageAction.getLogMessage());
______TS("failure 1: non-existent feedback session");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackSessionAttributes.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, "randomName for Session123", Const.ParamsNames.FEEDBACK_SESSION_ENABLE_EDIT, "true" };
instructorFeedbackEditPageAction = getAction(submissionParams);
try {
showPageResult = getShowPageResult(instructorFeedbackEditPageAction);
signalFailureToDetectException();
} catch (UnauthorizedAccessException uae) {
assertEquals("Trying to access system using a non-existent feedback session entity", uae.getMessage());
}
}
use of teammates.common.exception.UnauthorizedAccessException in project teammates by TEAMMATES.
the class InstructorFeedbackPreviewAsStudentActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
InstructorAttributes instructorHelper = typicalBundle.instructors.get("helperOfCourse1");
String idOfInstructor = instructor.googleId;
String idOfInstructorHelper = instructorHelper.googleId;
StudentAttributes student = typicalBundle.students.get("student1InCourse1");
gaeSimulation.loginAsInstructor(idOfInstructor);
______TS("typical success case");
String feedbackSessionName = "First feedback session";
String courseId = student.course;
String previewAsEmail = student.email;
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.PREVIEWAS, previewAsEmail };
InstructorFeedbackPreviewAsStudentAction paia = getAction(submissionParams);
ShowPageResult showPageResult = getShowPageResult(paia);
assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, false, idOfInstructor), showPageResult.getDestinationWithParams());
assertEquals("", showPageResult.getStatusMessage());
AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorFeedbackPreviewAsStudent|||instructorFeedbackPreviewAsStudent" + "|||true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Preview feedback session as student (" + student.email + ")<br>" + "Session Name: First feedback session<br>Course ID: idOfTypicalCourse1|||" + "/page/instructorFeedbackPreviewAsStudent", paia.getLogMessage());
gaeSimulation.loginAsInstructor(idOfInstructorHelper);
______TS("failure: not enough privilege");
feedbackSessionName = "First feedback session";
courseId = "idOfTypicalCourse1";
previewAsEmail = student.email;
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.PREVIEWAS, previewAsEmail };
try {
paia = getAction(submissionParams);
showPageResult = getShowPageResult(paia);
} catch (UnauthorizedAccessException e) {
assertEquals("Feedback session [First feedback session] is not accessible to instructor [" + instructorHelper.email + "] for privilege [canmodifysession]", e.getMessage());
}
gaeSimulation.loginAsInstructor(idOfInstructor);
______TS("failure: non-existent previewas email");
previewAsEmail = "non-exIstentEmail@gsail.tmt";
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.PREVIEWAS, previewAsEmail };
try {
paia = getAction(submissionParams);
showPageResult = getShowPageResult(paia);
signalFailureToDetectException();
} catch (EntityNotFoundException enfe) {
assertEquals("Student Email " + previewAsEmail + " does not exist in " + courseId + ".", enfe.getMessage());
}
}
Aggregations