@Test
public void testModifyUserModifyPhoto() throws Exception
{
//Setup
User user = new User(TEST_USER_ID , TEST_PASSWORD);
Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
user.addToAlbums(album);
Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
photo.setUploadTime(new Date());
for(Album anAlbum: user.getAlbums())
{
if(anAlbum.equals(album))
{
anAlbum.addToPhotos(photo);
}
}
em.persist(user);
em.flush();
em.clear();
//Execute
String modifiedTitle = "Modified Photo Title";
for(Album anAlbum: user.getAlbums())
{
for(Photo aPhoto: anAlbum.getPhotos())
{
aPhoto.setTitle(modifiedTitle);
}
}
user = repository.modify(user);
em.flush();
em.clear();
//Verify
User actualUser = em.find(User.class, TEST_USER_ID);
assertEquals(user, actualUser);
for(Album anAlbum: user.getAlbums())
{
assertTrue(anAlbum.getPhotos().contains(photo));
for(Photo aPhoto: anAlbum.getPhotos())