use of teammates.ui.pagedata.InstructorFeedbackSessionsPageData in project teammates by TEAMMATES.
the class InstructorFeedbackSessionsPageDataTest method testInit.
@Test
public void testInit() {
AccountAttributes instructorAccount = dataBundle.accounts.get("instructor1OfCourse1");
______TS("typical success case with existing fs passed in");
InstructorFeedbackSessionsPageData data = new InstructorFeedbackSessionsPageData(instructorAccount, dummySessionToken);
Map<String, InstructorAttributes> courseInstructorMap = new HashMap<>();
List<InstructorAttributes> instructors = getInstructorsForGoogleId(instructorAccount.googleId, true);
for (InstructorAttributes instructor : instructors) {
courseInstructorMap.put(instructor.courseId, instructor);
}
List<InstructorAttributes> instructorsForUser = new ArrayList<>(courseInstructorMap.values());
List<CourseAttributes> courses = getCoursesForInstructor(instructorsForUser);
List<FeedbackSessionAttributes> fsList = getFeedbackSessionsListForInstructor(instructorsForUser);
FeedbackSessionAttributes fsa = dataBundle.feedbackSessions.get("session1InCourse1");
data.init(courses, null, fsList, courseInstructorMap, fsa, null, null);
______TS("typical success case with existing fs passed in: test new fs form");
// Test new fs form model
FeedbackSessionsForm formModel = data.getNewFsForm();
assertNull(formModel.getCourseId());
assertEquals(1, formModel.getCoursesSelectField().size());
assertEquals(2, formModel.getFeedbackSessionTypeOptions().size());
assertEquals("session using template: team peer evaluation", formModel.getFeedbackSessionTypeOptions().get(1).getContent());
assertNull(formModel.getFeedbackSessionTypeOptions().get(1).getAttributes().get("selected"));
assertTrue(formModel.getFeedbackSessionTypeOptions().get(1).getAttributes().containsKey("selected"));
assertEquals("Fri, 30 Apr, 2027", formModel.getFsEndDate());
assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getFsEndTimeOptions().size());
assertEquals("First feedback session", formModel.getFsName());
assertEquals("Sun, 01 Apr, 2012", formModel.getFsStartDate());
assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getFsStartTimeOptions().size());
assertEquals(7, formModel.getGracePeriodOptions().size());
int expectedDefaultGracePeriodOptionsIndex = 2;
assertNull(formModel.getGracePeriodOptions().get(expectedDefaultGracePeriodOptionsIndex).getAttributes().get("selected"));
assertTrue(formModel.getGracePeriodOptions().get(expectedDefaultGracePeriodOptionsIndex).getAttributes().containsKey("selected"));
assertEquals("Please please fill in the following questions.", formModel.getInstructions());
assertEquals("Sat, 01 May, 2027", formModel.getAdditionalSettings().getResponseVisibleDateValue());
assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getAdditionalSettings().getResponseVisibleTimeOptions().size());
assertEquals("Wed, 28 Mar, 2012", formModel.getAdditionalSettings().getSessionVisibleDateValue());
assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getAdditionalSettings().getSessionVisibleTimeOptions().size());
assertFalse(formModel.getAdditionalSettings().isResponseVisiblePublishManuallyChecked());
assertTrue(formModel.getAdditionalSettings().isResponseVisibleDateChecked());
assertFalse(formModel.getAdditionalSettings().isResponseVisibleImmediatelyChecked());
assertFalse(formModel.getAdditionalSettings().isResponseVisibleDateDisabled());
assertFalse(formModel.getAdditionalSettings().isSessionVisibleAtOpenChecked());
assertFalse(formModel.getAdditionalSettings().isSessionVisibleDateDisabled());
assertTrue(formModel.getAdditionalSettings().isSessionVisibleDateButtonChecked());
assertFalse(formModel.getAdditionalSettings().isSessionVisiblePrivateChecked());
______TS("typical success case with existing fs passed in: session rows");
FeedbackSessionsTable fsTableModel = data.getFsList();
List<FeedbackSessionsTableRow> fsRows = fsTableModel.getExistingFeedbackSessions();
assertEquals(6, fsRows.size());
String firstFsName = "Grace Period Session";
assertEquals(firstFsName, fsRows.get(0).getName());
String lastFsName = "First feedback session";
assertEquals(lastFsName, fsRows.get(fsRows.size() - 1).getName());
______TS("typical success case with existing fs passed in: copy modal");
FeedbackSessionsCopyFromModal copyModalModel = data.getCopyFromModal();
assertEquals(1, copyModalModel.getCoursesSelectField().size());
assertEquals("First feedback session", copyModalModel.getFsName());
assertEquals(6, copyModalModel.getExistingFeedbackSessions().size());
}
Aggregations