@Test public void search_JudgmentsFound_WithGeneratedFalse() { Judgment ccJudgment = TestInMemoryObjectFactory.createCcJudgment(); Whitebox.setInternalState(ccJudgment, "id", 19l); List<Judgment> judgments = Lists.newArrayList(ccJudgment); searchResult = new SearchResult<Judgment>(judgments, 1l, 0, 10); searchFilter.setWithGenerated(false); Mockito.<SearchResult<Judgment>>when(databaseSearchService.search(searchFilter)).thenReturn(searchResult); judgmentEnrichmentDbSearchService.search(searchFilter); verify(databaseSearchService).search(searchFilter); verifyZeroInteractions(enrichmentTagRepository, judgmentEnrichmentService); }
public SearchResult<Judgment> search(JudgmentSearchFilter searchFilter) { Preconditions.checkNotNull(searchFilter); SearchResult<Judgment> searchResult = databaseSearchService.search(searchFilter); if (searchFilter.isWithGenerated() != null && !searchFilter.isWithGenerated()) { return searchResult; } if (CollectionUtils.isEmpty(searchResult.getResultRecords())) { return searchResult; } List<Judgment> judgments = searchResult.getResultRecords(); List<EnrichmentTag> enrichmentTags = enrichmentTagRepository.findAllByJudgmentIds(extractJudgmentIds(judgments)); for (Judgment judgment : judgments) { List<EnrichmentTag> judgmentEnrichmentTags = extractEnrichmentTags(enrichmentTags, judgment); judgmentEnrichmentService.enrich(judgment, judgmentEnrichmentTags); } return searchResult; }
JudgmentEnrichmentDbSearchService { public SearchResult<Judgment> search(JudgmentSearchFilter searchFilter) { Preconditions.checkNotNull(searchFilter); SearchResult<Judgment> searchResult = databaseSearchService.search(searchFilter); if (searchFilter.isWithGenerated() != null && !searchFilter.isWithGenerated()) { return searchResult; } if (CollectionUtils.isEmpty(searchResult.getResultRecords())) { return searchResult; } List<Judgment> judgments = searchResult.getResultRecords(); List<EnrichmentTag> enrichmentTags = enrichmentTagRepository.findAllByJudgmentIds(extractJudgmentIds(judgments)); for (Judgment judgment : judgments) { List<EnrichmentTag> judgmentEnrichmentTags = extractEnrichmentTags(enrichmentTags, judgment); judgmentEnrichmentService.enrich(judgment, judgmentEnrichmentTags); } return searchResult; } }
JudgmentEnrichmentDbSearchService { public SearchResult<Judgment> search(JudgmentSearchFilter searchFilter) { Preconditions.checkNotNull(searchFilter); SearchResult<Judgment> searchResult = databaseSearchService.search(searchFilter); if (searchFilter.isWithGenerated() != null && !searchFilter.isWithGenerated()) { return searchResult; } if (CollectionUtils.isEmpty(searchResult.getResultRecords())) { return searchResult; } List<Judgment> judgments = searchResult.getResultRecords(); List<EnrichmentTag> enrichmentTags = enrichmentTagRepository.findAllByJudgmentIds(extractJudgmentIds(judgments)); for (Judgment judgment : judgments) { List<EnrichmentTag> judgmentEnrichmentTags = extractEnrichmentTags(enrichmentTags, judgment); judgmentEnrichmentService.enrich(judgment, judgmentEnrichmentTags); } return searchResult; }  }
JudgmentEnrichmentDbSearchService { public SearchResult<Judgment> search(JudgmentSearchFilter searchFilter) { Preconditions.checkNotNull(searchFilter); SearchResult<Judgment> searchResult = databaseSearchService.search(searchFilter); if (searchFilter.isWithGenerated() != null && !searchFilter.isWithGenerated()) { return searchResult; } if (CollectionUtils.isEmpty(searchResult.getResultRecords())) { return searchResult; } List<Judgment> judgments = searchResult.getResultRecords(); List<EnrichmentTag> enrichmentTags = enrichmentTagRepository.findAllByJudgmentIds(extractJudgmentIds(judgments)); for (Judgment judgment : judgments) { List<EnrichmentTag> judgmentEnrichmentTags = extractEnrichmentTags(enrichmentTags, judgment); judgmentEnrichmentService.enrich(judgment, judgmentEnrichmentTags); } return searchResult; }  SearchResult<Judgment> search(JudgmentSearchFilter searchFilter); @Autowired void setDatabaseSearchService(DatabaseSearchService databaseSearchService); @Autowired void setEnrichmentTagRepository(EnrichmentTagRepository enrichmentTagRepository); @Autowired void setJudgmentEnrichmentService(JudgmentEnrichmentService judgmentEnrichmentService); }
JudgmentEnrichmentDbSearchService { public SearchResult<Judgment> search(JudgmentSearchFilter searchFilter) { Preconditions.checkNotNull(searchFilter); SearchResult<Judgment> searchResult = databaseSearchService.search(searchFilter); if (searchFilter.isWithGenerated() != null && !searchFilter.isWithGenerated()) { return searchResult; } if (CollectionUtils.isEmpty(searchResult.getResultRecords())) { return searchResult; } List<Judgment> judgments = searchResult.getResultRecords(); List<EnrichmentTag> enrichmentTags = enrichmentTagRepository.findAllByJudgmentIds(extractJudgmentIds(judgments)); for (Judgment judgment : judgments) { List<EnrichmentTag> judgmentEnrichmentTags = extractEnrichmentTags(enrichmentTags, judgment); judgmentEnrichmentService.enrich(judgment, judgmentEnrichmentTags); } return searchResult; }  SearchResult<Judgment> search(JudgmentSearchFilter searchFilter); @Autowired void setDatabaseSearchService(DatabaseSearchService databaseSearchService); @Autowired void setEnrichmentTagRepository(EnrichmentTagRepository enrichmentTagRepository); @Autowired void setJudgmentEnrichmentService(JudgmentEnrichmentService judgmentEnrichmentService);  }