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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
Aggregations