@Test
public void isImageEditedWithMetaTags() throws Exception {
Image image = helper.getAllImages(em).get(0);
List<MetaTag> tags = image.getImageTags();
MetaTag removedTag = tags.get(0);
String metaTagsByImageId = "select m from MetaTag m join m.images i where i.id = :id";
List<MetaTag> _tagsById = em.createQuery(metaTagsByImageId, MetaTag.class).setParameter("id", image.getId())
.getResultList();
Assert.assertTrue(_tagsById.contains(removedTag));
Assert.assertTrue(removedTag.getImages().contains(image));
tags.remove(0);
Assert.assertFalse(tags.contains(removedTag));
removedTag.removeImage(image);
Assert.assertFalse(removedTag.getImages().contains(image));
image.setImageTags(tags);
ia.editImage(image, true);
List<MetaTag> tagsById = em.createQuery(metaTagsByImageId, MetaTag.class).setParameter("id", image.getId())
.getResultList();
Image editedImage = helper.getAllImages(em).get(0);
String tagById = "select m from MetaTag m where id = :id";
MetaTag m = em.createQuery(tagById, MetaTag.class).setParameter("id", removedTag.getId()).getSingleResult();
Assert.assertFalse(tagsById.contains(removedTag));
Assert.assertFalse(m.getImages().contains(editedImage));
}