use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class InstructorCourseEnrollResultPageDataTest method testAll.
@Test
public void testAll() {
______TS("test typical case");
AccountAttributes account = dataBundle.accounts.get("instructor1OfCourse1");
String courseId = "idOfTypicalCourse1";
@SuppressWarnings("unchecked") List<StudentAttributes>[] students = new ArrayList[StudentUpdateStatus.STATUS_COUNT];
for (int i = 0; i < StudentUpdateStatus.STATUS_COUNT; i++) {
students[i] = new ArrayList<>();
}
students[StudentUpdateStatus.NEW.numericRepresentation].add(dataBundle.students.get("student1InCourse1"));
students[StudentUpdateStatus.NEW.numericRepresentation].add(dataBundle.students.get("student2InCourse1"));
students[StudentUpdateStatus.MODIFIED.numericRepresentation].add(dataBundle.students.get("student3InCourse1"));
students[StudentUpdateStatus.UNMODIFIED.numericRepresentation].add(dataBundle.students.get("student4InCourse1"));
students[StudentUpdateStatus.ERROR.numericRepresentation].add(dataBundle.students.get("student5InCourse1"));
boolean hasSection = true;
String enrollStudents = "enrollString";
InstructorCourseEnrollResultPageData pageData = new InstructorCourseEnrollResultPageData(account, dummySessionToken, courseId, students, hasSection, enrollStudents);
assertNotNull(pageData.getCourseId());
assertEquals(courseId, pageData.getCourseId());
assertNotNull(pageData.account);
assertEquals(account.googleId, pageData.account.googleId);
assertNotNull(pageData.getEnrollResultPanelList());
assertEquals(students.length, pageData.getEnrollResultPanelList().size());
assertEquals(students[StudentUpdateStatus.NEW.numericRepresentation].size(), pageData.getEnrollResultPanelList().get(StudentUpdateStatus.NEW.numericRepresentation).getStudentList().size());
assertEquals(students[StudentUpdateStatus.ERROR.numericRepresentation].size(), pageData.getEnrollResultPanelList().get(StudentUpdateStatus.ERROR.numericRepresentation).getStudentList().size());
assertEquals(students[StudentUpdateStatus.MODIFIED.numericRepresentation].size(), pageData.getEnrollResultPanelList().get(StudentUpdateStatus.MODIFIED.numericRepresentation).getStudentList().size());
assertEquals(students[StudentUpdateStatus.NOT_IN_ENROLL_LIST.numericRepresentation].size(), pageData.getEnrollResultPanelList().get(StudentUpdateStatus.NOT_IN_ENROLL_LIST.numericRepresentation).getStudentList().size());
assertEquals(students[StudentUpdateStatus.UNKNOWN.numericRepresentation].size(), pageData.getEnrollResultPanelList().get(StudentUpdateStatus.UNKNOWN.numericRepresentation).getStudentList().size());
assertEquals(students[StudentUpdateStatus.UNMODIFIED.numericRepresentation].size(), pageData.getEnrollResultPanelList().get(StudentUpdateStatus.UNMODIFIED.numericRepresentation).getStudentList().size());
assertTrue(pageData.isHasSection());
assertEquals(enrollStudents, pageData.getEnrollStudents());
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class InstructorCourseJoinConfirmationPageDataTest method testAll.
@Test
public void testAll() {
______TS("test typical case");
AccountAttributes account = dataBundle.accounts.get("instructor1OfCourse1");
String regkey = "someRandomKey";
String institute = "Institute Name";
InstructorCourseJoinConfirmationPageData pageData = new InstructorCourseJoinConfirmationPageData(account, dummySessionToken, regkey, institute);
assertNotNull(pageData.getRegkey());
assertEquals(regkey, pageData.getRegkey());
assertNotNull(pageData.getInstitute());
assertEquals(institute, pageData.getInstitute());
assertNotNull(pageData.getConfirmationLink());
String confirmationLink = Const.ActionURIs.INSTRUCTOR_COURSE_JOIN_AUTHENTICATED + "?key=" + regkey + "&" + Const.ParamsNames.INSTRUCTOR_INSTITUTION + "=" + SanitizationHelper.sanitizeForUri(institute);
assertEquals(confirmationLink, pageData.getConfirmationLink());
______TS("test case when institute is null");
account = dataBundle.accounts.get("instructor1OfCourse1");
regkey = "someRandomKey";
pageData = new InstructorCourseJoinConfirmationPageData(account, dummySessionToken, regkey, null);
assertNotNull(pageData.getRegkey());
assertEquals(regkey, pageData.getRegkey());
assertNull(pageData.getInstitute());
assertNotNull(pageData.getConfirmationLink());
confirmationLink = Const.ActionURIs.INSTRUCTOR_COURSE_JOIN_AUTHENTICATED + "?key=" + regkey;
assertEquals(confirmationLink, pageData.getConfirmationLink());
}
use of teammates.common.datatransfer.attributes.AccountAttributes 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());
}
use of teammates.common.datatransfer.attributes.AccountAttributes 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());
}
use of teammates.common.datatransfer.attributes.AccountAttributes 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);
}
Aggregations