use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class InstructorCourseEnrollSaveActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
String enrollString = "";
InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
String instructorId = instructor1OfCourse1.googleId;
String courseId = instructor1OfCourse1.courseId;
gaeSimulation.loginAsInstructor(instructorId);
______TS("Typical case: add and edit students for non-empty course");
enrollString = "Section | Team | Name | Email | Comment" + System.lineSeparator() + // A new student
"Section 3 \t Team 1\tJean Wong\tjean@email.tmt\tExchange student" + System.lineSeparator() + // A new student with extra spaces in the team and name
"Section 3 \t Team 1\tstudent with extra spaces \t" + "studentWithExtraSpaces@gmail.tmt\t" + System.lineSeparator() + // A student to be modified
"Section 2 \t Team 1.3\tstudent1 In Course1</td></div>'\"\tstudent1InCourse1@gmail.tmt\t" + "New comment added" + System.lineSeparator() + // An existing student with no modification
"Section 1 \t Team 1.1</td></div>'\"\tstudent2 In Course1\tstudent2InCourse1@gmail.tmt\t" + System.lineSeparator() + // An existing student, now with extra spaces, should cause no modification
"Section 1 \t Team 1.1</td></div>'\"\tstudent3 In Course1 \tstudent3InCourse1@gmail.tmt\t";
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.STUDENTS_ENROLLMENT_INFO, enrollString };
InstructorCourseEnrollSaveAction enrollAction = getAction(submissionParams);
ShowPageResult pageResult = getShowPageResult(enrollAction);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL_RESULT, false, "idOfInstructor1OfCourse1"), pageResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals("", pageResult.getStatusMessage());
// there are 6 sessions in this course
verifySpecifiedTasksAdded(enrollAction, Const.TaskQueue.FEEDBACK_RESPONSE_ADJUSTMENT_QUEUE_NAME, 6);
List<TaskWrapper> tasksAdded = enrollAction.getTaskQueuer().getTasksAdded();
for (TaskWrapper task : tasksAdded) {
Map<String, String[]> paramMap = task.getParamMap();
assertEquals(courseId, paramMap.get(ParamsNames.COURSE_ID)[0]);
}
InstructorCourseEnrollResultPageData pageData = (InstructorCourseEnrollResultPageData) pageResult.data;
assertEquals(courseId, pageData.getCourseId());
StudentAttributes newStudent = StudentAttributes.builder(courseId, "Jean Wong", "jean@email.tmt").withSection("Section 3").withTeam("Team 1").withComments("Exchange student").withGoogleId("jean").build();
newStudent.updateStatus = StudentUpdateStatus.NEW;
verifyStudentEnrollmentStatus(newStudent, pageData.getEnrollResultPanelList());
StudentAttributes newStudentWithExtraSpaces = StudentAttributes.builder(courseId, "student with extra spaces", "studentWithExtraSpaces@gmail.tmt").withSection("Section 3").withTeam("Team 1").withComments("").withGoogleId("student").build();
newStudentWithExtraSpaces.updateStatus = StudentUpdateStatus.NEW;
verifyStudentEnrollmentStatus(newStudentWithExtraSpaces, pageData.getEnrollResultPanelList());
StudentAttributes modifiedStudent = typicalBundle.students.get("student1InCourse1");
modifiedStudent.comments = "New comment added";
modifiedStudent.section = "Section 2";
modifiedStudent.team = "Team 1.3";
modifiedStudent.updateStatus = StudentUpdateStatus.MODIFIED;
verifyStudentEnrollmentStatus(modifiedStudent, pageData.getEnrollResultPanelList());
StudentAttributes unmodifiedStudent = typicalBundle.students.get("student2InCourse1");
unmodifiedStudent.updateStatus = StudentUpdateStatus.UNMODIFIED;
verifyStudentEnrollmentStatus(unmodifiedStudent, pageData.getEnrollResultPanelList());
StudentAttributes unmodifiedStudentWithExtraSpaces = typicalBundle.students.get("student3InCourse1");
unmodifiedStudentWithExtraSpaces.updateStatus = StudentUpdateStatus.UNMODIFIED;
verifyStudentEnrollmentStatus(unmodifiedStudentWithExtraSpaces, pageData.getEnrollResultPanelList());
String expectedLogSegment = "Students Enrolled in Course <span class=\"bold\">[" + courseId + "]" + ":</span><br>" + SanitizationHelper.sanitizeForHtml(enrollString).replace("\n", "<br>");
AssertHelper.assertContains(expectedLogSegment, enrollAction.getLogMessage());
______TS("Masquerade mode, enrollment into empty course");
if (CoursesLogic.inst().isCoursePresent("new-course")) {
CoursesLogic.inst().deleteCourseCascade("new-course");
}
courseId = "new-course";
CoursesLogic.inst().createCourseAndInstructor(instructorId, courseId, "New course", "UTC");
gaeSimulation.loginAsAdmin("admin.user");
String headerRow = "Name\tEmail\tTeam\tComment";
String studentsInfo = "Jean Wong\tjean@email.tmt\tTeam 1\tExchange student" + System.lineSeparator() + "James Tan\tjames@email.tmt\tTeam 2\t";
enrollString = headerRow + System.lineSeparator() + studentsInfo;
submissionParams = new String[] { Const.ParamsNames.USER_ID, instructorId, Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.STUDENTS_ENROLLMENT_INFO, enrollString };
enrollAction = getAction(submissionParams);
pageResult = getShowPageResult(enrollAction);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL_RESULT, false, "idOfInstructor1OfCourse1"), pageResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals("", pageResult.getStatusMessage());
verifyNoTasksAdded(enrollAction);
pageData = (InstructorCourseEnrollResultPageData) pageResult.data;
assertEquals(courseId, pageData.getCourseId());
StudentAttributes student1 = StudentAttributes.builder(courseId, "Jean Wong", "jean@email.tmt").withSection("None").withTeam("Team 1").withComments("Exchange student").withGoogleId("jean").build();
student1.updateStatus = StudentUpdateStatus.NEW;
verifyStudentEnrollmentStatus(student1, pageData.getEnrollResultPanelList());
StudentAttributes student2 = StudentAttributes.builder(courseId, "James Tan", "james@email.tmt").withSection("None").withTeam("Team 2").withComments("").withGoogleId("james").build();
student2.updateStatus = StudentUpdateStatus.NEW;
verifyStudentEnrollmentStatus(student2, pageData.getEnrollResultPanelList());
expectedLogSegment = "Students Enrolled in Course <span class=\"bold\">[" + courseId + "]:</span>" + "<br>" + enrollString.replace("\n", "<br>");
AssertHelper.assertContains(expectedLogSegment, enrollAction.getLogMessage());
______TS("Failure case: enrollment failed due to invalid lines");
gaeSimulation.loginAsInstructor(instructorId);
String studentWithoutEnoughParam = "Team 1\tStudentWithNoEmailInput";
String studentWithInvalidEmail = "Team 2\tBenjamin Tan\tinvalid.email.tmt";
String invalidEmail = "invalid.email.tmt";
enrollString = "Team | Name | Email" + System.lineSeparator() + studentWithoutEnoughParam + System.lineSeparator() + studentWithInvalidEmail;
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.STUDENTS_ENROLLMENT_INFO, enrollString };
enrollAction = getAction(submissionParams);
pageResult = getShowPageResult(enrollAction);
assertEquals(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL, pageResult.destination);
assertTrue(pageResult.isError);
String expectedStatusMessage = "<p>" + "<span class=\"bold\">Problem in line : " + "<span class=\"invalidLine\">" + SanitizationHelper.sanitizeForHtml(studentWithoutEnoughParam) + "</span>" + "</span>" + "<br>" + "<span class=\"problemDetail\">• " + StudentAttributesFactory.ERROR_ENROLL_LINE_TOOFEWPARTS + "</span>" + "</p>" + "<br>" + "<p>" + "<span class=\"bold\">Problem in line : " + "<span class=\"invalidLine\">" + SanitizationHelper.sanitizeForHtml(studentWithInvalidEmail) + "</span>" + "</span>" + "<br>" + "<span class=\"problemDetail\">• " + SanitizationHelper.sanitizeForHtml(getPopulatedErrorMessage(FieldValidator.EMAIL_ERROR_MESSAGE, invalidEmail, FieldValidator.EMAIL_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, FieldValidator.EMAIL_MAX_LENGTH)) + "</span>" + "</p>";
assertEquals(expectedStatusMessage, pageResult.getStatusMessage());
verifyNoTasksAdded(enrollAction);
InstructorCourseEnrollPageData enrollPageData = (InstructorCourseEnrollPageData) pageResult.data;
assertEquals(courseId, enrollPageData.getCourseId());
assertEquals(enrollString, enrollPageData.getEnrollStudents());
expectedLogSegment = expectedStatusMessage + "<br>Enrollment string entered by user:<br>" + enrollString.replace("\n", "<br>");
AssertHelper.assertContains(expectedLogSegment, enrollAction.getLogMessage());
______TS("Boundary test for size limit per enrollment");
// can enroll, if within the size limit
StringBuilder enrollStringBuilder = new StringBuilder(200);
enrollStringBuilder.append("Section\tTeam\tName\tEmail");
for (int i = 0; i < Const.SIZE_LIMIT_PER_ENROLLMENT; i++) {
enrollStringBuilder.append(System.lineSeparator()).append("section" + i + "\tteam" + i + "\tname" + i + "\temail" + i + "@nonexistemail.nonexist");
}
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.STUDENTS_ENROLLMENT_INFO, enrollStringBuilder.toString() };
enrollAction = getAction(submissionParams);
pageResult = getShowPageResult(enrollAction);
assertFalse(pageResult.isError);
assertEquals("", pageResult.getStatusMessage());
verifyNoTasksAdded(enrollAction);
// fail to enroll, if exceed the range
enrollStringBuilder.append(System.lineSeparator()).append("section" + Const.SIZE_LIMIT_PER_ENROLLMENT + "\tteam" + Const.SIZE_LIMIT_PER_ENROLLMENT + "\tname" + Const.SIZE_LIMIT_PER_ENROLLMENT + "\temail" + Const.SIZE_LIMIT_PER_ENROLLMENT + "@nonexistemail.nonexist");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.STUDENTS_ENROLLMENT_INFO, enrollStringBuilder.toString() };
enrollAction = getAction(submissionParams);
pageResult = getShowPageResult(enrollAction);
assertEquals(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL, pageResult.destination);
assertTrue(pageResult.isError);
assertEquals(Const.StatusMessages.QUOTA_PER_ENROLLMENT_EXCEED, pageResult.getStatusMessage());
verifyNoTasksAdded(enrollAction);
______TS("Failure case: empty input");
enrollString = "";
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.STUDENTS_ENROLLMENT_INFO, enrollString };
enrollAction = getAction(submissionParams);
pageResult = getShowPageResult(enrollAction);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL, true, "idOfInstructor1OfCourse1"), pageResult.getDestinationWithParams());
assertTrue(pageResult.isError);
assertEquals(Const.StatusMessages.ENROLL_LINE_EMPTY, pageResult.getStatusMessage());
verifyNoTasksAdded(enrollAction);
enrollPageData = (InstructorCourseEnrollPageData) pageResult.data;
assertEquals(courseId, enrollPageData.getCourseId());
assertEquals(enrollString, enrollPageData.getEnrollStudents());
AssertHelper.assertContains(Const.StatusMessages.ENROLL_LINE_EMPTY, enrollAction.getLogMessage());
CoursesLogic.inst().deleteCourseCascade("new-course");
StudentsLogic.inst().deleteStudentsForCourseWithoutDocument(instructor1OfCourse1.courseId);
}
use of teammates.ui.controller.ShowPageResult 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);
}
use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class StudentFeedbackResultsPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
FeedbackSessionAttributes session1InCourse1 = typicalBundle.feedbackSessions.get("session1InCourse1");
FeedbackSessionAttributes emptySession = typicalBundle.feedbackSessions.get("empty.session");
FeedbackSessionAttributes closedSession = typicalBundle.feedbackSessions.get("closedSession");
FeedbackSessionAttributes gracePeriodSession = typicalBundle.feedbackSessions.get("gracePeriodSession");
session1InCourse1.setResultsVisibleFromTime(session1InCourse1.getStartTime());
FeedbackSessionsLogic.inst().updateFeedbackSession(session1InCourse1);
StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
gaeSimulation.loginAsStudent(student1InCourse1.googleId);
______TS("invalid params");
String[] submissionParams = new String[] {};
verifyRedirectTo(Const.ActionURIs.STUDENT_HOME_PAGE, submissionParams);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session1InCourse1.getCourseId() };
verifyRedirectTo(Const.ActionURIs.STUDENT_HOME_PAGE, submissionParams);
submissionParams = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName() };
verifyRedirectTo(Const.ActionURIs.STUDENT_HOME_PAGE, submissionParams);
______TS("results not viewable when not published");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session1InCourse1.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName() };
FeedbackSessionsLogic.inst().unpublishFeedbackSession(session1InCourse1);
StudentFeedbackResultsPageAction pageAction = getAction(submissionParams);
try {
getShowPageResult(pageAction);
} catch (UnauthorizedAccessException exception) {
assertEquals("This feedback session is not yet visible.", exception.getMessage());
}
______TS("cannot access a private session");
FeedbackSessionsLogic.inst().publishFeedbackSession(session1InCourse1);
session1InCourse1.setFeedbackSessionType(FeedbackSessionType.PRIVATE);
FeedbackSessionsLogic.inst().updateFeedbackSession(session1InCourse1);
pageAction = getAction(submissionParams);
try {
getShowPageResult(pageAction);
} catch (UnauthorizedAccessException exception) {
assertEquals("Feedback session [First feedback session] is not accessible to student " + "[" + student1InCourse1.email + "]", exception.getMessage());
}
session1InCourse1.setFeedbackSessionType(FeedbackSessionType.STANDARD);
FeedbackSessionsLogic.inst().updateFeedbackSession(session1InCourse1);
______TS("access a empty session");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, emptySession.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, emptySession.getFeedbackSessionName() };
pageAction = getAction(submissionParams);
ShowPageResult pageResult = getShowPageResult(pageAction);
assertEquals(Const.ViewURIs.STUDENT_FEEDBACK_RESULTS, pageResult.destination);
assertFalse(pageResult.isError);
assertEquals("You have not received any new feedback but you may review your own submissions below.", pageResult.getStatusMessage());
______TS("access a gracePeriodSession session");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, gracePeriodSession.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, gracePeriodSession.getFeedbackSessionName() };
pageAction = getAction(submissionParams);
try {
pageResult = getShowPageResult(pageAction);
} catch (UnauthorizedAccessException exception) {
assertEquals("This feedback session is not yet visible.", exception.getMessage());
}
______TS("access a closed session");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, closedSession.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, closedSession.getFeedbackSessionName() };
pageAction = getAction(submissionParams);
try {
pageResult = getShowPageResult(pageAction);
} catch (UnauthorizedAccessException exception) {
assertEquals("This feedback session is not yet visible.", exception.getMessage());
}
______TS("access a non-existent session");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session1InCourse1.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, "non-existent session" };
pageAction = getAction(submissionParams);
try {
pageResult = getShowPageResult(pageAction);
} catch (UnauthorizedAccessException exception) {
assertEquals("Trying to access system using a non-existent feedback session entity", exception.getMessage());
}
______TS("typical case");
removeAndRestoreTypicalDataBundle();
session1InCourse1 = FeedbackSessionsLogic.inst().getFeedbackSession(session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId());
FeedbackSessionsLogic.inst().publishFeedbackSession(session1InCourse1);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session1InCourse1.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName() };
pageAction = getAction(submissionParams);
pageResult = getShowPageResult(pageAction);
assertEquals(Const.ViewURIs.STUDENT_FEEDBACK_RESULTS, pageResult.destination);
assertFalse(pageResult.isError);
assertEquals("You have received feedback from others. Please see below.", pageResult.getStatusMessage());
StudentFeedbackResultsPageData pageData = (StudentFeedbackResultsPageData) pageResult.data;
// databundle time changed here because publishing sets resultsVisibleTime to now.
typicalBundle.feedbackSessions.get("session1InCourse1").setResultsVisibleFromTime(Instant.now());
/*
* The above test can fail if the time elapsed between pageData... and dataBundle...
* changes the time recorded by dataBundle up to the precision of seconds.
* To solve that, verify that the time elapsed is less than one second (or else the test
* fails after all) and if it does, change the value in the dataBundle to match.
*/
Instant pageDataResultsVisibleFromTime = pageData.getBundle().feedbackSession.getResultsVisibleFromTime();
Instant dataBundleResultsVisibleFromTime = typicalBundle.feedbackSessions.get("session1InCourse1").getResultsVisibleFromTime();
Duration difference = Duration.between(pageDataResultsVisibleFromTime, dataBundleResultsVisibleFromTime);
long toleranceTimeInMs = 1000;
if (difference.compareTo(Duration.ofMillis(toleranceTimeInMs)) < 0) {
// change to the value that will never make the test fail
typicalBundle.feedbackSessions.get("session1InCourse1").setResultsVisibleFromTime(pageData.getBundle().feedbackSession.getResultsVisibleFromTime());
}
List<FeedbackSessionAttributes> expectedInfoList = new ArrayList<>();
List<FeedbackSessionAttributes> actualInfoList = new ArrayList<>();
expectedInfoList.add(typicalBundle.feedbackSessions.get("session1InCourse1"));
actualInfoList.add(pageData.getBundle().feedbackSession);
AssertHelper.assertSameContentIgnoreOrder(expectedInfoList, actualInfoList);
assertEquals(student1InCourse1.googleId, pageData.account.googleId);
assertEquals(student1InCourse1.getIdentificationString(), pageData.student.getIdentificationString());
}
use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class StudentFeedbackSubmissionEditPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
StudentAttributes unregStudent = StudentAttributes.builder("idOfTypicalCourse1", "Unreg Student", "unreg@stud.ent").withSection("1").withTeam("Team0.1").withComments("asdf").build();
gaeSimulation.loginAsStudent(student1InCourse1.googleId);
______TS("not enough parameters");
verifyAssumptionFailure();
FeedbackSessionAttributes session1InCourse1 = dataBundle.feedbackSessions.get("session1InCourse1");
String[] submissionParams = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName(), Const.ParamsNames.USER_ID, student1InCourse1.googleId };
verifyAssumptionFailure(submissionParams);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session1InCourse1.getCourseId(), Const.ParamsNames.USER_ID, student1InCourse1.googleId };
verifyAssumptionFailure(submissionParams);
______TS("Test null feedback session name parameter");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session1InCourse1.getCourseId(), Const.ParamsNames.USER_ID, student1InCourse1.googleId };
StudentFeedbackSubmissionEditPageAction pageAction;
RedirectResult redirectResult;
try {
pageAction = getAction(submissionParams);
redirectResult = getRedirectResult(pageAction);
signalFailureToDetectException("Did not detect that parameters are null.");
} catch (NullPostParameterException e) {
assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.FEEDBACK_SESSION_NAME), e.getMessage());
}
______TS("Test null course id parameter");
submissionParams = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName(), Const.ParamsNames.USER_ID, student1InCourse1.googleId };
try {
pageAction = getAction(submissionParams);
redirectResult = getRedirectResult(pageAction);
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());
}
______TS("typical success case for registered student");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session1InCourse1.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName(), Const.ParamsNames.USER_ID, student1InCourse1.googleId };
pageAction = getAction(submissionParams);
ShowPageResult pageResult = getShowPageResult(pageAction);
assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, false, student1InCourse1.googleId), pageResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, pageResult.getStatusMessage());
______TS("feedbacksession deleted");
FeedbackSessionsDb feedbackSessionsDb = new FeedbackSessionsDb();
feedbackSessionsDb.deleteEntity(session1InCourse1);
String[] params = new String[] { Const.ParamsNames.COURSE_ID, session1InCourse1.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName(), Const.ParamsNames.USER_ID, student1InCourse1.googleId };
pageAction = getAction(params);
redirectResult = getRedirectResult(pageAction);
assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_HOME_PAGE, false, "student1InCourse1"), redirectResult.getDestinationWithParams());
assertFalse(redirectResult.isError);
assertEquals(Const.StatusMessages.FEEDBACK_SESSION_DELETED_NO_ACCESS, redirectResult.getStatusMessage());
// for unregistered student
StudentsDb stDb = new StudentsDb();
stDb.createStudentWithoutDocument(unregStudent);
unregStudent = stDb.getStudentForEmail("idOfTypicalCourse1", "unreg@stud.ent");
gaeSimulation.logoutUser();
params = new String[] { Const.ParamsNames.COURSE_ID, session1InCourse1.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName(), Const.ParamsNames.REGKEY, StringHelper.encrypt(unregStudent.key), Const.ParamsNames.STUDENT_EMAIL, unregStudent.email };
try {
pageAction = getAction(params);
AssertHelper.assertLogMessageEqualsForUnregisteredStudentUser("TEAMMATESLOG|||studentFeedbackSubmissionEditPage|||studentFeedbackSubmissionEditPage|||" + "true|||Unregistered:idOfTypicalCourse1|||Unreg Student|||Unknown|||unreg@stud.ent|||" + "Unknown|||/page/studentFeedbackSubmissionEditPage", pageAction.getLogMessage(), unregStudent.email, unregStudent.course);
redirectResult = getRedirectResult(pageAction);
signalFailureToDetectException("EntityDoesNotExist");
} catch (EntityNotFoundException enfe) {
assertEquals("unregistered student trying to access non-existent session", enfe.getMessage());
}
stDb.deleteStudent("idOfTypicalCourse1", "unreg@stud.ent");
______TS("typical success case for unregistered student");
gaeSimulation.loginAsStudent(student1InCourse1.googleId);
removeAndRestoreTypicalDataBundle();
session1InCourse1 = dataBundle.feedbackSessions.get("session1InCourse1");
params = new String[] { Const.ParamsNames.COURSE_ID, session1InCourse1.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName(), Const.ParamsNames.USER_ID, student1InCourse1.googleId };
pageAction = getAction(params);
pageResult = getShowPageResult(pageAction);
assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, false, student1InCourse1.googleId), pageResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, pageResult.getStatusMessage());
______TS("masquerade mode");
gaeSimulation.loginAsAdmin("admin.user");
pageAction = getAction(params);
pageResult = getShowPageResult(pageAction);
assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, false, student1InCourse1.googleId), pageResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, pageResult.getStatusMessage());
______TS("student has not joined course");
gaeSimulation.loginAsStudent(student1InCourse1.googleId);
student1InCourse1.googleId = null;
new StudentsDb().updateStudentWithoutSearchability(student1InCourse1.course, student1InCourse1.email, student1InCourse1.name, student1InCourse1.team, student1InCourse1.section, student1InCourse1.email, student1InCourse1.googleId, student1InCourse1.comments);
pageAction = getAction(params);
redirectResult = getRedirectResult(pageAction);
assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_HOME_PAGE, true, "student1InCourse1"), redirectResult.getDestinationWithParams());
assertTrue(redirectResult.isError);
assertEquals("You are not registered in the course " + session1InCourse1.getCourseId(), redirectResult.getStatusMessage());
}
use of teammates.ui.controller.ShowPageResult in project teammates by TEAMMATES.
the class StudentProfilePageActionTest method testActionInMasquerade.
private void testActionInMasquerade(AccountAttributes student) {
gaeSimulation.loginAsAdmin("admin.user");
______TS("Typical case: masquerade mode");
String[] submissionParams = new String[] { Const.ParamsNames.STUDENT_PROFILE_PHOTOEDIT, "false", Const.ParamsNames.USER_ID, student.googleId };
StudentProfilePageAction action = getAction(addUserIdToParams(student.googleId, 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, true);
}
Aggregations