use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class EmailGeneratorTest method testGenerateInstructorJoinEmail_testSanitization.
@Test
public void testGenerateInstructorJoinEmail_testSanitization() throws IOException {
______TS("instructor new account email: sanitization required");
InstructorAttributes instructor1 = instructorsLogic.getInstructorForEmail("idOfTestingSanitizationCourse", "instructor1@sanitization.tmt");
String joinLink = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN).withRegistrationKey(StringHelper.encrypt(instructor1.key)).withInstructorInstitution("Test Institute").toAbsoluteString();
EmailWrapper email = new EmailGenerator().generateNewInstructorAccountJoinEmail(instructor1.email, instructor1.name, joinLink);
// InstructorAttributes sanitizes name before saving
String subject = String.format(EmailType.NEW_INSTRUCTOR_ACCOUNT.getSubject(), SanitizationHelper.sanitizeForHtml(instructor1.name));
verifyEmail(email, instructor1.email, subject, "/instructorNewAccountEmailTestingSanitization.html");
assertEquals(email.getBcc(), Config.SUPPORT_EMAIL);
______TS("instructor course join email: sanitization required");
AccountAttributes inviter = dataBundle.accounts.get("instructor1OfTestingSanitizationCourse");
CourseAttributes course = coursesLogic.getCourse("idOfTestingSanitizationCourse");
email = new EmailGenerator().generateInstructorCourseJoinEmail(inviter, instructor1, course);
subject = String.format(EmailType.INSTRUCTOR_COURSE_JOIN.getSubject(), course.getName(), course.getId());
verifyEmail(email, instructor1.email, subject, "/instructorCourseJoinEmailTestingSanitization.html");
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class EmailGeneratorTest method testGenerateInstructorJoinEmail.
@Test
public void testGenerateInstructorJoinEmail() throws IOException {
______TS("instructor new account email");
String instructorEmail = "instructor@email.tmt";
String instructorName = "Instr";
String regkey = "skxxxxxxxxxks";
@SuppressWarnings("deprecation") InstructorAttributes instructor = InstructorAttributes.builder("googleId", "courseId", "Instructor Name", instructorEmail).withKey(regkey).build();
AccountAttributes inviter = AccountAttributes.builder().withEmail("instructor-joe@gmail.com").withName("Joe Wilson").build();
String joinLink = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN).withRegistrationKey(StringHelper.encrypt(regkey)).withInstructorInstitution("Test Institute").toAbsoluteString();
EmailWrapper email = new EmailGenerator().generateNewInstructorAccountJoinEmail(instructorEmail, instructorName, joinLink);
String subject = String.format(EmailType.NEW_INSTRUCTOR_ACCOUNT.getSubject(), instructorName);
verifyEmail(email, instructorEmail, subject, "/instructorNewAccountEmail.html");
assertEquals(email.getBcc(), Config.SUPPORT_EMAIL);
______TS("instructor course join email");
CourseAttributes course = CourseAttributes.builder("course-id", "Course Name", ZoneId.of("UTC")).build();
email = new EmailGenerator().generateInstructorCourseJoinEmail(inviter, instructor, course);
subject = String.format(EmailType.INSTRUCTOR_COURSE_JOIN.getSubject(), course.getName(), course.getId());
verifyEmail(email, instructor.email, subject, "/instructorCourseJoinEmail.html");
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class StudentsLogicTest method testGetStudentsForCourse.
private void testGetStudentsForCourse() {
______TS("course with multiple students");
CourseAttributes course1OfInstructor1 = dataBundle.courses.get("typicalCourse1");
List<StudentAttributes> studentList = studentsLogic.getStudentsForCourse(course1OfInstructor1.getId());
assertEquals(5, studentList.size());
for (StudentAttributes s : studentList) {
assertEquals(course1OfInstructor1.getId(), s.course);
}
______TS("course with 0 students");
CourseAttributes course2OfInstructor1 = dataBundle.courses.get("courseNoEvals");
studentList = studentsLogic.getStudentsForCourse(course2OfInstructor1.getId());
assertEquals(0, studentList.size());
______TS("null parameter");
try {
studentsLogic.getStudentsForCourse(null);
signalFailureToDetectException();
} catch (AssertionError ae) {
assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
}
______TS("non-existent course");
studentList = studentsLogic.getStudentsForCourse("non-existent");
assertEquals(0, studentList.size());
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class CoursesDbTest method testDeleteCourse.
@Test
public void testDeleteCourse() throws InvalidParametersException {
CourseAttributes c = createNewCourse();
______TS("Success: delete an existing course");
coursesDb.deleteCourse(c.getId());
CourseAttributes deleted = coursesDb.getCourse(c.getId());
assertNull(deleted);
______TS("Failure: delete a non-existent courses");
// Should fail silently
coursesDb.deleteCourse(c.getId());
______TS("Failure: null parameter");
try {
coursesDb.deleteCourse(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 CoursesDbTest method testGetCourse.
@Test
public void testGetCourse() throws InvalidParametersException {
CourseAttributes c = createNewCourse();
______TS("Success: get an existent course");
CourseAttributes retrieved = coursesDb.getCourse(c.getId());
assertNotNull(retrieved);
______TS("Failure: get a non-existent course");
retrieved = coursesDb.getCourse("non-existent-course");
assertNull(retrieved);
______TS("Failure: get null parameters");
try {
coursesDb.getCourse(null);
signalFailureToDetectException();
} catch (AssertionError e) {
assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
}
}
Aggregations