Search in sources :

Example 1 with ShowPageResult

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

the class InstructorStudentRecordsPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    InstructorAttributes instructor = typicalBundle.instructors.get("instructor3OfCourse1");
    StudentAttributes student = typicalBundle.students.get("student2InCourse1");
    String instructorId = instructor.googleId;
    gaeSimulation.loginAsInstructor(instructorId);
    ______TS("Invalid parameters");
    // no params
    verifyAssumptionFailure();
    // null courseId
    String[] invalidParams = new String[] { Const.ParamsNames.STUDENT_EMAIL, student.email };
    verifyAssumptionFailure(invalidParams);
    // null student email
    invalidParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId };
    verifyAssumptionFailure(invalidParams);
    // student not in course
    String studentEmailOfStudent1InCourse2 = typicalBundle.students.get("student1InCourse2").email;
    invalidParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.STUDENT_EMAIL, studentEmailOfStudent1InCourse2 };
    RedirectResult redirect = getRedirectResult(getAction(invalidParams));
    AssertHelper.assertContains(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, redirect.getDestinationWithParams());
    AssertHelper.assertContains(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_RECORDS, redirect.getStatusMessage());
    ______TS("Typical case: student has some records and has profile");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.STUDENT_EMAIL, student.email };
    InstructorStudentRecordsPageAction a = getAction(submissionParams);
    ShowPageResult r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS, false, "idOfInstructor3"), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals("", r.getStatusMessage());
    InstructorStudentRecordsPageData actualData = (InstructorStudentRecordsPageData) r.data;
    StudentProfileAttributes expectedProfile = StudentProfileAttributes.builder(student.googleId).build();
    expectedProfile.modifiedDate = actualData.spa.modifiedDate;
    expectedProfile.pictureKey = actualData.spa.pictureKey;
    assertEquals(instructorId, actualData.account.googleId);
    assertEquals(instructor.courseId, actualData.getCourseId());
    assertEquals(6, actualData.getSessionNames().size());
    assertEquals(student.googleId, actualData.spa.googleId);
    String expectedLogMessage = "TEAMMATESLOG|||instructorStudentRecordsPage|||instructorStudentRecordsPage" + "|||true|||Instructor|||Instructor 3 of Course 1 and 2|||idOfInstructor3" + "|||instr3@course1n2.tmt|||instructorStudentRecords Page Load<br>" + "Viewing <span class=\"bold\">" + student.email + "'s</span> records " + "for Course <span class=\"bold\">[" + instructor.courseId + "]</span><br>" + "Number of sessions: 6<br>" + "Student Profile: " + SanitizationHelper.sanitizeForHtmlTag(expectedProfile.toString()) + "|||/page/instructorStudentRecordsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("Typical case: instructor cannot view sections");
    instructor = typicalBundle.instructors.get("helperOfCourse1");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.STUDENT_EMAIL, student.email };
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS, false, "idOfHelperOfCourse1"), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals("Normally, we would show the student’s profile here. " + "However, you do not have access to view this student's profile<br>" + "No records were found for this student", r.getStatusMessage());
    ______TS("Typical case: student has no records, no profiles");
    String instructor4Id = typicalBundle.instructors.get("instructor4").googleId;
    // re-login as another instructor for new test
    gaeSimulation.loginAsInstructor(instructor4Id);
    String courseIdWithNoSession = "idOfCourseNoEvals";
    StudentAttributes testStudent = createStudentInTypicalDataBundleForCourseWithNoSession();
    String[] submissionParamsWithNoSession = new String[] { Const.ParamsNames.COURSE_ID, courseIdWithNoSession, Const.ParamsNames.STUDENT_EMAIL, "emailTemp@gmail.tmt" };
    InstructorStudentRecordsPageAction aWithNoSession = getAction(submissionParamsWithNoSession);
    ShowPageResult rWithNoSession = getShowPageResult(aWithNoSession);
    List<String> expectedMessages = new ArrayList<>();
    expectedMessages.add("No records were found for this student");
    expectedMessages.add(Const.StatusMessages.STUDENT_NOT_JOINED_YET_FOR_RECORDS);
    AssertHelper.assertContains(expectedMessages, rWithNoSession.getStatusMessage());
    ______TS("Typical case: student has profile but no records");
    testStudent.googleId = "valid.no.sessions";
    StudentsLogic.inst().updateStudentCascadeWithoutDocument(testStudent.email, testStudent);
    logic.createAccount(testStudent.googleId, testStudent.name, false, testStudent.email, "valid institute");
    a = getAction(submissionParamsWithNoSession);
    r = getShowPageResult(a);
    AssertHelper.assertContains("No records were found for this student", r.getStatusMessage());
    ______TS("Typical case: student has profile with script injection");
    instructor = typicalBundle.instructors.get("instructor1OfTestingSanitizationCourse");
    instructorId = instructor.googleId;
    String studentId = "student1InTestingSanitizationCourse";
    student = typicalBundle.students.get(studentId);
    expectedProfile = typicalBundle.accounts.get(studentId).studentProfile;
    gaeSimulation.loginAsInstructor(instructorId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.STUDENT_EMAIL, student.email };
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    actualData = (InstructorStudentRecordsPageData) r.data;
    expectedProfile.modifiedDate = actualData.spa.modifiedDate;
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS, false, instructorId), r.getDestinationWithParams());
    assertFalse(r.isError);
    expectedLogMessage = "TEAMMATESLOG|||instructorStudentRecordsPage|||instructorStudentRecordsPage" + "|||true|||Instructor|||Instructor&lt;script&gt; alert(&#39;hi!&#39;); &lt;&#x2f;script&gt;" + "|||" + instructorId + "|||instructor1@sanitization.tmt|||instructorStudentRecords Page Load<br>" + "Viewing <span class=\"bold\">" + student.email + "'s</span> records " + "for Course <span class=\"bold\">[" + instructor.courseId + "]</span><br>" + "Number of sessions: 1<br>" + "Student Profile: " + SanitizationHelper.sanitizeForHtmlTag(expectedProfile.toString()) + "|||/page/instructorStudentRecordsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorStudentRecordsPageAction(teammates.ui.controller.InstructorStudentRecordsPageAction) RedirectResult(teammates.ui.controller.RedirectResult) ArrayList(java.util.ArrayList) InstructorStudentRecordsPageData(teammates.ui.pagedata.InstructorStudentRecordsPageData) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 2 with ShowPageResult

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

the class StudentCourseDetailsPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    String idOfCourseOfStudent = student1InCourse1.course;
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, idOfCourseOfStudent };
    ______TS("Invalid parameters");
    // parameters missing.
    verifyAssumptionFailure(new String[] {});
    ______TS("Typical case, student in the same course");
    StudentCourseDetailsPageAction pageAction = getAction(submissionParams);
    ShowPageResult pageResult = getShowPageResult(pageAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_COURSE_DETAILS, false, "student1InCourse1"), pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals("", pageResult.getStatusMessage());
    StudentCourseDetailsPageData pageData = (StudentCourseDetailsPageData) pageResult.data;
    assertEquals(student1InCourse1.course, pageData.getStudentCourseDetailsPanel().getCourseId());
    assertEquals(student1InCourse1.googleId, pageData.account.googleId);
    assertEquals(student1InCourse1.getIdentificationString(), pageData.student.getIdentificationString());
    assertEquals(student1InCourse1.team, pageData.getStudentCourseDetailsPanel().getStudentTeam());
    List<StudentAttributes> expectedStudentsList = StudentsLogic.inst().getStudentsForTeam(student1InCourse1.team, student1InCourse1.course);
    List<StudentAttributes> actualStudentsList = pageData.getStudentCourseDetailsPanel().getTeammates();
    AssertHelper.assertSameContentIgnoreOrder(expectedStudentsList, actualStudentsList);
    // assertEquals(StudentsLogic.inst().getStudentsForTeam(student1InCourse1.team, student1InCourse1), pageData.);
    // above comparison method failed, so use the one below
    List<InstructorAttributes> expectedInstructorsList = InstructorsLogic.inst().getInstructorsForCourse(student1InCourse1.course);
    List<InstructorAttributes> actualInstructorsList = pageData.getStudentCourseDetailsPanel().getInstructors();
    AssertHelper.assertSameContentIgnoreOrder(expectedInstructorsList, actualInstructorsList);
    String expectedLogMessage = "TEAMMATESLOG|||studentCourseDetailsPage|||studentCourseDetailsPage|||true|||" + "Student|||Student 1 in course 1|||student1InCourse1|||" + "student1InCourse1@gmail.tmt|||studentCourseDetails Page Load<br>" + "Viewing team details for <span class=\"bold\">[idOfTypicalCourse1] " + "Typical Course 1 with 2 Evals</span>|||/page/studentCourseDetailsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, pageAction.getLogMessage());
    ______TS("Typical case, the student is not in the course");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, "idOfTypicalCourse2" };
    StudentCourseDetailsPageAction redirectAction = getAction(submissionParams);
    RedirectResult redirectResult = this.getRedirectResult(redirectAction);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_HOME_PAGE, true, "student1InCourse1"), redirectResult.getDestinationWithParams());
    assertTrue(redirectResult.isError);
    assertEquals("You are not registered in the course idOfTypicalCourse2", redirectResult.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||studentCourseDetailsPage|||studentCourseDetailsPage|||true|||" + "Student|||Student 1 in course 1|||student1InCourse1|||" + "student1InCourse1@gmail.tmt|||studentCourseDetails Page Load<br>" + "Viewing team details for <span class=\"bold\">[idOfTypicalCourse1] " + "Typical Course 1 with 2 Evals</span>|||/page/studentCourseDetailsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, pageAction.getLogMessage());
    ______TS("Typical case, student contains data requiring sanitization");
    StudentAttributes studentTestingSanitization = typicalBundle.students.get("student1InTestingSanitizationCourse");
    gaeSimulation.loginAsStudent(studentTestingSanitization.googleId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, studentTestingSanitization.course };
    pageAction = getAction(submissionParams);
    pageResult = getShowPageResult(pageAction);
    assertEquals(Const.ViewURIs.STUDENT_COURSE_DETAILS + "?error=false&user=" + studentTestingSanitization.googleId, pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals("", pageResult.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||studentCourseDetailsPage|||studentCourseDetailsPage|||true|||" + "Student|||" + SanitizationHelper.sanitizeForHtml("Stud1<script> alert('hi!'); </script>") + "|||student1InTestingSanitizationCourse|||" + "normal@sanitization.tmt|||studentCourseDetails Page Load<br>" + "Viewing team details for <span class=\"bold\">[idOfTestingSanitizationCourse] " + SanitizationHelper.sanitizeForHtml("Testing<script> alert('hi!'); </script>") + "</span>|||/page/studentCourseDetailsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, pageAction.getLogMessage());
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) RedirectResult(teammates.ui.controller.RedirectResult) StudentCourseDetailsPageData(teammates.ui.pagedata.StudentCourseDetailsPageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) StudentCourseDetailsPageAction(teammates.ui.controller.StudentCourseDetailsPageAction) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 3 with ShowPageResult

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

the class StudentCourseJoinActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    StudentCourseJoinAction joinAction;
    RedirectResult redirectResult;
    String[] submissionParams;
    StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    StudentsDb studentsDb = new StudentsDb();
    student1InCourse1 = studentsDb.getStudentForGoogleId(student1InCourse1.course, student1InCourse1.googleId);
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    ______TS("not enough parameters");
    verifyAssumptionFailure();
    ______TS("typical case");
    String idOfNewStudent = "idOfNewStudent";
    StudentAttributes newStudentData = StudentAttributes.builder(student1InCourse1.course, "nameOfNewStudent", "newStudent@course1.com").withSection(student1InCourse1.section).withTeam(student1InCourse1.team).withComments("This is a new student").build();
    studentsDb.createEntity(newStudentData);
    gaeSimulation.loginUser(idOfNewStudent);
    String newStudentKey = StringHelper.encrypt(studentsDb.getStudentForEmail(newStudentData.course, newStudentData.email).key);
    /*
         * Reason why get student attributes for student just added again from
         * StudentsDb:below test needs the student's key, which is auto
         * generated when creating the student instance.So the reg key needs to
         * be obtained by calling the getter from logic to retrieve again
         */
    submissionParams = new String[] { Const.ParamsNames.REGKEY, newStudentKey, Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_PROFILE_PAGE };
    joinAction = getAction(submissionParams);
    ShowPageResult pageResult = getShowPageResult(joinAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_COURSE_JOIN_CONFIRMATION, false, idOfNewStudent), pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_COURSE_JOIN_AUTHENTICATED, newStudentKey, Const.ActionURIs.STUDENT_PROFILE_PAGE), ((StudentCourseJoinConfirmationPageData) pageResult.data).getConfirmUrl());
    assertEquals("", pageResult.getStatusMessage());
    ______TS("skip confirmation");
    gaeSimulation.logoutUser();
    submissionParams = new String[] { Const.ParamsNames.REGKEY, newStudentKey, Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_PROFILE_PAGE, Const.ParamsNames.STUDENT_EMAIL, newStudentData.email, Const.ParamsNames.COURSE_ID, newStudentData.course };
    joinAction = getAction(submissionParams);
    redirectResult = getRedirectResult(joinAction);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_COURSE_JOIN_AUTHENTICATED, newStudentKey, Const.ActionURIs.STUDENT_PROFILE_PAGE.replace("/", "%2F"), false), redirectResult.getDestinationWithParams());
    assertFalse(redirectResult.isError);
    // delete the new student
    studentsDb.deleteStudentWithoutDocument(newStudentData.course, newStudentData.email);
    ______TS("Non-existent student attempting to join course displays error");
    gaeSimulation.loginUser(idOfNewStudent);
    submissionParams = new String[] { Const.ParamsNames.REGKEY, newStudentKey, Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_PROFILE_PAGE, Const.ParamsNames.STUDENT_EMAIL, newStudentData.email, Const.ParamsNames.COURSE_ID, newStudentData.course };
    joinAction = getAction(submissionParams);
    redirectResult = getRedirectResult(joinAction);
    assertEquals(Const.ActionURIs.STUDENT_HOME_PAGE, redirectResult.destination);
    assertEquals(String.format(Const.StatusMessages.NON_EXISTENT_STUDENT_ATTEMPTING_TO_JOIN_COURSE, newStudentData.course), redirectResult.getStatusMessage());
    assertEquals("warning", redirectResult.getStatusMessageColor());
    assertTrue(redirectResult.isError);
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) RedirectResult(teammates.ui.controller.RedirectResult) StudentCourseJoinAction(teammates.ui.controller.StudentCourseJoinAction) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) StudentsDb(teammates.storage.api.StudentsDb) Test(org.testng.annotations.Test)

Example 4 with ShowPageResult

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

the class StudentHomePageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    String unregUserId = "unreg.user";
    StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    String studentId = student1InCourse1.googleId;
    String adminUserId = "admin.user";
    String[] submissionParams = new String[] {};
    ______TS("unregistered student");
    gaeSimulation.loginUser(unregUserId);
    StudentHomePageAction a = getAction(submissionParams);
    ShowPageResult r = getShowPageResult(a);
    AssertHelper.assertContainsRegex(getPageResultDestination(Const.ViewURIs.STUDENT_HOME, false, "unreg.user"), r.getDestinationWithParams());
    assertFalse(r.isError);
    AssertHelper.assertContainsRegex("Ooops! Your Google account is not known to TEAMMATES{*}use the new Gmail address.", r.getStatusMessage());
    StudentHomePageData data = (StudentHomePageData) r.data;
    assertEquals(0, data.getCourseTables().size());
    String expectedLogMessage = "TEAMMATESLOG|||studentHomePage|||studentHomePage" + "|||true|||Unregistered|||Unknown|||unreg.user|||Unknown" + "|||Servlet Action Failure :Student with Google ID " + "unreg.user does not exist|||/page/studentHomePage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("registered student with no courses");
    // Note: this can happen only if the course was deleted after the student joined it.
    // The 'welcome stranger' response is not really appropriate for this situation, but
    // we keep it because the situation is rare and not worth extra coding.
    // Create a student account without courses
    AccountAttributes studentWithoutCourses = AccountAttributes.builder().withGoogleId("googleId.without.courses").withName("Student Without Courses").withEmail("googleId.without.courses@email.tmt").withInstitute("TEAMMATES Test Institute 5").withIsInstructor(false).withDefaultStudentProfileAttributes("googleId.without.courses").build();
    AccountsDb accountsDb = new AccountsDb();
    accountsDb.createAccount(studentWithoutCourses);
    assertNotNull(accountsDb.getAccount(studentWithoutCourses.googleId));
    gaeSimulation.loginUser(studentWithoutCourses.googleId);
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    AssertHelper.assertContainsRegex(getPageResultDestination(Const.ViewURIs.STUDENT_HOME, false, studentWithoutCourses.googleId), r.getDestinationWithParams());
    assertFalse(r.isError);
    AssertHelper.assertContainsRegex("Ooops! Your Google account is not known to TEAMMATES{*}use the new Gmail address.", r.getStatusMessage());
    data = (StudentHomePageData) r.data;
    assertEquals(0, data.getCourseTables().size());
    expectedLogMessage = "TEAMMATESLOG|||studentHomePage|||studentHomePage|||true" + "|||Unregistered|||Student Without Courses|||googleId.without.courses" + "|||googleId.without.courses@email.tmt|||Servlet Action Failure " + ":Student with Google ID googleId.without.courses does not exist" + "|||/page/studentHomePage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("typical user, masquerade mode");
    gaeSimulation.loginAsAdmin(adminUserId);
    studentId = typicalBundle.students.get("student2InCourse2").googleId;
    // Access page in masquerade mode
    a = getAction(addUserIdToParams(studentId, submissionParams));
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_HOME, false, studentId), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals("", r.getStatusMessage());
    data = (StudentHomePageData) r.data;
    assertEquals(2, data.getCourseTables().size());
    expectedLogMessage = "TEAMMATESLOG|||studentHomePage|||studentHomePage|||true" + "|||Student(M)|||Student in two courses|||student2InCourse1" + "|||student2InCourse1@gmail.tmt" + "|||studentHome Page Load<br>Total courses: 2" + "|||/page/studentHomePage";
    AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedLogMessage, a.getLogMessage(), adminUserId);
    ______TS("New student with no existing course, course join affected by eventual consistency");
    submissionParams = new String[] { Const.ParamsNames.CHECK_PERSISTENCE_COURSE, "idOfTypicalCourse1" };
    studentId = "newStudent";
    gaeSimulation.loginUser(studentId);
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    data = (StudentHomePageData) r.data;
    assertEquals(1, data.getCourseTables().size());
    assertEquals("idOfTypicalCourse1", data.getCourseTables().get(0).getCourseId());
    ______TS("Registered student with existing courses, course join affected by eventual consistency");
    submissionParams = new String[] { Const.ParamsNames.CHECK_PERSISTENCE_COURSE, "idOfTypicalCourse2" };
    student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    studentId = student1InCourse1.googleId;
    gaeSimulation.loginUser(studentId);
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    data = (StudentHomePageData) r.data;
    assertEquals(2, data.getCourseTables().size());
    assertEquals("idOfTypicalCourse2", data.getCourseTables().get(1).getCourseId());
    ______TS("Just joined course, course join not affected by eventual consistency and appears in list");
    submissionParams = new String[] { Const.ParamsNames.CHECK_PERSISTENCE_COURSE, "idOfTypicalCourse1" };
    student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    studentId = student1InCourse1.googleId;
    gaeSimulation.loginUser(studentId);
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    data = (StudentHomePageData) r.data;
    assertEquals(1, data.getCourseTables().size());
    // Delete additional sessions that were created
    CoursesLogic.inst().deleteCourseCascade("typicalCourse2");
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) AccountsDb(teammates.storage.api.AccountsDb) StudentHomePageAction(teammates.ui.controller.StudentHomePageAction) StudentHomePageData(teammates.ui.pagedata.StudentHomePageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 5 with ShowPageResult

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

the class StudentProfilePageActionTest method testActionSuccess.

private void testActionSuccess(AccountAttributes student, String caseDescription) {
    gaeSimulation.loginAsStudent(student.googleId);
    ______TS(caseDescription);
    String[] submissionParams = new String[] {};
    StudentProfilePageAction action = getAction(submissionParams);
    ShowPageResult result = getShowPageResult(action);
    AssertHelper.assertContains(getPageResultDestination(Const.ViewURIs.STUDENT_PROFILE_PAGE, false, student.googleId), result.getDestinationWithParams());
    assertFalse(result.isError);
    assertEquals("", result.getStatusMessage());
    verifyAccountsAreSame(student, result);
    verifyLogMessage(student, action, false);
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) StudentProfilePageAction(teammates.ui.controller.StudentProfilePageAction)

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