Search in sources :

Example 66 with CourseAttributes

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

the class CoursesLogicTest method testIsCoursePresent.

private void testIsCoursePresent() {
    ______TS("typical case: not an existent course");
    CourseAttributes nonExistentCourse = CourseAttributes.builder("non-existent-course", "non existent course", ZoneId.of("UTC")).build();
    assertFalse(coursesLogic.isCoursePresent(nonExistentCourse.getId()));
    ______TS("typical case: an existent course");
    CourseAttributes existingCourse = CourseAttributes.builder("idOfTypicalCourse1", "existing course", ZoneId.of("UTC")).build();
    assertTrue(coursesLogic.isCoursePresent(existingCourse.getId()));
    ______TS("Null parameter");
    try {
        coursesLogic.isCoursePresent(null);
        signalFailureToDetectException();
    } catch (AssertionError e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
}
Also used : CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 67 with CourseAttributes

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

the class CoursesLogicTest method testGetCourseSummaryWithoutStats.

private void testGetCourseSummaryWithoutStats() throws Exception {
    ______TS("typical case");
    CourseAttributes course = dataBundle.courses.get("typicalCourse1");
    CourseSummaryBundle courseSummary = coursesLogic.getCourseSummaryWithoutStats(course.getId());
    assertEquals(course.getId(), courseSummary.course.getId());
    assertEquals(course.getName(), courseSummary.course.getName());
    ______TS("course without students");
    StudentProfileAttributes spa = StudentProfileAttributes.builder("instructor1").build();
    AccountsLogic.inst().createAccount(AccountAttributes.builder().withGoogleId("instructor1").withName("Instructor 1").withEmail("instructor@email.tmt").withInstitute("TEAMMATES Test Institute 1").withIsInstructor(true).withStudentProfileAttributes(spa).build());
    coursesLogic.createCourseAndInstructor("instructor1", "course1", "course 1", "America/Los_Angeles");
    courseSummary = coursesLogic.getCourseSummaryWithoutStats("course1");
    assertEquals("course1", courseSummary.course.getId());
    assertEquals("course 1", courseSummary.course.getName());
    assertEquals("America/Los_Angeles", courseSummary.course.getTimeZone().getId());
    coursesLogic.deleteCourseCascade("course1");
    accountsDb.deleteAccount("instructor1");
    ______TS("non-existent");
    try {
        coursesLogic.getCourseSummaryWithoutStats("non-existent-course");
        signalFailureToDetectException();
    } catch (EntityDoesNotExistException e) {
        AssertHelper.assertContains("The course does not exist:", e.getMessage());
    }
    ______TS("null parameter");
    try {
        coursesLogic.getCourseSummaryWithoutStats((CourseAttributes) null);
        signalFailureToDetectException();
    } catch (AssertionError e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
    try {
        coursesLogic.getCourseSummaryWithoutStats((String) null);
        signalFailureToDetectException();
    } catch (AssertionError e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
}
Also used : CourseSummaryBundle(teammates.common.datatransfer.CourseSummaryBundle) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 68 with CourseAttributes

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

the class CoursesLogicTest method testVerifyCourseIsPresent.

private void testVerifyCourseIsPresent() throws Exception {
    ______TS("typical case: verify a non-existent course");
    CourseAttributes nonExistentCourse = CourseAttributes.builder("non-existent-course", "non existent course", ZoneId.of("UTC")).build();
    try {
        coursesLogic.verifyCourseIsPresent(nonExistentCourse.getId());
        signalFailureToDetectException();
    } catch (EntityDoesNotExistException e) {
        AssertHelper.assertContains("Course does not exist: ", e.getMessage());
    }
    ______TS("typical case: verify an existent course");
    CourseAttributes existingCourse = CourseAttributes.builder("idOfTypicalCourse1", "existing course", ZoneId.of("UTC")).build();
    coursesLogic.verifyCourseIsPresent(existingCourse.getId());
    ______TS("Null parameter");
    try {
        coursesLogic.verifyCourseIsPresent(null);
        signalFailureToDetectException();
    } catch (AssertionError | EntityDoesNotExistException e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
}
Also used : CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 69 with CourseAttributes

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

the class CoursesLogicTest method testGetTeamsForCourse.

private void testGetTeamsForCourse() throws Exception {
    ______TS("typical case");
    CourseAttributes course = dataBundle.courses.get("typicalCourse1");
    List<TeamDetailsBundle> teams = coursesLogic.getTeamsForCourse(course.getId());
    assertEquals(2, teams.size());
    assertEquals("Team 1.1</td></div>'\"", teams.get(0).name);
    assertEquals("Team 1.2", teams.get(1).name);
    ______TS("course without students");
    StudentProfileAttributes spa = StudentProfileAttributes.builder("instructor1").build();
    AccountsLogic.inst().createAccount(AccountAttributes.builder().withGoogleId("instructor1").withName("Instructor 1").withEmail("instructor@email.tmt").withInstitute("TEAMMATES Test Institute 1").withIsInstructor(true).withStudentProfileAttributes(spa).build());
    coursesLogic.createCourseAndInstructor("instructor1", "course1", "course 1", "UTC");
    teams = coursesLogic.getTeamsForCourse("course1");
    assertEquals(0, teams.size());
    coursesLogic.deleteCourseCascade("course1");
    accountsDb.deleteAccount("instructor1");
    ______TS("non-existent");
    try {
        coursesLogic.getTeamsForCourse("non-existent-course");
        signalFailureToDetectException();
    } catch (EntityDoesNotExistException e) {
        AssertHelper.assertContains("does not exist", e.getMessage());
    }
    ______TS("null parameter");
    try {
        coursesLogic.getTeamsForCourse(null);
        signalFailureToDetectException();
    } catch (AssertionError e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
}
Also used : TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 70 with CourseAttributes

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

the class CoursesLogicTest method testGetCourse.

private void testGetCourse() throws Exception {
    ______TS("failure: course doesn't exist");
    assertNull(coursesLogic.getCourse("nonexistant-course"));
    ______TS("success: typical case");
    CourseAttributes c = CourseAttributes.builder("Computing101-getthis", "Basic Computing Getting", ZoneId.of("UTC")).build();
    coursesDb.createEntity(c);
    assertEquals(c.getId(), coursesLogic.getCourse(c.getId()).getId());
    assertEquals(c.getName(), coursesLogic.getCourse(c.getId()).getName());
    coursesDb.deleteEntity(c);
    ______TS("Null parameter");
    try {
        coursesLogic.getCourse(null);
        signalFailureToDetectException();
    } catch (AssertionError e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
}
Also used : CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

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