Search in sources :

Example 41 with CourseAttributes

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");
}
Also used : EmailGenerator(teammates.logic.api.EmailGenerator) AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 42 with CourseAttributes

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");
}
Also used : EmailGenerator(teammates.logic.api.EmailGenerator) AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 43 with CourseAttributes

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());
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 44 with CourseAttributes

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());
    }
}
Also used : CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 45 with CourseAttributes

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());
    }
}
Also used : 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