Course course = courseDAO.find(2L);
CategoryDAO categoryDAO = new CategoryDAO(testDb.getConnection());
Category category = categoryDAO.find(2L);
GradedEvent gradedEvent = instance.find(new Long(3L));
assertEquals(1, gradedEvent.getQuestions().size());
gradedEvent.setCourse(course);
gradedEvent.setAssignment("PEX3");
gradedEvent.setDueDate("19 May 2010");
gradedEvent.setPartialCredit(false);
gradedEvent.setTerm("Fall 2010");
gradedEvent.setVersion("ALL");
Question newQuestion = new Question(42L, "TestQ", category,
"This is a new test question");
assertEquals(1, gradedEvent.getQuestions().size());
gradedEvent.addQuestion(newQuestion);
// Make sure the updated GradedEvent is returned from the method
GradedEvent result = instance.update(gradedEvent);
assertNotNull(result);
// Grab the updated GradedEvent from the Data source
GradedEvent requestQuery = instance.find(new Long(3L));
// Verify the data is maintained across the 3 versions (local, result from
// update, and query of the data source
// Id
assertEquals(new Long(3L), requestQuery.getId());
assertEquals(result.getId(), requestQuery.getId());
// Course
assertEquals(course, requestQuery.getCourse());
assertEquals(result.getCourse(), requestQuery.getCourse());
// Assignment
assertEquals("PEX3", requestQuery.getAssignment());
assertEquals(result.getAssignment(), requestQuery.getAssignment());
// Term
assertEquals("Fall 2010", requestQuery.getTerm());
assertEquals(result.getTerm(), requestQuery.getTerm());
// Version
assertEquals("ALL", requestQuery.getVersion());
assertEquals(result.getVersion(), requestQuery.getVersion());
// Due Date
assertEquals("19 May 2010", requestQuery.getDueDate());
assertEquals(result.getDueDate(), requestQuery.getDueDate());
// Partial Credit
assertEquals(false, requestQuery.getPartialCredit());
assertEquals(result.getPartialCredit(), requestQuery.getPartialCredit());
// Number of Questions
assertEquals(2, requestQuery.getQuestions().size());
assertEquals(result.getQuestions().size(), requestQuery.getQuestions().size());
assertTrue(instance.isOpen());
courseDAO.closeConnection();
categoryDAO.closeConnection();
}