@Test public void testDeleteAlbum() throws Exception { Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION); album.modifyUser(user); em.persist(album); long albumId = album.getAlbumId(); em.flush(); // Execute repository.delete(album); // Verify em.flush(); em.clear(); Album actualAlbum = em.find(Album.class, albumId); assertNull(actualAlbum); }
@Test public void testDeleteAlbumWithPhoto() throws Exception { Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION); album.modifyUser(user); em.persist(album); em.flush(); Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT); photo.setUploadTime(new Date()); album.addToPhotos(photo); album = repository.modify(album); em.flush(); // Execute long albumId = album.getAlbumId(); repository.delete(album); // Verify em.flush(); em.clear(); Album actualAlbum = em.find(Album.class, albumId); assertNull(actualAlbum); }