use of teammates.common.exception.EntityNotFoundException in project teammates by TEAMMATES.
the class InstructorEditInstructorFeedbackPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor = dataBundle.instructors.get("IEIFPTCourseinstr");
InstructorAttributes moderatedInstructor = dataBundle.instructors.get("IEIFPTCoursehelper1");
InstructorEditInstructorFeedbackPageAction editInstructorFpAction;
ShowPageResult showPageResult;
String courseId = moderatedInstructor.courseId;
String feedbackSessionName = "";
String moderatedInstructorEmail = "IEIFPTCoursehelper1@gmail.tmt";
String[] submissionParams;
gaeSimulation.loginAsInstructor(instructor.googleId);
______TS("typical success case");
feedbackSessionName = "First feedback session";
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
editInstructorFpAction = getAction(submissionParams);
showPageResult = getShowPageResult(editInstructorFpAction);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), showPageResult.getDestinationWithParams());
assertEquals("", showPageResult.getStatusMessage());
AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorEditInstructorFeedbackPage|||instructorEditInstructorFeedbackPage" + "|||true|||Instructor|||IEIFPTCourseinstr|||IEIFPTCourseinstr|||IEIFPTCourseintr@course1.tmt|||" + "Moderating feedback session for instructor (" + moderatedInstructor.email + ")<br>" + "Session Name: First feedback session<br>Course ID: IEIFPTCourse|||" + "/page/instructorEditInstructorFeedbackPage", editInstructorFpAction.getLogMessage());
______TS("success: another feedback");
feedbackSessionName = "Another feedback session";
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
editInstructorFpAction = getAction(submissionParams);
showPageResult = getShowPageResult(editInstructorFpAction);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), showPageResult.getDestinationWithParams());
assertEquals("", showPageResult.getStatusMessage());
String logMessage = "TEAMMATESLOG|||instructorEditInstructorFeedbackPage|||" + "instructorEditInstructorFeedbackPage|||true|||Instructor|||IEIFPTCourseinstr|||" + "IEIFPTCourseinstr|||IEIFPTCourseintr@course1.tmt|||" + "Moderating feedback session for instructor (" + moderatedInstructor.email + ")<br>" + "Session Name: Another feedback session<br>Course ID: IEIFPTCourse|||" + "/page/instructorEditInstructorFeedbackPage";
AssertHelper.assertLogMessageEquals(logMessage, editInstructorFpAction.getLogMessage());
______TS("failure: accessing non-existent moderatedinstructor email");
gaeSimulation.loginAsInstructor(instructor.googleId);
moderatedInstructorEmail = "non-exIstentEmail@gsail.tmt";
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedInstructorEmail };
try {
editInstructorFpAction = getAction(submissionParams);
editInstructorFpAction.executeAndPostProcess();
signalFailureToDetectException();
} catch (EntityNotFoundException enfe) {
assertEquals("Instructor Email " + moderatedInstructorEmail + " does not exist in " + courseId + ".", enfe.getMessage());
}
}
use of teammates.common.exception.EntityNotFoundException 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.EntityNotFoundException 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());
}
}
use of teammates.common.exception.EntityNotFoundException in project teammates by TEAMMATES.
the class Action method executeAndPostProcess.
/**
* ------------------------------------------------
*/
/**
* Executes the action (as implemented by a child class). Before passing
* the result to the caller, it does some post processing: <br>
* 1. If the original request contained a URL to redirect after performing
* the action, the result will be replaced with a new 'redirect' type
* result. Note: Redirection is not allowed to third-party destinations. <br>
* 2. User ID, error flag, and the status message will be added to the response,
* to be encoded into the URL. The error flag is also added to the
* {@code isError} flag in the {@link ActionResult} object.
*/
public ActionResult executeAndPostProcess() {
if (!isValidUser()) {
return createRedirectResult(getAuthenticationRedirectUrl());
}
// get the result from the child class.
ActionResult response;
try {
response = execute();
} catch (EntityDoesNotExistException e) {
throw new EntityNotFoundException(e);
}
// set error flag of the result
response.isError = isError;
// Set the common parameters for the response
if (gateKeeper.getCurrentUser() != null) {
response.responseParams.put(Const.ParamsNames.USER_ID, account.googleId);
}
if (regkey != null) {
response.responseParams.put(Const.ParamsNames.REGKEY, getRegkeyFromRequest());
if (student != null) {
response.responseParams.put(Const.ParamsNames.STUDENT_EMAIL, student.email);
response.responseParams.put(Const.ParamsNames.COURSE_ID, student.course);
}
if (getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME) != null) {
response.responseParams.put(Const.ParamsNames.FEEDBACK_SESSION_NAME, getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME));
}
}
response.responseParams.put(Const.ParamsNames.ERROR, Boolean.toString(response.isError));
// Pass status message using session to prevent XSS attack
if (!response.getStatusMessage().isEmpty()) {
putStatusMessageToSession(response);
}
return response;
}
Aggregations