use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class CoursesLogicTest method testIsSampleCourse.
private void testIsSampleCourse() {
______TS("typical case: not a sample course");
CourseAttributes notSampleCourse = CourseAttributes.builder("course.id", "not sample course", ZoneId.of("UTC")).build();
assertFalse(coursesLogic.isSampleCourse(notSampleCourse.getId()));
______TS("typical case: is a sample course");
CourseAttributes sampleCourse = CourseAttributes.builder("course.id-demo3", "sample course", ZoneId.of("UTC")).build();
assertTrue(coursesLogic.isSampleCourse(sampleCourse.getId()));
______TS("typical case: is a sample course with '-demo' in the middle of its id");
CourseAttributes sampleCourse2 = CourseAttributes.builder("course.id-demo3-demo33", "sample course with additional -demo", ZoneId.of("UTC")).build();
assertTrue(coursesLogic.isSampleCourse(sampleCourse2.getId()));
______TS("Null parameter");
try {
coursesLogic.isSampleCourse(null);
signalFailureToDetectException();
} catch (AssertionError e) {
assertEquals("Course ID is null", e.getMessage());
}
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class CoursesLogicTest method testDeleteCourse.
private void testDeleteCourse() {
______TS("typical case");
CourseAttributes course1OfInstructor = dataBundle.courses.get("typicalCourse1");
StudentAttributes studentInCourse = dataBundle.students.get("student1InCourse1");
// Ensure there are entities in the datastore under this course
assertFalse(StudentsLogic.inst().getStudentsForCourse(course1OfInstructor.getId()).isEmpty());
verifyPresentInDatastore(course1OfInstructor);
verifyPresentInDatastore(studentInCourse);
verifyPresentInDatastore(dataBundle.instructors.get("instructor1OfCourse1"));
verifyPresentInDatastore(dataBundle.instructors.get("instructor3OfCourse1"));
verifyPresentInDatastore(dataBundle.students.get("student1InCourse1"));
verifyPresentInDatastore(dataBundle.students.get("student5InCourse1"));
verifyPresentInDatastore(dataBundle.feedbackSessions.get("session1InCourse1"));
verifyPresentInDatastore(dataBundle.feedbackSessions.get("session2InCourse1"));
assertEquals(course1OfInstructor.getId(), studentInCourse.course);
coursesLogic.deleteCourseCascade(course1OfInstructor.getId());
// Ensure the course and related entities are deleted
verifyAbsentInDatastore(course1OfInstructor);
verifyAbsentInDatastore(studentInCourse);
verifyAbsentInDatastore(dataBundle.instructors.get("instructor1OfCourse1"));
verifyAbsentInDatastore(dataBundle.instructors.get("instructor3OfCourse1"));
verifyAbsentInDatastore(dataBundle.students.get("student1InCourse1"));
verifyAbsentInDatastore(dataBundle.students.get("student5InCourse1"));
verifyAbsentInDatastore(dataBundle.feedbackSessions.get("session1InCourse1"));
verifyAbsentInDatastore(dataBundle.feedbackSessions.get("session2InCourse1"));
______TS("non-existent");
// try to delete again. Should fail silently.
coursesLogic.deleteCourseCascade(course1OfInstructor.getId());
______TS("null parameter");
try {
coursesLogic.deleteCourseCascade(null);
signalFailureToDetectException();
} catch (AssertionError e) {
assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
}
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class CoursesLogicTest method testHasIndicatedSections.
private void testHasIndicatedSections() throws Exception {
______TS("Typical case: course with sections");
CourseAttributes typicalCourse1 = dataBundle.courses.get("typicalCourse1");
assertTrue(coursesLogic.hasIndicatedSections(typicalCourse1.getId()));
______TS("Typical case: course without sections");
CourseAttributes typicalCourse2 = dataBundle.courses.get("typicalCourse2");
assertFalse(coursesLogic.hasIndicatedSections(typicalCourse2.getId()));
______TS("Failure case: course does not exists");
try {
coursesLogic.hasIndicatedSections("non-existent-course");
signalFailureToDetectException();
} catch (EntityDoesNotExistException e) {
AssertHelper.assertContains("does not exist", e.getMessage());
}
______TS("Failure case: null parameter");
try {
coursesLogic.hasIndicatedSections(null);
signalFailureToDetectException();
} catch (AssertionError e) {
assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
}
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class CoursesLogicTest method testGetCourseDetailsListForStudent.
private void testGetCourseDetailsListForStudent() throws Exception {
______TS("student having multiple evaluations in multiple courses");
CourseAttributes expectedCourse1 = dataBundle.courses.get("typicalCourse1");
// This student is in both course 1 and 2
StudentAttributes studentInBothCourses = dataBundle.students.get("student2InCourse1");
// Get course details for student
List<CourseDetailsBundle> courseList = coursesLogic.getCourseDetailsListForStudent(studentInBothCourses.googleId);
// Verify number of courses received
assertEquals(2, courseList.size());
CourseDetailsBundle actualCourse1 = courseList.get(0);
assertEquals(expectedCourse1.getId(), actualCourse1.course.getId());
assertEquals(expectedCourse1.getName(), actualCourse1.course.getName());
// student with no courses is not applicable
______TS("non-existent student");
try {
coursesLogic.getCourseDetailsListForStudent("non-existent-student");
signalFailureToDetectException();
} catch (EntityDoesNotExistException e) {
AssertHelper.assertContains("does not exist", e.getMessage());
}
______TS("null parameter");
try {
coursesLogic.getCourseDetailsListForStudent(null);
signalFailureToDetectException();
} catch (AssertionError e) {
assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
}
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class EmailGeneratorTest method testGenerateFeedbackSessionEmails_testSanitization.
@Test
public void testGenerateFeedbackSessionEmails_testSanitization() throws IOException {
FeedbackSessionAttributes session = fsLogic.getFeedbackSession("Normal feedback session name", "idOfTestingSanitizationCourse");
CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
StudentAttributes student1 = studentsLogic.getStudentForEmail(course.getId(), "normal@sanitization.tmt");
InstructorAttributes instructor1 = instructorsLogic.getInstructorForEmail(course.getId(), "instructor1@sanitization.tmt");
______TS("feedback session opening emails: sanitization required");
List<EmailWrapper> emails = new EmailGenerator().generateFeedbackSessionOpeningEmails(session);
assertEquals(2, emails.size());
String subject = String.format(EmailType.FEEDBACK_OPENING.getSubject(), course.getName(), session.getFeedbackSessionName());
verifyEmailReceivedCorrectly(emails, student1.email, subject, "/sessionOpeningEmailTestingSanitzationForStudent.html");
verifyEmailReceivedCorrectly(emails, instructor1.email, subject, "/sessionOpeningEmailTestingSanitizationForInstructor.html");
______TS("feedback session closed alerts: sanitization required");
emails = new EmailGenerator().generateFeedbackSessionClosedEmails(session);
assertEquals(2, emails.size());
subject = String.format(EmailType.FEEDBACK_CLOSED.getSubject(), course.getName(), session.getFeedbackSessionName());
verifyEmailReceivedCorrectly(emails, student1.email, subject, "/sessionClosedEmailTestingSanitizationForStudent.html");
verifyEmailReceivedCorrectly(emails, instructor1.email, subject, "/sessionClosedEmailTestingSanitizationForInstructor.html");
______TS("feedback sessions summary of course email: sanitization required");
EmailWrapper email = new EmailGenerator().generateFeedbackSessionSummaryOfCourse(session.getCourseId(), student1);
subject = String.format(EmailType.STUDENT_EMAIL_CHANGED.getSubject(), course.getName(), course.getId());
verifyEmail(email, student1.email, subject, "/summaryOfFeedbackSessionsOfCourseEmailTestingSanitizationForStudent.html");
______TS("feedback session submission email: sanitization required");
Instant time = TimeHelper.parseInstant("2016-09-04 05:30 AM +0000");
email = new EmailGenerator().generateFeedbackSubmissionConfirmationEmailForInstructor(session, instructor1, time);
subject = String.format(EmailType.FEEDBACK_SUBMISSION_CONFIRMATION.getSubject(), course.getName(), session.getFeedbackSessionName());
verifyEmail(email, instructor1.email, subject, "/sessionSubmissionConfirmationEmailTestingSanitization.html");
}
Aggregations