### Question:
JpaCustomTagPersistenceService implements CustomTagPersistenceService { @Override public void deleteTag(String contentId, String tagLabel) { tagLabel = tagLabel.toLowerCase(); if ((contentId != null) && (tagLabel!= null)) { em.createQuery("delete from Tag t where t.contentId = ?1 and t.tagLabel = ?2") .setParameter(1, contentId) .setParameter(2, tagLabel) .executeUpdate(); } }  @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 deleteTag() { JpaCustomTagPersistenceService tested = getTested(); 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_2, CONTRIB_ID_2, "label3"); em.getTransaction().begin(); tested.createTag(tag1); tested.createTag(tag2); tested.createTag(tag3); em.getTransaction().commit(); em.getTransaction().begin(); tested.deleteTag(CONTENT_TYPE_1_ID_1, "nonexisting label"); List<Tag> ret = tested.getTagsByContentType(CONTENT_TYPE_1); Assert.assertEquals(3, ret.size()); em.getTransaction().commit(); em.getTransaction().begin(); tested.deleteTag(CONTENT_TYPE_1_ID_2, "label2"); ret = tested.getTagsByContentType(CONTENT_TYPE_1); Assert.assertEquals(3, ret.size()); em.getTransaction().commit(); em.getTransaction().begin(); tested.deleteTag(CONTENT_TYPE_1_ID_1, "label1"); ret = tested.getTagsByContentType(CONTENT_TYPE_1); Assert.assertEquals(2, ret.size()); Tag testedTag1 = ret.get(0); Tag testedTag2 = ret.get(1); if (testedTag1.getTagLabel().equals("label2")) { Assert.assertEquals(tag2.getContentId(), testedTag1.getContentId()); Assert.assertEquals(tag2.getContributorId(), testedTag1.getContributorId()); Assert.assertEquals(tag3.getContentId(), testedTag2.getContentId()); Assert.assertEquals(tag3.getContributorId(), testedTag2.getContributorId()); Assert.assertEquals("label3", testedTag2.getTagLabel()); } else { Assert.assertEquals(tag2.getContentId(), testedTag2.getContentId()); Assert.assertEquals(tag2.getContributorId(), testedTag2.getContributorId()); Assert.assertEquals(tag3.getContentId(), testedTag1.getContentId()); Assert.assertEquals(tag3.getContributorId(), testedTag1.getContributorId()); Assert.assertEquals("label3", testedTag1.getTagLabel()); } em.getTransaction().commit(); }