use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class InstructorStudentListPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor = typicalBundle.instructors.get("instructor3OfCourse1");
String instructorId = instructor.googleId;
String[] submissionParams = new String[] { Const.ParamsNames.SEARCH_KEY, "A search key", Const.ParamsNames.DISPLAY_ARCHIVE, "false" };
______TS("Typical case, student list view");
gaeSimulation.loginAsInstructor(instructorId);
InstructorStudentListPageAction a = getAction(submissionParams);
ShowPageResult r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_LIST, false, instructorId), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals("", r.getStatusMessage());
String expectedLogMessage = "TEAMMATESLOG|||instructorStudentListPage|||instructorStudentListPage" + "|||true|||Instructor|||Instructor 3 of Course 1 and 2|||idOfInstructor3" + "|||instr3@course1n2.tmt|||instructorStudentList Page Load<br>Total Courses: 2" + "|||/page/instructorStudentListPage";
AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
InstructorStudentListPageData islpd = (InstructorStudentListPageData) r.data;
assertEquals(2, islpd.getNumOfCourses());
______TS("No courses");
instructorId = typicalBundle.accounts.get("instructorWithoutCourses").googleId;
gaeSimulation.loginAsInstructor(instructorId);
a = getAction(submissionParams);
r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_LIST, false, "instructorWithoutCourses"), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals(Const.StatusMessages.INSTRUCTOR_NO_COURSE_AND_STUDENTS, r.getStatusMessage());
islpd = (InstructorStudentListPageData) r.data;
assertEquals(0, islpd.getNumOfCourses());
expectedLogMessage = "TEAMMATESLOG|||instructorStudentListPage|||instructorStudentListPage" + "|||true|||Instructor|||Instructor Without Courses|||instructorWithoutCourses" + "|||iwc@yahoo.tmt|||instructorStudentList Page Load<br>Total Courses: 0" + "|||/page/instructorStudentListPage";
AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
instructor = typicalBundle.instructors.get("instructorOfArchivedCourse");
instructorId = instructor.googleId;
______TS("Archived course, not displayed");
gaeSimulation.loginAsInstructor(instructorId);
a = getAction(submissionParams);
r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_LIST, false, "idOfInstructorOfArchivedCourse"), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals("", r.getStatusMessage());
islpd = (InstructorStudentListPageData) r.data;
assertEquals(0, islpd.getNumOfCourses());
expectedLogMessage = "TEAMMATESLOG|||instructorStudentListPage|||instructorStudentListPage" + "|||true|||Instructor|||InstructorOfArchiveCourse name|||idOfInstructorOfArchivedCourse" + "|||instructorOfArchiveCourse@archiveCourse.tmt" + "|||instructorStudentList Page Load<br>Total Courses: 1" + "|||/page/instructorStudentListPage";
AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
submissionParams = new String[] { Const.ParamsNames.SEARCH_KEY, "A search key", Const.ParamsNames.DISPLAY_ARCHIVE, "true" };
______TS("Archived course, displayed");
gaeSimulation.loginAsInstructor(instructorId);
a = getAction(submissionParams);
r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_LIST, false, "idOfInstructorOfArchivedCourse"), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals("", r.getStatusMessage());
islpd = (InstructorStudentListPageData) r.data;
assertEquals(1, islpd.getNumOfCourses());
expectedLogMessage = "TEAMMATESLOG|||instructorStudentListPage|||instructorStudentListPage" + "|||true|||Instructor|||InstructorOfArchiveCourse name|||idOfInstructorOfArchivedCourse" + "|||instructorOfArchiveCourse@archiveCourse.tmt" + "|||instructorStudentList Page Load<br>Total Courses: 1" + "|||/page/instructorStudentListPage";
AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
}
use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class InstructorStudentRecordsAjaxPageActionTest method testAccessControl.
@Test
@Override
protected void testAccessControl() throws Exception {
InstructorAttributes instructor = typicalBundle.instructors.get("instructor3OfCourse1");
StudentAttributes student = typicalBundle.students.get("student2InCourse1");
CourseAttributes course = typicalBundle.courses.get("typicalCourse1");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.STUDENT_EMAIL, student.email, Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session" };
verifyOnlyInstructorsOfTheSameCourseCanAccess(submissionParams);
______TS("Instructor cannot view sections without View-Student-In-Sections privilege");
instructor = typicalBundle.instructors.get("helperOfCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.STUDENT_EMAIL, student.email, Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session" };
InstructorStudentRecordsAjaxPageAction a = getAction(submissionParams);
ShowPageResult r = getShowPageResult(a);
a = getAction(submissionParams);
r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS_AJAX, false, "idOfHelperOfCourse1"), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals("", r.getStatusMessage());
InstructorStudentRecordsAjaxPageData data = (InstructorStudentRecordsAjaxPageData) r.data;
assertEquals(0, data.getResultsTables().size());
}
use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class InstructorFeedbackEditCopyPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor = dataBundle.instructors.get("teammates.test.instructor2");
String instructorId = instructor.googleId;
gaeSimulation.loginAsInstructor(instructorId);
______TS("Successful case");
String[] submissionParams = { Const.ParamsNames.COURSE_ID, "valid course id", Const.ParamsNames.FEEDBACK_SESSION_NAME, "valid fs name" };
InstructorFeedbackEditCopyPageAction a = getAction(submissionParams);
ShowPageResult r = getShowPageResult(a);
assertFalse(r.isError);
InstructorFeedbackEditCopyPageData pageData = (InstructorFeedbackEditCopyPageData) r.data;
assertEquals(4, pageData.getCourses().size());
List<String> idOfCourses = new ArrayList<>();
for (CourseAttributes course : pageData.getCourses()) {
idOfCourses.add(course.getId());
}
// course is archived
assertFalse(idOfCourses.contains("FeedbackEditCopy.CS1101"));
// instructor does not have sufficient permissions
assertFalse(idOfCourses.contains("FeedbackEditCopy.CS2107"));
assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2102"));
assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2103"));
assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2103R"));
assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2104"));
}
use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class InstructorFeedbackPreviewAsInstructorActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor1 = typicalBundle.instructors.get("instructor1OfCourse1");
InstructorAttributes instructor2 = typicalBundle.instructors.get("instructor2OfCourse1");
InstructorAttributes instructorHelper = typicalBundle.instructors.get("helperOfCourse1");
String idOfInstructor1 = instructor1.googleId;
String idOfInstructor2 = instructor2.googleId;
String idOfInstructorHelper = instructorHelper.googleId;
gaeSimulation.loginAsInstructor(idOfInstructor1);
______TS("typical success case");
String feedbackSessionName = "First feedback session";
String courseId = "idOfTypicalCourse1";
String previewAsEmail = instructor2.email;
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.PREVIEWAS, previewAsEmail };
InstructorFeedbackPreviewAsInstructorAction paia = getAction(submissionParams);
ShowPageResult showPageResult = getShowPageResult(paia);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, idOfInstructor1), showPageResult.getDestinationWithParams());
assertEquals("", showPageResult.getStatusMessage());
AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorFeedbackPreviewAsInstructor|||instructorFeedbackPreviewAsInstructor" + "|||true|||Instructor|||Instructor 1 of Course 1" + "|||" + idOfInstructor1 + "|||instr1@course1.tmt|||" + "Preview feedback session as instructor (" + instructor2.email + ")<br>" + "Session Name: First feedback session<br>Course ID: " + instructor1.courseId + "|||/page/instructorFeedbackPreviewAsInstructor", paia.getLogMessage());
gaeSimulation.loginAsInstructor(idOfInstructor2);
______TS("typical success case");
feedbackSessionName = "First feedback session";
courseId = "idOfTypicalCourse1";
previewAsEmail = instructor1.email;
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName, Const.ParamsNames.PREVIEWAS, previewAsEmail };
paia = getAction(submissionParams);
showPageResult = getShowPageResult(paia);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, idOfInstructor2), showPageResult.getDestinationWithParams());
assertEquals("", showPageResult.getStatusMessage());
AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorFeedbackPreviewAsInstructor|||instructorFeedbackPreviewAsInstructor" + "|||true|||Instructor|||Instructor 2 of Course 1" + "|||" + idOfInstructor2 + "|||instr2@course1.tmt|||" + "Preview feedback session as instructor (" + instructor1.email + ")<br>" + "Session Name: First feedback session<br>Course ID: " + instructor1.courseId + "|||/page/instructorFeedbackPreviewAsInstructor", paia.getLogMessage());
gaeSimulation.loginAsInstructor(idOfInstructorHelper);
______TS("failure: not enough privilege");
feedbackSessionName = "First feedback session";
courseId = "idOfTypicalCourse1";
previewAsEmail = instructor2.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(idOfInstructor1);
______TS("failure: non-existent previewas email");
previewAsEmail = "non-existentEmail@course13212.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("Instructor Email " + previewAsEmail + " does not exist in " + courseId + ".", enfe.getMessage());
}
}
use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class InstructorCourseStudentDetailsEditPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
String instructorId = instructor1OfCourse1.googleId;
gaeSimulation.loginAsInstructor(instructorId);
______TS("Invalid parameters");
// no parameters
verifyAssumptionFailure();
// null student email
String[] invalidParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
verifyAssumptionFailure(invalidParams);
// null course id
invalidParams = new String[] { Const.ParamsNames.STUDENT_EMAIL, student1InCourse1.email };
verifyAssumptionFailure(invalidParams);
______TS("Typical case, edit student detail page");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, Const.ParamsNames.STUDENT_EMAIL, student1InCourse1.email };
InstructorCourseStudentDetailsEditPageAction a = getAction(submissionParams);
ShowPageResult r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_EDIT, false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals("", r.getStatusMessage());
InstructorCourseStudentDetailsEditPageData pageData = (InstructorCourseStudentDetailsEditPageData) r.data;
assertEquals(instructorId, pageData.account.googleId);
assertEquals(student1InCourse1.name, pageData.getStudentInfoTable().getName());
assertEquals(student1InCourse1.email, pageData.getStudentInfoTable().getEmail());
assertEquals(student1InCourse1.section, pageData.getStudentInfoTable().getSection());
assertEquals(student1InCourse1.team, pageData.getStudentInfoTable().getTeam());
assertEquals(student1InCourse1.comments, pageData.getStudentInfoTable().getComments());
assertEquals(student1InCourse1.course, pageData.getStudentInfoTable().getCourse());
String expectedLogMessage = "TEAMMATESLOG|||instructorCourseStudentDetailsEdit|||instructorCourseStudentDetailsEdit" + "|||true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1" + "|||instr1@course1.tmt|||instructorCourseStudentEdit Page Load<br>Editing Student " + "<span class=\"bold\">student1InCourse1@gmail.tmt's</span> details in Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + "|||/page/instructorCourseStudentDetailsEdit";
AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
}
Aggregations