Search in sources :

Example 11 with ShowPageResult

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());
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorStudentListPageAction(teammates.ui.controller.InstructorStudentListPageAction) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorStudentListPageData(teammates.ui.pagedata.InstructorStudentListPageData) Test(org.testng.annotations.Test)

Example 12 with ShowPageResult

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());
}
Also used : InstructorStudentRecordsAjaxPageData(teammates.ui.pagedata.InstructorStudentRecordsAjaxPageData) ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorStudentRecordsAjaxPageAction(teammates.ui.controller.InstructorStudentRecordsAjaxPageAction) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 13 with ShowPageResult

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"));
}
Also used : InstructorFeedbackEditCopyPageData(teammates.ui.pagedata.InstructorFeedbackEditCopyPageData) ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorFeedbackEditCopyPageAction(teammates.ui.controller.InstructorFeedbackEditCopyPageAction) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 14 with ShowPageResult

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());
    }
}
Also used : InstructorFeedbackPreviewAsInstructorAction(teammates.ui.controller.InstructorFeedbackPreviewAsInstructorAction) ShowPageResult(teammates.ui.controller.ShowPageResult) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) EntityNotFoundException(teammates.common.exception.EntityNotFoundException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 15 with ShowPageResult

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());
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorCourseStudentDetailsEditPageData(teammates.ui.pagedata.InstructorCourseStudentDetailsEditPageData) InstructorCourseStudentDetailsEditPageAction(teammates.ui.controller.InstructorCourseStudentDetailsEditPageAction) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Aggregations

ShowPageResult (teammates.ui.controller.ShowPageResult)51 Test (org.testng.annotations.Test)42 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)31 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)15 RedirectResult (teammates.ui.controller.RedirectResult)10 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)8 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)8 EntityNotFoundException (teammates.common.exception.EntityNotFoundException)5 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)4 NullPostParameterException (teammates.common.exception.NullPostParameterException)4 ArrayList (java.util.ArrayList)3 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)3 AdminActivityLogPageAction (teammates.ui.controller.AdminActivityLogPageAction)3 AdminEmailLogPageAction (teammates.ui.controller.AdminEmailLogPageAction)3 AjaxResult (teammates.ui.controller.AjaxResult)3 InstructorCourseEnrollPageAction (teammates.ui.controller.InstructorCourseEnrollPageAction)3 InstructorCourseEnrollPageData (teammates.ui.pagedata.InstructorCourseEnrollPageData)3 Instant (java.time.Instant)2 AdminEmailAttributes (teammates.common.datatransfer.attributes.AdminEmailAttributes)2 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)2