### Question:
ReferencingJudgmentsService { public long fetchReferencingJudgmentsCount(long judgmentId) { JudgmentCriteria criteria = new JudgmentCriteria(); criteria.setReferencedCourtCaseId(judgmentId); Paging paging = new Paging(0, 0); SearchResults<JudgmentSearchResult> results = judgmentSearchService.search(criteria, paging); return results.getTotalResults(); }  long fetchReferencingJudgmentsCount(long judgmentId); @Autowired void setJudgmentSearchService(JudgmentSearchService judgmentSearchService);  }### Answer:
@Test public void fetchReferencingJudgmentsCount() { SearchResults<JudgmentSearchResult> results = new SearchResults<JudgmentSearchResult>(); results.setTotalResults(28L); when(judgmentSearchService.search(any(), any())).thenReturn(results); long count = referencingJudgmentsService.fetchReferencingJudgmentsCount(15L); assertEquals(28L, count); verify(judgmentSearchService).search(JudgmentCriteriaBuilder.create().withReferencedCourtCaseId(15L).build(), new Paging(0, 0)); }