@Test public void testGetStudentById() { // Grab a test fixture student. Student student = studentDao.getStudentById(1000000L); Assert.assertEquals(Long.valueOf(1000000L), student.getId()); Assert.assertEquals("Berners-Lee", student.getLastName()); Assert.assertEquals("Tim", student.getFirstName()); Assert.assertTrue(student.isActive()); Assert.assertEquals(Integer.valueOf(2016), student.getExpectedGraduationYear()); // The text fixture data has some empty values. Assert.assertNull(student.getMiddleName()); Assert.assertNull(student.getEntryYear()); Assert.assertEquals(0, student.getMajors().size()); Assert.assertEquals(0, student.getMinors().size()); Assert.assertEquals(0, student.getRecord().getGrades().size()); // Grant and event data do not come along for the ride. try { student.getGrants().size(); // If this doesn't bork, something is wrong. Assert.fail("getGrants should not succeed, but did."); } catch (LazyInitializationException lazyInitializationException) { // This is what should happen; carry on. } try { student.getAttendance().size(); // If this doesn't bork, something is wrong. Assert.fail("getAttendance should not succeed, but did."); } catch (LazyInitializationException lazyInitializationException) { // This is what should happen; carry on. } }