Search in sources :

Example 6 with InstructorFeedbackSessionsPageData

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());
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FeedbackSessionsForm(teammates.ui.template.FeedbackSessionsForm) FeedbackSessionsCopyFromModal(teammates.ui.template.FeedbackSessionsCopyFromModal) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSessionsTableRow(teammates.ui.template.FeedbackSessionsTableRow) FeedbackSessionsTable(teammates.ui.template.FeedbackSessionsTable) InstructorFeedbackSessionsPageData(teammates.ui.pagedata.InstructorFeedbackSessionsPageData) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Aggregations

InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)6 InstructorFeedbackSessionsPageData (teammates.ui.pagedata.InstructorFeedbackSessionsPageData)6 ArrayList (java.util.ArrayList)5 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)5 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)5 Test (org.testng.annotations.Test)4 HashMap (java.util.HashMap)3 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)3 FeedbackSessionsCopyFromModal (teammates.ui.template.FeedbackSessionsCopyFromModal)3 FeedbackSessionsForm (teammates.ui.template.FeedbackSessionsForm)3 StatusMessage (teammates.common.util.StatusMessage)2 FeedbackSessionsTable (teammates.ui.template.FeedbackSessionsTable)2 FeedbackSessionsTableRow (teammates.ui.template.FeedbackSessionsTableRow)2 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)1 InvalidParametersException (teammates.common.exception.InvalidParametersException)1 InstructorFeedbackSessionsPageAction (teammates.ui.controller.InstructorFeedbackSessionsPageAction)1 ShowPageResult (teammates.ui.controller.ShowPageResult)1