### Question:
JpaRatingPersistenceService implements RatingPersistenceService { @Override public void deleteRatingsForContributor(String contributorId) { if (contributorId != null) { em.createQuery("delete from Rating r where r.contributorId = ?1").setParameter(1, contributorId).executeUpdate(); } }  @Override List<Rating> getRatings(String contributorId, String... contentId); @Override void rate(String contributorId, String contentId, int rating); @Override RatingStats countRatingStats(String contentId); @Override void mergeRatingsForContributors(String contributorIdFrom, String contributorIdTo); @Override void deleteRatingsForContributor(String contributorId); @Override void deleteRatingsForContent(String... contentId);  }### Answer:
@Test public void deleteRatingsForContributor() { JpaRatingPersistenceService tested = getTested(); em.getTransaction().begin(); tested.rate(CONTRIB_ID_1, CONTENT_ID_1, 1); tested.rate(CONTRIB_ID_1, CONTENT_ID_3, 4); tested.rate(CONTRIB_ID_2, CONTENT_ID_1, 5); tested.rate(CONTRIB_ID_2, CONTENT_ID_2, 3); tested.rate(CONTRIB_ID_3, CONTENT_ID_1, 2); tested.rate(CONTRIB_ID_3, CONTENT_ID_2, 2); em.getTransaction().commit(); em.getTransaction().begin(); tested.deleteRatingsForContributor(null); tested.deleteRatingsForContributor(CONTRIB_ID_1); em.getTransaction().commit(); em.getTransaction().begin(); Assert.assertEquals(0, tested.getRatings(CONTRIB_ID_1, CONTENT_ID_1, CONTENT_ID_2, CONTENT_ID_3).size()); Assert.assertEquals(2, tested.getRatings(CONTRIB_ID_2, CONTENT_ID_1, CONTENT_ID_2, CONTENT_ID_3).size()); Assert.assertEquals(2, tested.getRatings(CONTRIB_ID_3, CONTENT_ID_1, CONTENT_ID_2, CONTENT_ID_3).size()); em.getTransaction().commit(); }