Search in sources :

Example 16 with ShowPageResult

use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.

the class InstructorCourseStudentDetailsEditSaveActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    String instructorId = instructor1OfCourse1.googleId;
    String newStudentEmail = "newemail@gmail.tmt";
    String newStudentTeam = "new student's team";
    String newStudentComments = "this is new comment after editing";
    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, successful edit and save student detail");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, Const.ParamsNames.STUDENT_EMAIL, student1InCourse1.email, Const.ParamsNames.STUDENT_NAME, student1InCourse1.name, Const.ParamsNames.NEW_STUDENT_EMAIL, newStudentEmail, Const.ParamsNames.COMMENTS, newStudentComments, Const.ParamsNames.TEAM_NAME, newStudentTeam, Const.ParamsNames.SESSION_SUMMARY_EMAIL_SEND_CHECK, "true" };
    InstructorCourseStudentDetailsEditSaveAction a = getAction(submissionParams);
    RedirectResult r = getRedirectResult(a);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE, false, "idOfInstructor1OfCourse1", "idOfTypicalCourse1"), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.STUDENT_EDITED_AND_EMAIL_SENT, r.getStatusMessage());
    verifyNumberOfEmailsSent(a, 1);
    EmailWrapper email = getEmailsSent(a).get(0);
    String courseName = coursesLogic.getCourse(instructor1OfCourse1.courseId).getName();
    assertEquals(String.format(EmailType.STUDENT_EMAIL_CHANGED.getSubject(), courseName, instructor1OfCourse1.courseId), email.getSubject());
    assertEquals(newStudentEmail, email.getRecipient());
    String expectedLogMessage = "TEAMMATESLOG|||instructorCourseStudentDetailsEditSave|||instructorCourseStudentDetailsEditSave" + "|||true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Student <span class=\"bold\">" + student1InCourse1.email + "'s</span> details in Course <span class=\"bold\">[idOfTypicalCourse1]</span> edited.<br>" + "New Email: " + newStudentEmail + "<br>New Team: " + newStudentTeam + "<br>Comments: " + newStudentComments + "|||/page/instructorCourseStudentDetailsEditSave";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("Typical case, successful edit and save student detail with spaces to be trimmed");
    // after trim, this is equal to newStudentEmail
    String newStudentEmailToBeTrimmed = "  newemail@gmail.tmt   ";
    String newStudentTeamToBeTrimmed = "  New team   ";
    String newStudentCommentsToBeTrimmed = "  this is new comment after editing   ";
    String[] submissionParamsToBeTrimmed = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, Const.ParamsNames.STUDENT_EMAIL, newStudentEmail, Const.ParamsNames.STUDENT_NAME, student1InCourse1.name, Const.ParamsNames.NEW_STUDENT_EMAIL, newStudentEmailToBeTrimmed, Const.ParamsNames.COMMENTS, newStudentCommentsToBeTrimmed, Const.ParamsNames.TEAM_NAME, newStudentTeamToBeTrimmed, Const.ParamsNames.SESSION_SUMMARY_EMAIL_SEND_CHECK, "true" };
    InstructorCourseStudentDetailsEditSaveAction aToBeTrimmed = getAction(submissionParamsToBeTrimmed);
    RedirectResult rToBeTrimmed = getRedirectResult(aToBeTrimmed);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE, false, "idOfInstructor1OfCourse1", "idOfTypicalCourse1"), rToBeTrimmed.getDestinationWithParams());
    assertFalse(rToBeTrimmed.isError);
    assertEquals(Const.StatusMessages.STUDENT_EDITED, rToBeTrimmed.getStatusMessage());
    verifyNoEmailsSent(aToBeTrimmed);
    String expectedLogMessageToBeTrimmed = "TEAMMATESLOG|||instructorCourseStudentDetailsEditSave|||instructorCourseStudentDetailsEditSave" + "|||true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Student <span class=\"bold\">" + newStudentEmail + "'s</span> details in Course <span class=\"bold\">[idOfTypicalCourse1]</span> edited.<br>" + "New Email: " + newStudentEmailToBeTrimmed.trim() + "<br>New Team: " + newStudentTeamToBeTrimmed.trim() + "<br>Comments: " + newStudentCommentsToBeTrimmed.trim() + "|||/page/instructorCourseStudentDetailsEditSave";
    AssertHelper.assertLogMessageEquals(expectedLogMessageToBeTrimmed, aToBeTrimmed.getLogMessage());
    ______TS("Error case, invalid email parameter (email has too many characters)");
    String invalidStudentEmail = StringHelperExtension.generateStringOfLength(255 - "@gmail.tmt".length()) + "@gmail.tmt";
    assertEquals(FieldValidator.EMAIL_MAX_LENGTH + 1, invalidStudentEmail.length());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, // Use the new email as the previous email have been changed
    Const.ParamsNames.STUDENT_EMAIL, // Use the new email as the previous email have been changed
    newStudentEmail, Const.ParamsNames.STUDENT_NAME, student1InCourse1.name, Const.ParamsNames.NEW_STUDENT_EMAIL, invalidStudentEmail, Const.ParamsNames.COMMENTS, student1InCourse1.comments, Const.ParamsNames.TEAM_NAME, student1InCourse1.team };
    gaeSimulation.loginAsInstructor(instructorId);
    a = getAction(submissionParams);
    ShowPageResult result = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_EDIT, true, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertTrue(result.isError);
    assertEquals(getPopulatedErrorMessage(FieldValidator.EMAIL_ERROR_MESSAGE, invalidStudentEmail, FieldValidator.EMAIL_FIELD_NAME, FieldValidator.REASON_TOO_LONG, FieldValidator.EMAIL_MAX_LENGTH), result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorCourseStudentDetailsEditSave|||instructorCourseStudentDetailsEditSave" + "|||true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Servlet Action Failure : " + getPopulatedErrorMessage(FieldValidator.EMAIL_ERROR_MESSAGE, invalidStudentEmail, FieldValidator.EMAIL_FIELD_NAME, FieldValidator.REASON_TOO_LONG, FieldValidator.EMAIL_MAX_LENGTH) + "|||/page/instructorCourseStudentDetailsEditSave";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("Error case, invalid email parameter (email already taken by others)");
    StudentAttributes student2InCourse1 = typicalBundle.students.get("student2InCourse1");
    String takenStudentEmail = student2InCourse1.email;
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, // Use the new email as the previous email have been changed
    Const.ParamsNames.STUDENT_EMAIL, // Use the new email as the previous email have been changed
    newStudentEmail, Const.ParamsNames.STUDENT_NAME, student1InCourse1.name, Const.ParamsNames.NEW_STUDENT_EMAIL, takenStudentEmail, Const.ParamsNames.COMMENTS, student1InCourse1.comments, Const.ParamsNames.TEAM_NAME, student1InCourse1.team };
    gaeSimulation.loginAsInstructor(instructorId);
    a = getAction(submissionParams);
    result = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_EDIT, true, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertTrue(result.isError);
    assertEquals(String.format(Const.StatusMessages.STUDENT_EMAIL_TAKEN_MESSAGE, student2InCourse1.name, takenStudentEmail), result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorCourseStudentDetailsEditSave|||instructorCourseStudentDetailsEditSave" + "|||true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Servlet Action Failure : " + String.format(Const.StatusMessages.STUDENT_EMAIL_TAKEN_MESSAGE, student2InCourse1.name, takenStudentEmail) + "|||/page/instructorCourseStudentDetailsEditSave";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    // deleting edited student
    AccountsLogic.inst().deleteAccountCascade(student2InCourse1.googleId);
    AccountsLogic.inst().deleteAccountCascade(student1InCourse1.googleId);
    ______TS("Error case, student does not exist");
    String nonExistentEmailForStudent = "notinuseemail@gmail.tmt";
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, Const.ParamsNames.STUDENT_EMAIL, nonExistentEmailForStudent, Const.ParamsNames.STUDENT_NAME, student1InCourse1.name, Const.ParamsNames.NEW_STUDENT_EMAIL, student1InCourse1.email, Const.ParamsNames.COMMENTS, student1InCourse1.comments, Const.ParamsNames.TEAM_NAME, student1InCourse1.team };
    gaeSimulation.loginAsInstructor(instructorId);
    a = getAction(submissionParams);
    RedirectResult redirectResult = getRedirectResult(a);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE, true, instructorId, instructor1OfCourse1.courseId), redirectResult.getDestinationWithParams());
    assertTrue(redirectResult.isError);
    assertEquals(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_EDIT, redirectResult.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorCourseStudentDetailsEditSave|||instructorCourseStudentDetailsEditSave" + "|||true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Student <span class=\"bold\">" + nonExistentEmailForStudent + "</span> in " + "Course <span class=\"bold\">[" + instructor1OfCourse1.courseId + "]</span> not found." + "|||/page/instructorCourseStudentDetailsEditSave";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("Unsuccessful case: test null student email parameter");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
    try {
        a = getAction(submissionParams);
        r = getRedirectResult(a);
        signalFailureToDetectException("Did not detect that parameters are null.");
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.STUDENT_EMAIL), e.getMessage());
    }
    ______TS("Unsuccessful case: test null course id parameter");
    submissionParams = new String[] { Const.ParamsNames.STUDENT_EMAIL, newStudentEmail };
    try {
        a = getAction(submissionParams);
        r = getRedirectResult(a);
        signalFailureToDetectException("Did not detect that parameters are null.");
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.COURSE_ID), e.getMessage());
    }
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) NullPostParameterException(teammates.common.exception.NullPostParameterException) RedirectResult(teammates.ui.controller.RedirectResult) InstructorCourseStudentDetailsEditSaveAction(teammates.ui.controller.InstructorCourseStudentDetailsEditSaveAction) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper) Test(org.testng.annotations.Test)

Example 17 with ShowPageResult

use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.

the class InstructorCourseStudentDetailsPageActionTest 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, view student detail");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, Const.ParamsNames.STUDENT_EMAIL, student1InCourse1.email };
    InstructorCourseStudentDetailsPageAction a = getAction(submissionParams);
    ShowPageResult r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_DETAILS, false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals("", r.getStatusMessage());
    InstructorCourseStudentDetailsPageData pageData = (InstructorCourseStudentDetailsPageData) 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|||instructorCourseStudentDetailsPage|||instructorCourseStudentDetailsPage" + "|||true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1" + "|||instr1@course1.tmt|||instructorCourseStudentDetails Page Load<br>Viewing details for Student " + "<span class=\"bold\">student1InCourse1@gmail.tmt</span> in Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + "|||/page/instructorCourseStudentDetailsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorCourseStudentDetailsPageData(teammates.ui.pagedata.InstructorCourseStudentDetailsPageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorCourseStudentDetailsPageAction(teammates.ui.controller.InstructorCourseStudentDetailsPageAction) Test(org.testng.annotations.Test)

Example 18 with ShowPageResult

use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.

the class InstructorCourseDetailsPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1OfCourse1.googleId);
    ______TS("Not enough parameters");
    verifyAssumptionFailure();
    ______TS("Typical Case, Course with at least one student");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
    InstructorCourseDetailsPageAction pageAction = getAction(submissionParams);
    ShowPageResult pageResult = getShowPageResult(pageAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_DETAILS, false, "idOfInstructor1OfCourse1"), pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals("", pageResult.getStatusMessage());
    InstructorCourseDetailsPageData pageData = (InstructorCourseDetailsPageData) pageResult.data;
    assertEquals(5, pageData.getInstructors().size());
    assertEquals("idOfTypicalCourse1", pageData.getCourseDetails().course.getId());
    assertEquals("Typical Course 1 with 2 Evals", pageData.getCourseDetails().course.getName());
    assertEquals(2, pageData.getCourseDetails().stats.teamsTotal);
    assertEquals(5, pageData.getCourseDetails().stats.studentsTotal);
    assertEquals(0, pageData.getCourseDetails().stats.unregisteredTotal);
    assertEquals(0, pageData.getCourseDetails().feedbackSessions.size());
    String expectedLogMessage = "TEAMMATESLOG|||instructorCourseDetailsPage|||instructorCourseDetailsPage|||true" + "|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1" + "|||instr1@course1.tmt|||instructorCourseDetails Page Load<br>Viewing Course " + "Details for Course <span class=\"bold\">[idOfTypicalCourse1]</span>" + "|||/page/instructorCourseDetailsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, pageAction.getLogMessage());
    ______TS("Masquerade mode, Course with no student");
    String adminUserId = "admin.user";
    gaeSimulation.loginAsAdmin(adminUserId);
    InstructorAttributes instructor4 = typicalBundle.instructors.get("instructor4");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor4.courseId };
    pageAction = getAction(addUserIdToParams(instructor4.googleId, submissionParams));
    pageResult = getShowPageResult(pageAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_DETAILS, false, "idOfInstructor4"), pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals(String.format(Const.StatusMessages.INSTRUCTOR_COURSE_EMPTY, pageResult.data.getInstructorCourseEnrollLink(instructor4.courseId)), pageResult.getStatusMessage());
    pageData = (InstructorCourseDetailsPageData) pageResult.data;
    assertEquals(1, pageData.getInstructors().size());
    assertEquals("idOfCourseNoEvals", pageData.getCourseDetails().course.getId());
    assertEquals("Typical Course 3 with 0 Evals", pageData.getCourseDetails().course.getName());
    assertEquals(0, pageData.getCourseDetails().stats.teamsTotal);
    assertEquals(0, pageData.getCourseDetails().stats.studentsTotal);
    assertEquals(0, pageData.getCourseDetails().stats.unregisteredTotal);
    assertEquals(0, pageData.getCourseDetails().feedbackSessions.size());
    expectedLogMessage = "TEAMMATESLOG|||instructorCourseDetailsPage|||instructorCourseDetailsPage|||true|||" + "Instructor(M)|||Instructor 4 of CourseNoEvals|||idOfInstructor4|||" + "instr4@coursenoevals.tmt|||instructorCourseDetails Page Load<br>Viewing Course " + "Details for Course <span class=\"bold\">[idOfCourseNoEvals]</span>|||" + "/page/instructorCourseDetailsPage";
    AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedLogMessage, pageAction.getLogMessage(), adminUserId);
    ______TS("HTML Table needed");
    instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1OfCourse1.googleId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED, "true" };
    pageAction = getAction(submissionParams);
    AjaxResult ajaxResult = this.getAjaxResult(pageAction);
    assertEquals(getPageResultDestination("", false, "idOfInstructor1OfCourse1"), ajaxResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals("", ajaxResult.getStatusMessage());
    pageData = (InstructorCourseDetailsPageData) ajaxResult.data;
    assertEquals("<table class=\"table table-bordered table-striped table-condensed\">" + "<tr>" + "<td>Course ID</td>" + "<td>idOfTypicalCourse1</td>" + "</tr>" + "<tr>" + "<td>Course Name</td>" + "<td>Typical Course 1 with 2 Evals</td>" + "</tr>" + "<tr>" + "<td>Section</td>" + "<td>Team</td>" + "<td>Full Name</td>" + "<td>Last Name</td>" + "<td>Status</td>" + "<td>Email</td>" + "</tr>" + "<tr>" + "<td>Section 1</td>" + "<td>Team 1.1&lt;&#x2f;td&gt;&lt;&#x2f;div&gt;&#39;&quot;</td>" + "<td>student1 In Course1&lt;&#x2f;td&gt;&lt;&#x2f;div&gt;&#39;&quot;</td>" + "<td>Course1&lt;&#x2f;td&gt;&lt;&#x2f;div&gt;&#39;&quot;</td>" + "<td>Joined</td>" + "<td>student1InCourse1@gmail.tmt</td>" + "</tr>" + "<tr>" + "<td>Section 1</td>" + "<td>Team 1.1&lt;&#x2f;td&gt;&lt;&#x2f;div&gt;&#39;&quot;</td>" + "<td>student2 In Course1</td>" + "<td>Course1</td>" + "<td>Joined</td>" + "<td>student2InCourse1@gmail.tmt</td>" + "</tr>" + "<tr>" + "<td>Section 1</td>" + "<td>Team 1.1&lt;&#x2f;td&gt;&lt;&#x2f;div&gt;&#39;&quot;</td>" + "<td>student3 In Course1</td>" + "<td>Course1</td>" + "<td>Joined</td>" + "<td>student3InCourse1@gmail.tmt</td>" + "</tr>" + "<tr>" + "<td>Section 1</td>" + "<td>Team 1.1&lt;&#x2f;td&gt;&lt;&#x2f;div&gt;&#39;&quot;</td>" + "<td>student4 In Course1</td>" + "<td>Course1</td>" + "<td>Joined</td>" + "<td>student4InCourse1@gmail.tmt</td>" + "</tr>" + "<tr>" + "<td>Section 2</td>" + "<td>Team 1.2</td>" + "<td>student5 In Course1</td>" + "<td>Course1</td>" + "<td>Joined</td>" + "<td>student5InCourse1@gmail.tmt</td>" + "</tr>" + "</table>", pageData.getStudentListHtmlTableAsString());
}
Also used : AjaxResult(teammates.ui.controller.AjaxResult) ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorCourseDetailsPageAction(teammates.ui.controller.InstructorCourseDetailsPageAction) InstructorCourseDetailsPageData(teammates.ui.pagedata.InstructorCourseDetailsPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 19 with ShowPageResult

use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.

the class InstructorCourseEditPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    String instructorId = instructor1OfCourse1.googleId;
    String courseId = instructor1OfCourse1.courseId;
    gaeSimulation.loginAsInstructor(instructorId);
    ______TS("Not enough parameters");
    verifyAssumptionFailure();
    ______TS("Typical case: open the course edit page");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId };
    InstructorCourseEditPageAction editAction = getAction(submissionParams);
    ShowPageResult pageResult = getShowPageResult(editAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_EDIT, false, "idOfInstructor1OfCourse1"), pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals("", pageResult.getStatusMessage());
    InstructorCourseEditPageData data = (InstructorCourseEditPageData) pageResult.data;
    assertEquals(CoursesLogic.inst().getCourse(courseId).toString(), data.getCourse().toString());
    verifySameInstructorList(InstructorsLogic.inst().getInstructorsForCourse(courseId), data.getInstructorPanelList());
    String expectedLogSegment = "instructorCourseEdit Page Load<br>" + "Editing information for Course <span class=\"bold\">[" + courseId + "]</span>";
    AssertHelper.assertContains(expectedLogSegment, editAction.getLogMessage());
    ______TS("Typical case: open the course edit page with instructor's email");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.INSTRUCTOR_EMAIL, "instr1@course1.tmt", Const.ParamsNames.COURSE_EDIT_MAIN_INDEX, "1" };
    editAction = getAction(submissionParams);
    pageResult = getShowPageResult(editAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_EDIT, false, "idOfInstructor1OfCourse1"), pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals("", pageResult.getStatusMessage());
    data = (InstructorCourseEditPageData) pageResult.data;
    assertEquals(CoursesLogic.inst().getCourse(courseId).toString(), data.getCourse().toString());
    assertEquals(1, data.getInstructorPanelList().size());
    expectedLogSegment = "instructorCourseEdit Page Load<br>" + "Editing information for Course <span class=\"bold\">[" + courseId + "]</span>";
    AssertHelper.assertContains(expectedLogSegment, editAction.getLogMessage());
    ______TS("Masquerade mode");
    InstructorAttributes instructor = typicalBundle.instructors.get("instructor4");
    instructorId = instructor.googleId;
    courseId = instructor.courseId;
    gaeSimulation.loginAsAdmin("admin.user");
    submissionParams = new String[] { Const.ParamsNames.USER_ID, instructorId, Const.ParamsNames.COURSE_ID, courseId };
    editAction = getAction(submissionParams);
    pageResult = getShowPageResult(editAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_EDIT, false, "idOfInstructor4"), pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals("", pageResult.getStatusMessage());
    data = (InstructorCourseEditPageData) pageResult.data;
    assertEquals(CoursesLogic.inst().getCourse(courseId).toString(), data.getCourse().toString());
    verifySameInstructorList(InstructorsLogic.inst().getInstructorsForCourse(courseId), data.getInstructorPanelList());
    expectedLogSegment = "instructorCourseEdit Page Load<br>" + "Editing information for Course <span class=\"bold\">[" + courseId + "]</span>";
    AssertHelper.assertContains(expectedLogSegment, editAction.getLogMessage());
    ______TS("Failure case: edit a non-existing course");
    CoursesLogic.inst().deleteCourseCascade(courseId);
    submissionParams = new String[] { Const.ParamsNames.USER_ID, instructorId, Const.ParamsNames.COURSE_ID, courseId };
    try {
        editAction = getAction(submissionParams);
        pageResult = getShowPageResult(editAction);
        signalFailureToDetectException();
    } catch (UnauthorizedAccessException e) {
        assertEquals("Trying to access system using a non-existent instructor entity", e.getMessage());
    }
}
Also used : InstructorCourseEditPageAction(teammates.ui.controller.InstructorCourseEditPageAction) ShowPageResult(teammates.ui.controller.ShowPageResult) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) InstructorCourseEditPageData(teammates.ui.pagedata.InstructorCourseEditPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 20 with ShowPageResult

use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.

the class AdminAccountManagementPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    ______TS("case: view admin acount management page");
    String[] submissionParams = new String[] {};
    final String adminUserId = "admin.user";
    gaeSimulation.loginAsAdmin(adminUserId);
    AdminAccountManagementPageAction action = getAction(submissionParams);
    ShowPageResult result = getShowPageResult(action);
    assertEquals("", result.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ViewURIs.ADMIN_ACCOUNT_MANAGEMENT, false, adminUserId), result.getDestinationWithParams());
    assertFalse(result.isError);
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) AdminAccountManagementPageAction(teammates.ui.controller.AdminAccountManagementPageAction) 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