*/
@Test
public void testCreate()
{
System.out.println("create");
Course testCourse = createTestCourse();
Long newId = instance.create(testCourse);
assertNotNull(newId);
assertEquals(new Long(15L), newId);
EntityManager em = testDb.getConnection();
List<Course> courses = instance.getAllCoursesByName();
System.out.println("Number of Courses (Expecting 1): " + courses.size());
if (courses.size() > 1)
{
for (int i = 0; i < courses.size(); i++)
{
Course crs = (Course) courses.get(i);
System.out.println("Course " + i + ": " + crs.getName()
+ " (ID: " + crs.getId() + ")");
}
}
assertEquals(3, courses.size());
Course course = (Course) courses.get(0);
System.out.println("Course (Expecting CS110): " + course.getName());
assertEquals("CS110", course.getName());
// Instructors are Eagerly loaded. Sections are lazily loaded
System.out.println("Number of Instructors in Course (Expecting 2): "
+ course.getInstructors().size());
assertEquals(2, course.getInstructors().size());
System.out.println("Number of Sections in Course (Expecting 2): "
+ course.getSections().size());
assertEquals(2, course.getSections().size());
Query query = em.createQuery("SELECT ins FROM Instructor ins");
List instructors = query.getResultList();
System.out.println("Number of Instructors in DB (Expecting 4): "
+ instructors.size());