use of teammates.ui.controller.ShowPageResult 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.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class InstructorCourseEnrollPageActionTest method visitEnrollPage_inMasqueradeMode.
private void visitEnrollPage_inMasqueradeMode() {
______TS("Masquerade mode");
gaeSimulation.loginAsAdmin("admin.user");
InstructorAttributes instructorToMasquerade = typicalBundle.instructors.get("instructor4");
String instructorId = instructorToMasquerade.googleId;
String courseId = instructorToMasquerade.courseId;
String[] submissionParams = new String[] { Const.ParamsNames.USER_ID, instructorId, Const.ParamsNames.COURSE_ID, courseId };
InstructorCourseEnrollPageAction enrollPageAction = getAction(submissionParams);
ShowPageResult pageResult = getShowPageResult(enrollPageAction);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL, false, "idOfInstructor4"), pageResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals("", pageResult.getStatusMessage());
InstructorCourseEnrollPageData pageData = (InstructorCourseEnrollPageData) pageResult.data;
assertEquals(courseId, pageData.getCourseId());
assertNull(pageData.getEnrollStudents());
String expectedLogSegment = String.format(Const.StatusMessages.ADMIN_LOG_INSTRUCTOR_COURSE_ENROLL_PAGE_LOAD, courseId);
AssertHelper.assertContains(expectedLogSegment, enrollPageAction.getLogMessage());
}
use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class InstructorCourseJoinActionTest method testExecuteAndPostProcess.
@SuppressWarnings("deprecation")
@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
InstructorsDb instrDb = new InstructorsDb();
// Reassign to let "key" variable in "instructor" not to be null
instructor = instrDb.getInstructorForGoogleId(instructor.courseId, instructor.googleId);
String invalidEncryptedKey = StringHelper.encrypt("invalidKey");
gaeSimulation.loginAsInstructor(instructor.googleId);
______TS("Invalid key, redirect for confirmation again");
String[] submissionParams = new String[] { Const.ParamsNames.REGKEY, invalidEncryptedKey };
InstructorCourseJoinAction confirmAction = getAction(submissionParams);
ShowPageResult pageResult = getShowPageResult(confirmAction);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_JOIN_CONFIRMATION, false, "idOfInstructor1OfCourse1", invalidEncryptedKey), pageResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals("", pageResult.getStatusMessage());
String expectedLogSegment = "Action Instructor Clicked Join Link" + "<br>Google ID: " + instructor.googleId + "<br>Key: " + invalidEncryptedKey;
AssertHelper.assertContains(expectedLogSegment, confirmAction.getLogMessage());
______TS("Already registered instructor, redirect straight to authentication page");
submissionParams = new String[] { Const.ParamsNames.REGKEY, StringHelper.encrypt(instructor.key) };
confirmAction = getAction(submissionParams);
RedirectResult redirectResult = getRedirectResult(confirmAction);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN_AUTHENTICATED, StringHelper.encrypt(instructor.key), false, "idOfInstructor1OfCourse1"), redirectResult.getDestinationWithParams());
assertFalse(redirectResult.isError);
assertEquals("", redirectResult.getStatusMessage());
expectedLogSegment = "Action Instructor Clicked Join Link" + "<br>Google ID: " + instructor.googleId + "<br>Key: " + StringHelper.encrypt(instructor.key);
AssertHelper.assertContains(expectedLogSegment, confirmAction.getLogMessage());
______TS("Typical case: unregistered instructor, redirect to confirmation page");
instructor = InstructorAttributes.builder(null, instructor.courseId, "New Instructor", "ICJAT.instr@email.com").build();
InstructorsLogic.inst().createInstructor(instructor);
instructor.googleId = "ICJAT.instr";
AccountAttributes newInstructorAccount = AccountAttributes.builder().withGoogleId(instructor.googleId).withName(instructor.name).withEmail(instructor.email).withInstitute("TEAMMATES Test Institute 5").withIsInstructor(false).withDefaultStudentProfileAttributes(instructor.googleId).build();
AccountsLogic.inst().createAccount(newInstructorAccount);
InstructorAttributes newInstructor = instrDb.getInstructorForEmail(instructor.courseId, instructor.email);
gaeSimulation.loginUser(instructor.googleId);
submissionParams = new String[] { Const.ParamsNames.REGKEY, StringHelper.encrypt(newInstructor.key) };
confirmAction = getAction(submissionParams);
pageResult = getShowPageResult(confirmAction);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_JOIN_CONFIRMATION, false, "ICJAT.instr", StringHelper.encrypt(newInstructor.key)), pageResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals("", pageResult.getStatusMessage());
expectedLogSegment = "Action Instructor Clicked Join Link" + "<br>Google ID: " + instructor.googleId + "<br>Key: " + StringHelper.encrypt(newInstructor.key);
AssertHelper.assertContains(expectedLogSegment, confirmAction.getLogMessage());
}
use of teammates.ui.controller.ShowPageResult 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());
}
}
use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentAddActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
FeedbackQuestionsDb feedbackQuestionsDb = new FeedbackQuestionsDb();
FeedbackResponsesDb feedbackResponsesDb = new FeedbackResponsesDb();
FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1");
int questionNumber = 1;
FeedbackQuestionAttributes question = feedbackQuestionsDb.getFeedbackQuestion(session.getFeedbackSessionName(), session.getCourseId(), questionNumber);
String giverEmail = "student1InCourse1@gmail.tmt";
String receiverEmail = "student1InCourse1@gmail.tmt";
FeedbackResponseAttributes response = feedbackResponsesDb.getFeedbackResponse(question.getId(), giverEmail, receiverEmail);
InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
______TS("Unsuccessful case: not enough parameters");
verifyAssumptionFailure();
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response" };
verifyAssumptionFailure(submissionParams);
______TS("typical successful case for unpublished session");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
InstructorFeedbackResponseCommentAddAction action = getAction(submissionParams);
ShowPageResult result = getShowPageResult(action);
InstructorFeedbackResponseCommentAjaxPageData data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("typical successful case for unpublished session empty giver permissions");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Empty giver permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("typical successful case for unpublished session shown to various recipients");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Null comment permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Empty comment permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to giver", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to receiver", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to own team members", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "OWN_TEAM_MEMBERS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to receiver team members", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER_TEAM_MEMBERS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to students", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "STUDENTS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("typical successful case for published session");
FeedbackSessionsLogic.inst().publishFeedbackSession(session);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response, published session", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "GIVER,INSTRUCTORS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("Unsuccessful case: empty comment text");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
AjaxResult ajaxResult = getAjaxResult(action);
assertEquals("", ajaxResult.getStatusMessage());
data = (InstructorFeedbackResponseCommentAjaxPageData) ajaxResult.data;
assertTrue(data.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSE_COMMENT_EMPTY, data.errorMessage);
}
Aggregations