Search in sources :

Example 1 with StudentCourseDetailsPageAction

use of teammates.ui.controller.StudentCourseDetailsPageAction 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 2 with StudentCourseDetailsPageAction

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

the class StudentCourseDetailsPageActionTest method testTeamMemberDetailsOnViewTeamPage.

@Test
public void testTeamMemberDetailsOnViewTeamPage() {
    AccountAttributes student = typicalBundle.accounts.get("student1InCourse1");
    String[] submissionParams = createValidParamsForProfile();
    StudentProfileAttributes expectedProfile = getProfileAttributesFrom(student.googleId, submissionParams);
    gaeSimulation.loginAsStudent(student.googleId);
    // adding profile picture for student1InCourse1
    StudentProfileEditSaveAction action = getStudentProfileEditSaveAction(submissionParams);
    RedirectResult result = getRedirectResult(action);
    expectedProfile.googleId = student.googleId;
    assertFalse(result.isError);
    StudentAttributes student1 = typicalBundle.students.get("student1InCourse1");
    gaeSimulation.logoutUser();
    gaeSimulation.loginAsStudent(typicalBundle.accounts.get("student2InCourse1").googleId);
    String[] submissionParam = new String[] { Const.ParamsNames.COURSE_ID, student1.course };
    StudentCourseDetailsPageAction pageAction = getAction(submissionParam);
    ShowPageResult pageResult = getShowPageResult(pageAction);
    StudentCourseDetailsPageData pageData = (StudentCourseDetailsPageData) pageResult.data;
    List<StudentAttributes> actualStudentsList = pageData.getStudentCourseDetailsPanel().getTeammates();
    boolean isStudentDisplayedOnViewTeam = false;
    for (StudentAttributes stud : actualStudentsList) {
        if (student1.email.equals(stud.email) && student1.name.equals(stud.name) && student1.getPublicProfilePictureUrl().equals(stud.getPublicProfilePictureUrl())) {
            isStudentDisplayedOnViewTeam = true;
        }
    }
    assertTrue(isStudentDisplayedOnViewTeam);
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) ShowPageResult(teammates.ui.controller.ShowPageResult) RedirectResult(teammates.ui.controller.RedirectResult) StudentProfileEditSaveAction(teammates.ui.controller.StudentProfileEditSaveAction) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) StudentCourseDetailsPageData(teammates.ui.pagedata.StudentCourseDetailsPageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) StudentCourseDetailsPageAction(teammates.ui.controller.StudentCourseDetailsPageAction) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)2 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)2 RedirectResult (teammates.ui.controller.RedirectResult)2 ShowPageResult (teammates.ui.controller.ShowPageResult)2 StudentCourseDetailsPageAction (teammates.ui.controller.StudentCourseDetailsPageAction)2 StudentCourseDetailsPageData (teammates.ui.pagedata.StudentCourseDetailsPageData)2 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)1 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)1 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)1 StudentProfileEditSaveAction (teammates.ui.controller.StudentProfileEditSaveAction)1