Search in sources :

Example 46 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class InstructorCourseEditPageDataTest method testAll.

@Test
public void testAll() {
    ______TS("test typical case");
    AccountAttributes account = dataBundle.accounts.get("instructor1OfCourse1");
    CourseAttributes course = dataBundle.courses.get("typicalCourse1");
    List<InstructorAttributes> instructorList = new ArrayList<>();
    instructorList.add(dataBundle.instructors.get("instructor1OfCourse1"));
    instructorList.add(dataBundle.instructors.get("instructor2OfCourse1"));
    instructorList.add(dataBundle.instructors.get("helperOfCourse1"));
    instructorList.add(dataBundle.instructors.get("instructorNotYetJoinCourse1"));
    InstructorAttributes currentInstructor = dataBundle.instructors.get("instructor1OfCourse1");
    int offset = -1;
    List<String> sectionNames = new ArrayList<>();
    sectionNames.add("Section 1");
    sectionNames.add("Section 2");
    List<String> feedbackSessionNames = new ArrayList<>();
    feedbackSessionNames.add("First feedback session");
    feedbackSessionNames.add("Second feedback session");
    feedbackSessionNames.add("Grace Period Session");
    feedbackSessionNames.add("Closed Session");
    feedbackSessionNames.add("Empty session");
    feedbackSessionNames.add("non visible session");
    InstructorCourseEditPageData pageData = new InstructorCourseEditPageData(account, dummySessionToken, course, instructorList, currentInstructor, offset, sectionNames, feedbackSessionNames);
    assertEquals("idOfTypicalCourse1", pageData.getCourse().getId());
    assertEquals(-1, pageData.getInstructorToShowIndex());
    assertNotNull(pageData.getDeleteCourseButton());
    assertNotNull(pageData.getAddInstructorButton());
    assertNotNull(pageData.getInstructorPanelList());
    assertEquals(instructorList.size(), pageData.getInstructorPanelList().size());
    CourseEditInstructorPanel panel = pageData.getInstructorPanelList().get(0);
    assertEquals(4, panel.getPermissionInputGroup1().size());
    assertEquals(1, panel.getPermissionInputGroup2().size());
    assertEquals(3, panel.getPermissionInputGroup3().size());
    assertEquals("idOfInstructor1OfCourse1", panel.getInstructor().googleId);
    assertNotNull(panel.getDeleteButton());
    assertNotNull(panel.getEditButton());
    assertNull(panel.getResendInviteButton());
    assertEquals(sectionNames.size(), panel.getSectionRows().size());
    CourseEditSectionRow sectionRow = panel.getSectionRows().get(0);
    assertEquals(1, sectionRow.getPermissionInputGroup2().size());
    assertEquals(3, sectionRow.getPermissionInputGroup3().size());
    assertEquals(feedbackSessionNames.size(), sectionRow.getFeedbackSessions().size());
    assertFalse(sectionRow.isSectionSpecial());
    /*
         * Comment for below Assertion:
         * These sections are separated by a group of 3 so here is the formula to get the number
         * of groups.
         */
    assertEquals((sectionNames.size() - 1) / 3 + 1, sectionRow.getSpecialSections().size());
    assertNotNull(pageData.getAddInstructorPanel());
    CourseEditInstructorPanel addInstructorPanel = pageData.getAddInstructorPanel();
    assertEquals(4, addInstructorPanel.getPermissionInputGroup1().size());
    assertEquals(1, addInstructorPanel.getPermissionInputGroup2().size());
    assertEquals(3, addInstructorPanel.getPermissionInputGroup3().size());
    assertEquals(sectionNames.size(), addInstructorPanel.getSectionRows().size());
    sectionRow = addInstructorPanel.getSectionRows().get(0);
    assertEquals(feedbackSessionNames.size(), sectionRow.getFeedbackSessions().size());
    ______TS("test case when current instructor has no privilege");
    String[] privileges = { Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS };
    for (String privilege : privileges) {
        currentInstructor.privileges.updatePrivilege(privilege, false);
    }
    pageData = new InstructorCourseEditPageData(account, dummySessionToken, course, instructorList, currentInstructor, offset, sectionNames, feedbackSessionNames);
    assertNull(pageData.getDeleteCourseButton().getAttributes().get("disabled"));
    assertTrue(pageData.getDeleteCourseButton().getAttributes().containsKey("disabled"));
    assertNull(pageData.getAddInstructorButton().getAttributes().get("disabled"));
    assertTrue(pageData.getAddInstructorButton().getAttributes().containsKey("disabled"));
    ______TS("test showing only one instructor");
    offset = 1;
    pageData = new InstructorCourseEditPageData(account, dummySessionToken, course, instructorList, currentInstructor, offset, sectionNames, feedbackSessionNames);
    assertNotNull(pageData.getAddInstructorPanel());
    assertTrue(pageData.getInstructorPanelList().get(0).isAccessControlDisplayed());
    ______TS("test specialSection");
    InstructorAttributes instructor = instructorList.get(0);
    instructor.privileges.addSessionWithDefaultPrivileges("Section 1", "First feedback session");
    pageData = new InstructorCourseEditPageData(account, dummySessionToken, course, instructorList, currentInstructor, offset, sectionNames, feedbackSessionNames);
    assertTrue(pageData.getInstructorPanelList().get(0).getSectionRows().get(0).isSectionSpecial());
    ______TS("test empty sectionNames");
    sectionNames = new ArrayList<>();
    pageData = new InstructorCourseEditPageData(account, dummySessionToken, course, instructorList, currentInstructor, offset, sectionNames, feedbackSessionNames);
    assertNotNull(pageData.getAddInstructorPanel());
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) ArrayList(java.util.ArrayList) InstructorCourseEditPageData(teammates.ui.pagedata.InstructorCourseEditPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseEditSectionRow(teammates.ui.template.CourseEditSectionRow) CourseEditInstructorPanel(teammates.ui.template.CourseEditInstructorPanel) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 47 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class InstructorCoursesPageDataTest method testAll.

@Test
public void testAll() {
    ______TS("test no course");
    AccountAttributes instructorAccountWithoutCourses = dataBundle.accounts.get("instructorWithoutCourses");
    InstructorCoursesPageData pageData = new InstructorCoursesPageData(instructorAccountWithoutCourses, dummySessionToken);
    List<CourseAttributes> activeCourses = new ArrayList<>();
    List<CourseAttributes> archivedCourses = new ArrayList<>();
    Map<String, InstructorAttributes> instructorForCourses = new HashMap<>();
    pageData.init(activeCourses, archivedCourses, instructorForCourses);
    assertNotNull(pageData.getActiveCourses());
    assertNotNull(pageData.getActiveCourses().getRows());
    assertEquals(0, pageData.getActiveCourses().getRows().size());
    assertNotNull(pageData.getArchivedCourses());
    assertNotNull(pageData.getArchivedCourses().getRows());
    assertEquals(0, pageData.getArchivedCourses().getRows().size());
    assertEquals("", pageData.getCourseIdToShow());
    assertEquals("", pageData.getCourseNameToShow());
    ______TS("test 1 active course");
    AccountAttributes instructorAccountWithOneActiveCourse = dataBundle.accounts.get("instructor1OfCourse1");
    pageData = new InstructorCoursesPageData(instructorAccountWithOneActiveCourse, dummySessionToken);
    activeCourses = new ArrayList<>();
    activeCourses.add(dataBundle.courses.get("typicalCourse1"));
    archivedCourses = new ArrayList<>();
    instructorForCourses = new HashMap<>();
    instructorForCourses.put("idOfTypicalCourse1", dataBundle.instructors.get("instructor1OfCourse1"));
    pageData.init(activeCourses, archivedCourses, instructorForCourses);
    assertNotNull(pageData.getActiveCourses());
    assertNotNull(pageData.getActiveCourses().getRows());
    assertEquals(1, pageData.getActiveCourses().getRows().size());
    assertNotNull(pageData.getArchivedCourses());
    assertNotNull(pageData.getArchivedCourses().getRows());
    assertEquals(0, pageData.getArchivedCourses().getRows().size());
    assertEquals("", pageData.getCourseIdToShow());
    assertEquals("", pageData.getCourseNameToShow());
    ______TS("test 2 active courses");
    AccountAttributes instructorAccountWithTwoActiveCourses = dataBundle.accounts.get("instructor3");
    pageData = new InstructorCoursesPageData(instructorAccountWithTwoActiveCourses, dummySessionToken);
    activeCourses = new ArrayList<>();
    activeCourses.add(dataBundle.courses.get("typicalCourse1"));
    activeCourses.add(dataBundle.courses.get("typicalCourse2"));
    archivedCourses = new ArrayList<>();
    instructorForCourses = new HashMap<>();
    instructorForCourses.put("idOfTypicalCourse1", dataBundle.instructors.get("instructor3OfCourse1"));
    instructorForCourses.put("idOfTypicalCourse2", dataBundle.instructors.get("instructor3OfCourse2"));
    pageData.init(activeCourses, archivedCourses, instructorForCourses, "Id to show", "Name to show");
    assertNotNull(pageData.getActiveCourses());
    assertNotNull(pageData.getActiveCourses().getRows());
    assertEquals(2, pageData.getActiveCourses().getRows().size());
    assertNotNull(pageData.getArchivedCourses());
    assertNotNull(pageData.getArchivedCourses().getRows());
    assertEquals(0, pageData.getArchivedCourses().getRows().size());
    assertEquals("Id to show", pageData.getCourseIdToShow());
    assertEquals("Name to show", pageData.getCourseNameToShow());
    ______TS("test 1 archived course");
    AccountAttributes instructorAccountWithOneArchivedCourse = dataBundle.accounts.get("instructorOfArchivedCourse");
    pageData = new InstructorCoursesPageData(instructorAccountWithOneArchivedCourse, dummySessionToken);
    activeCourses = new ArrayList<>();
    archivedCourses = new ArrayList<>();
    archivedCourses.add(dataBundle.courses.get("archivedCourse"));
    instructorForCourses = new HashMap<>();
    instructorForCourses.put("idOfArchivedCourse", dataBundle.instructors.get("instructorOfArchivedCourse"));
    pageData.init(activeCourses, archivedCourses, instructorForCourses);
    assertNotNull(pageData.getActiveCourses());
    assertNotNull(pageData.getActiveCourses().getRows());
    assertEquals(0, pageData.getActiveCourses().getRows().size());
    assertNotNull(pageData.getArchivedCourses());
    assertNotNull(pageData.getArchivedCourses().getRows());
    assertEquals(1, pageData.getArchivedCourses().getRows().size());
    assertEquals("", pageData.getCourseIdToShow());
    assertEquals("", pageData.getCourseNameToShow());
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) InstructorCoursesPageData(teammates.ui.pagedata.InstructorCoursesPageData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 48 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageDataTest method testInitWithoutHighlighting.

@Test
public void testInitWithoutHighlighting() {
    AccountAttributes instructorAccount = dataBundle.accounts.get("instructor2OfCourse1");
    ______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.initWithoutHighlightedRow(courses, "idOfTypicalCourse1", fsList, courseInstructorMap, fsa, "STANDARD");
    FeedbackSessionsForm formModel = data.getNewFsForm();
    assertEquals("idOfTypicalCourse1", formModel.getCourseId());
    assertEquals(1, formModel.getCoursesSelectField().size());
    assertEquals(2, formModel.getFeedbackSessionTypeOptions().size());
    assertEquals("session with my own questions", formModel.getFeedbackSessionTypeOptions().get(0).getContent());
    assertNull(formModel.getFeedbackSessionTypeOptions().get(0).getAttributes().get("selected"));
    assertTrue(formModel.getFeedbackSessionTypeOptions().get(0).getAttributes().containsKey("selected"));
    FeedbackSessionsCopyFromModal modal = data.getCopyFromModal();
    assertEquals("First feedback session", modal.getFsName());
}
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) InstructorFeedbackSessionsPageData(teammates.ui.pagedata.InstructorFeedbackSessionsPageData) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 49 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageDataTest method testInitWithoutDefaultFormValues.

@Test
public void testInitWithoutDefaultFormValues() {
    AccountAttributes instructorAccount = dataBundle.accounts.get("instructor1OfCourse1");
    ______TS("typical success case");
    InstructorFeedbackSessionsPageData data = new InstructorFeedbackSessionsPageData(instructorAccount, dummySessionToken);
    HashMap<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);
    data.initWithoutDefaultFormValues(courses, null, fsList, courseInstructorMap, null);
    ______TS("typical success case: 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("", formModel.getFsEndDate());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getFsEndTimeOptions().size());
    assertEquals("", formModel.getFsName());
    assertEquals("", formModel.getFsStartDate());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getFsStartTimeOptions().size());
    assertEquals("", formModel.getFsTimeZone());
    assertEquals(7, formModel.getGracePeriodOptions().size());
    int expectedDefaultGracePeriodOptionsIndex = 3;
    assertNull(formModel.getGracePeriodOptions().get(expectedDefaultGracePeriodOptionsIndex).getAttributes().get("selected"));
    assertTrue(formModel.getGracePeriodOptions().get(expectedDefaultGracePeriodOptionsIndex).getAttributes().containsKey("selected"));
    assertEquals("Please answer all the given questions.", formModel.getInstructions());
    assertEquals("", formModel.getAdditionalSettings().getResponseVisibleDateValue());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getAdditionalSettings().getResponseVisibleTimeOptions().size());
    assertEquals("", formModel.getAdditionalSettings().getSessionVisibleDateValue());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getAdditionalSettings().getSessionVisibleTimeOptions().size());
    assertTrue(formModel.getAdditionalSettings().isResponseVisiblePublishManuallyChecked());
    assertFalse(formModel.getAdditionalSettings().isResponseVisibleDateChecked());
    assertFalse(formModel.getAdditionalSettings().isResponseVisibleImmediatelyChecked());
    assertTrue(formModel.getAdditionalSettings().isResponseVisibleDateDisabled());
    assertTrue(formModel.getAdditionalSettings().isSessionVisibleAtOpenChecked());
    assertTrue(formModel.getAdditionalSettings().isSessionVisibleDateDisabled());
    assertFalse(formModel.getAdditionalSettings().isSessionVisibleDateButtonChecked());
    assertFalse(formModel.getAdditionalSettings().isSessionVisiblePrivateChecked());
    ______TS("typical success case: 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: copy modal");
    FeedbackSessionsCopyFromModal copyModalModel = data.getCopyFromModal();
    assertEquals(1, copyModalModel.getCoursesSelectField().size());
    assertEquals("", copyModalModel.getFsName());
    assertEquals(6, copyModalModel.getExistingFeedbackSessions().size());
    ______TS("case with instructor with only archived course");
    AccountAttributes instructorOfArchivedCourseAccount = dataBundle.accounts.get("instructorOfArchivedCourse");
    InstructorFeedbackSessionsPageData instructorArchivedCourseData = new InstructorFeedbackSessionsPageData(instructorOfArchivedCourseAccount, dummySessionToken);
    Map<String, InstructorAttributes> archivedCourseInstructorMap = new HashMap<>();
    instructors = getInstructorsForGoogleId(instructorOfArchivedCourseAccount.googleId, true);
    for (InstructorAttributes instructor : instructors) {
        archivedCourseInstructorMap.put(instructor.courseId, instructor);
    }
    List<InstructorAttributes> instructorsForArchivedCourse = new ArrayList<>(archivedCourseInstructorMap.values());
    List<CourseAttributes> archivedCourses = getCoursesForInstructor(instructorsForArchivedCourse);
    List<FeedbackSessionAttributes> archivedFsList = getFeedbackSessionsListForInstructor(instructorsForArchivedCourse);
    instructorArchivedCourseData.initWithoutDefaultFormValues(archivedCourses, null, archivedFsList, archivedCourseInstructorMap, null);
    ______TS("case with instructor with only archived course: test new fs form");
    // Test new fs form model
    formModel = instructorArchivedCourseData.getNewFsForm();
    assertNull(formModel.getCourseId());
    assertEquals(1, formModel.getCoursesSelectField().size());
    assertEquals(Const.StatusMessages.INSTRUCTOR_NO_ACTIVE_COURSES, formModel.getCoursesSelectField().get(0).getContent());
    assertTrue(formModel.isSubmitButtonDisabled());
    ______TS("case with instructor with restricted permissions");
    AccountAttributes helperAccount = dataBundle.accounts.get("helperOfCourse1");
    InstructorFeedbackSessionsPageData helperData = new InstructorFeedbackSessionsPageData(helperAccount, dummySessionToken);
    Map<String, InstructorAttributes> helperCourseInstructorMap = new HashMap<>();
    instructors = getInstructorsForGoogleId(helperAccount.googleId, true);
    for (InstructorAttributes instructor : instructors) {
        helperCourseInstructorMap.put(instructor.courseId, instructor);
    }
    List<InstructorAttributes> instructorsForHelper = new ArrayList<>(helperCourseInstructorMap.values());
    List<CourseAttributes> helperCourses = getCoursesForInstructor(instructorsForHelper);
    List<FeedbackSessionAttributes> helperFsList = getFeedbackSessionsListForInstructor(instructorsForHelper);
    helperData.initWithoutDefaultFormValues(helperCourses, null, helperFsList, helperCourseInstructorMap, null);
    ______TS("case with instructor with restricted permissions: test new fs form");
    // Test new fs form model
    formModel = helperData.getNewFsForm();
    assertNull(formModel.getCourseId());
    assertEquals(1, formModel.getCoursesSelectField().size());
    assertEquals(Const.StatusMessages.INSTRUCTOR_NO_MODIFY_PERMISSION_FOR_ACTIVE_COURSES_SESSIONS, formModel.getCoursesSelectField().get(0).getContent());
    assertTrue(formModel.isSubmitButtonDisabled());
    ______TS("case with instructor with restricted permissions: session rows");
    fsTableModel = helperData.getFsList();
    fsRows = fsTableModel.getExistingFeedbackSessions();
    assertEquals(6, fsRows.size());
    ______TS("case with instructor with restricted permissions: copy modal");
    copyModalModel = helperData.getCopyFromModal();
    assertEquals(1, copyModalModel.getCoursesSelectField().size());
    assertEquals("", copyModalModel.getFsName());
    assertEquals(0, copyModalModel.getExistingFeedbackSessions().size());
    ______TS("case with highlighted session in session table");
    instructorAccount = dataBundle.accounts.get("instructor1OfCourse1");
    data = new InstructorFeedbackSessionsPageData(instructorAccount, dummySessionToken);
    courseInstructorMap = new HashMap<>();
    instructors = getInstructorsForGoogleId(instructorAccount.googleId, true);
    for (InstructorAttributes instructor : instructors) {
        courseInstructorMap.put(instructor.courseId, instructor);
    }
    instructorsForUser = new ArrayList<>(courseInstructorMap.values());
    courses = getCoursesForInstructor(instructorsForUser);
    fsList = getFeedbackSessionsListForInstructor(instructorsForUser);
    data.initWithoutDefaultFormValues(courses, "idOfTypicalCourse1", fsList, courseInstructorMap, "First feedback session");
    List<FeedbackSessionsTableRow> sessionRows = data.getFsList().getExistingFeedbackSessions();
    boolean isFirstFeedbackSessionHighlighted = false;
    boolean isOtherFeedbackSessionHighlighted = false;
    for (FeedbackSessionsTableRow row : sessionRows) {
        if ("First feedback session".equals(row.getName())) {
            isFirstFeedbackSessionHighlighted = row.getRowAttributes().getAttributes().get("class").matches(".*\\bwarning\\b.*");
        } else {
            if (row.getRowAttributes().getAttributes().get("class").matches(".*\\bwarning\\b.*")) {
                isOtherFeedbackSessionHighlighted = true;
            }
        }
    }
    assertTrue(isFirstFeedbackSessionHighlighted);
    assertFalse(isOtherFeedbackSessionHighlighted);
}
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)

Example 50 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class StudentCourseDetailsPageDataTest method test.

@Test
public void test() {
    ______TS("typical success case");
    AccountAttributes account = dataBundle.accounts.get("student1InCourse1");
    StudentCourseDetailsPageData pageData = new StudentCourseDetailsPageData(account, dummySessionToken);
    StudentAttributes student = dataBundle.students.get("student1InCourse1");
    CourseAttributes course = dataBundle.courses.get("typicalCourse1");
    CourseDetailsBundle courseDetails = new CourseDetailsBundle(course);
    List<InstructorAttributes> instructors = new ArrayList<>();
    instructors.add(dataBundle.instructors.get("instructor1OfCourse1"));
    instructors.add(dataBundle.instructors.get("instructor2OfCourse1"));
    instructors.add(dataBundle.instructors.get("helperOfCourse1"));
    TeamDetailsBundle team = new TeamDetailsBundle();
    team.name = student.team;
    // Get team members of student
    for (Entry<String, StudentAttributes> entry : dataBundle.students.entrySet()) {
        StudentAttributes currStudent = entry.getValue();
        if (currStudent.team.equals(team.name)) {
            team.students.add(currStudent);
        }
    }
    pageData.init(courseDetails, instructors, student, team);
    List<InstructorAttributes> courseInstructors = pageData.getStudentCourseDetailsPanel().getInstructors();
    List<StudentAttributes> teammates = pageData.getStudentCourseDetailsPanel().getTeammates();
    assertEquals(courseDetails.course.getName(), pageData.getStudentCourseDetailsPanel().getCourseName());
    assertEquals(courseDetails.course.getId(), pageData.getStudentCourseDetailsPanel().getCourseId());
    assertFalse(courseInstructors.isEmpty());
    assertFalse(teammates.isEmpty());
    assertEquals(student.email, pageData.getStudentCourseDetailsPanel().getStudentEmail());
    assertEquals(student.name, pageData.getStudentCourseDetailsPanel().getStudentName());
    assertEquals(team.name, pageData.getStudentCourseDetailsPanel().getStudentTeam());
    assertEquals(instructors.size(), courseInstructors.size());
    assertEquals(instructors.get(0).name, courseInstructors.get(0).name);
    assertEquals(instructors.get(1).name, courseInstructors.get(1).name);
    assertEquals(instructors.get(2).name, courseInstructors.get(2).name);
    assertEquals(instructors.get(0).displayedName, courseInstructors.get(0).displayedName);
    assertEquals(instructors.get(1).displayedName, courseInstructors.get(1).displayedName);
    assertEquals(instructors.get(2).displayedName, courseInstructors.get(2).displayedName);
    assertEquals(team.students.size(), teammates.size());
    ______TS("student in unregistered course");
    student = dataBundle.students.get("student1InUnregisteredCourse");
    course = dataBundle.courses.get("unregisteredCourse");
    courseDetails = new CourseDetailsBundle(course);
    instructors = new ArrayList<>();
    instructors.add(dataBundle.instructors.get("instructor5"));
    team = new TeamDetailsBundle();
    team.name = student.team;
    // Get team members of student
    for (Entry<String, StudentAttributes> entry : dataBundle.students.entrySet()) {
        StudentAttributes currStudent = entry.getValue();
        if (currStudent.team.equals(team.name)) {
            team.students.add(currStudent);
        }
    }
    pageData.init(courseDetails, instructors, student, team);
    courseInstructors = pageData.getStudentCourseDetailsPanel().getInstructors();
    teammates = pageData.getStudentCourseDetailsPanel().getTeammates();
    assertEquals(courseDetails.course.getName(), pageData.getStudentCourseDetailsPanel().getCourseName());
    assertEquals(courseDetails.course.getId(), pageData.getStudentCourseDetailsPanel().getCourseId());
    assertFalse(courseInstructors.isEmpty());
    assertFalse(teammates.isEmpty());
    assertEquals(student.email, pageData.getStudentCourseDetailsPanel().getStudentEmail());
    assertEquals(student.name, pageData.getStudentCourseDetailsPanel().getStudentName());
    assertEquals(team.name, pageData.getStudentCourseDetailsPanel().getStudentTeam());
    assertEquals(instructors.size(), courseInstructors.size());
    assertEquals(instructors.get(0).name, courseInstructors.get(0).name);
    assertEquals(instructors.get(0).displayedName, courseInstructors.get(0).displayedName);
    assertEquals(team.students.size(), teammates.size());
    ______TS("student in archived course");
    student = dataBundle.students.get("student1InArchivedCourse");
    course = dataBundle.courses.get("archivedCourse");
    courseDetails = new CourseDetailsBundle(course);
    instructors = new ArrayList<>();
    instructors.add(dataBundle.instructors.get("instructorOfArchivedCourse"));
    team = new TeamDetailsBundle();
    team.name = student.team;
    // Get team members of student
    for (Entry<String, StudentAttributes> entry : dataBundle.students.entrySet()) {
        StudentAttributes currStudent = entry.getValue();
        if (currStudent.team.equals(team.name)) {
            team.students.add(currStudent);
        }
    }
    pageData.init(courseDetails, instructors, student, team);
    courseInstructors = pageData.getStudentCourseDetailsPanel().getInstructors();
    teammates = pageData.getStudentCourseDetailsPanel().getTeammates();
    assertEquals(courseDetails.course.getName(), pageData.getStudentCourseDetailsPanel().getCourseName());
    assertEquals(courseDetails.course.getId(), pageData.getStudentCourseDetailsPanel().getCourseId());
    assertFalse(courseInstructors.isEmpty());
    assertFalse(teammates.isEmpty());
    assertEquals(student.email, pageData.getStudentCourseDetailsPanel().getStudentEmail());
    assertEquals(student.name, pageData.getStudentCourseDetailsPanel().getStudentName());
    assertEquals(team.name, pageData.getStudentCourseDetailsPanel().getStudentTeam());
    assertEquals(instructors.size(), courseInstructors.size());
    assertEquals(instructors.get(0).name, courseInstructors.get(0).name);
    assertEquals(instructors.get(0).displayedName, courseInstructors.get(0).displayedName);
    assertEquals(team.students.size(), teammates.size());
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) ArrayList(java.util.ArrayList) StudentCourseDetailsPageData(teammates.ui.pagedata.StudentCourseDetailsPageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Aggregations

CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)106 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)48 Test (org.testng.annotations.Test)40 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)33 ArrayList (java.util.ArrayList)31 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)19 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)16 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)15 EmailWrapper (teammates.common.util.EmailWrapper)15 HashMap (java.util.HashMap)12 InvalidParametersException (teammates.common.exception.InvalidParametersException)10 EmailGenerator (teammates.logic.api.EmailGenerator)10 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)8 StatusMessage (teammates.common.util.StatusMessage)6 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)5 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)4 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)4 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)4 InstructorCoursesPageData (teammates.ui.pagedata.InstructorCoursesPageData)4 InstructorFeedbackSessionsPageData (teammates.ui.pagedata.InstructorFeedbackSessionsPageData)4