### Question:
JpaCustomTagPersistenceService implements CustomTagPersistenceService { @Override public void changeOwnershipOfTags(String contributorFrom, String contributorTo) { if (contributorFrom == null || contributorTo == null) return; List<Tag> tags = em.createQuery("FROM Tag").getResultList(); for (Tag tag : tags) { if (tag.getContributorId().equals(contributorFrom)) { tag.setContributorId(contributorTo); em.merge(tag); } } }  @Override List<Tag> getTagsByContent(String... contentId); @Override List<Tag> getTagsByContentType(String contentType); @Override boolean createTag(Tag tag); @Override void deleteTag(String contentId, String tagLabel); @Override void deleteTagsForContent(String... contentId); @Override void changeOwnershipOfTags(String contributorFrom, String contributorTo);  }### Answer:
@Test public void changeOwnershipOfTags() { JpaCustomTagPersistenceService tested = getTested(); em.getTransaction().begin(); Tag tag1 = new Tag(CONTENT_TYPE_1_ID_1, CONTRIB_ID_1, "label1"); Tag tag2 = new Tag(CONTENT_TYPE_1_ID_1, CONTRIB_ID_2, "label2"); Tag tag3 = new Tag(CONTENT_TYPE_1_ID_1, CONTRIB_ID_2, "label3"); tested.createTag(tag1); tested.createTag(tag2); tested.createTag(tag3); List<Tag> ret = tested.getTagsByContentType(CONTENT_TYPE_1_ID_1); Assert.assertEquals(3, ret.size()); int count = 0; for (Tag tag : ret) { if (tag.getContributorId().equals(CONTRIB_ID_2)) { count++; } } Assert.assertEquals(2, count); System.out.println("pred: " + tested.getTagsByContentType(CONTENT_TYPE_1_ID_1)); em.getTransaction().commit(); em.getTransaction().begin(); tested.changeOwnershipOfTags(CONTRIB_ID_1, CONTRIB_ID_2); em.getTransaction().commit(); em.getTransaction().begin(); System.out.println("po: " + tested.getTagsByContentType(CONTENT_TYPE_1_ID_1)); ret = tested.getTagsByContentType(CONTENT_TYPE_1_ID_1); Assert.assertEquals(3, ret.size()); count = 0; for (Tag tag : ret) { if (tag.getContributorId().equals(CONTRIB_ID_2)) { count++; } } Assert.assertEquals(3, count); em.getTransaction().commit(); }