### Question:
JudgmentObjectDeleter { @Transactional public void deleteJudgmentResultsWithoutJudgments(CourtType courtType) { log.debug("Deleting judgmentResults (with type {}) without referring judgments ", courtType.name()); String q = "select judgmentResult.id from " + JudgmentResult.class.getName() + " judgmentResult " + " where judgmentResult.courtType = :courtType " + " and not exists (select judgment from "+ Judgment.class.getName() + " judgment " + " where judgment.judgmentResult.id = judgmentResult.id)"; @SuppressWarnings("unchecked") List<Long> judgmentResultIds = entityManager.createQuery(q) .setParameter("courtType", courtType) .getResultList(); judgmentResultIds.stream().forEach(judgmentResultRepository::delete); judgmentResultRepository.flush(); }  @Transactional void deleteJudgmentsWithoutRawSourceJudgment(Class<? extends Judgment> judgmentClass, Class<? extends RawSourceJudgment> rawJudgmentClass); @Transactional void deleteMeansOfAppealWithoutJudgments(CourtType courtType); @Transactional void deleteJudgmentResultsWithoutJudgments(CourtType courtType);  }### Answer:
@Test public void deleteJudgmentResultsWithoutJudgments() { Judgment scJudgment = rawJudgmentTestFactory.createCtJudgment(false); Judgment ctJudgment = rawJudgmentTestFactory.createCtJudgment(false); JudgmentResult scJudgmentResult1 = createJudgmentResult(CourtType.SUPREME, "scMeansOfAppeal1"); createMeansOfAppeal(CourtType.SUPREME, "scMeansOfAppeal2"); JudgmentResult ctJudgmentResult1 = createJudgmentResult(CourtType.CONSTITUTIONAL_TRIBUNAL, "ctMeansOfAppeal1"); JudgmentResult ctJudgmentResult2 = createJudgmentResult(CourtType.CONSTITUTIONAL_TRIBUNAL, "ctMeansOfAppeal2"); scJudgment.setJudgmentResult(scJudgmentResult1); ctJudgment.setJudgmentResult(ctJudgmentResult1); judgmentRepository.save(Lists.newArrayList(scJudgment, ctJudgment)); judgmentObjectDeleter.deleteJudgmentResultsWithoutJudgments(CourtType.SUPREME); List<JudgmentResult> dbJudgmentResults = judgmentResultRepository.findAll(); assertThat(dbJudgmentResults, containsInAnyOrder(scJudgmentResult1, ctJudgmentResult1, ctJudgmentResult2)); }