@Test public void testFindAlbumById() throws Exception { Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION); album.modifyUser(user); Album createdAlbum = repository.create(album); // Execute Album foundAlbum = repository.findById(createdAlbum.getAlbumId()); // Verify em.flush(); em.clear(); Album actualAlbum = em.find(Album.class, foundAlbum.getAlbumId()); assertEquals(foundAlbum, actualAlbum); }