@Test public void findRemovedJudgments() { List<String> sourceIdsPage1 = Lists.newArrayList("sourceId_1", "sourceId_2", "sourceId_3"); List<String> sourceIdsPage2 = Lists.newArrayList("sourceId_4", "sourceId_5"); when(judgmentRepository.findAllIdsBySourceCode(SourceCode.COMMON_COURT)).thenReturn(Lists.newArrayList(1L, 3L, 4L, 6L, 7L)); when(sourceCcjExternalRepository.findJudgmentIds(0, 3, null)).thenReturn(sourceIdsPage1); when(sourceCcjExternalRepository.findJudgmentIds(1, 3, null)).thenReturn(sourceIdsPage2); when(sourceCcjExternalRepository.findJudgmentIds(2, 3, null)).thenReturn(Lists.newArrayList()); when(judgmentRepository.findAllIdsBySourceCodeAndSourceJudgmentIds(SourceCode.COMMON_COURT, Lists.newArrayList("sourceId_1", "sourceId_2"))) .thenReturn(Lists.newArrayList(1L)); when(judgmentRepository.findAllIdsBySourceCodeAndSourceJudgmentIds(SourceCode.COMMON_COURT, Lists.newArrayList("sourceId_3"))) .thenReturn(Lists.newArrayList(3L)); when(judgmentRepository.findAllIdsBySourceCodeAndSourceJudgmentIds(SourceCode.COMMON_COURT, sourceIdsPage2)) .thenReturn(Lists.newArrayList(4L)); List<Long> removedSourceIds = ccRemovedJudgmentsFinder.findCcRemovedJudgmentSourceIds(); assertThat(removedSourceIds, containsInAnyOrder(6L, 7L)); }
public List<Long> findCcRemovedJudgmentSourceIds() { log.info("Searching for ccJudgments removed from external repository"); List<Long> removedJudgmentsIds = judgmentRepository.findAllIdsBySourceCode(SourceCode.COMMON_COURT); int pageNumber = 0; while(true) { List<String> judgmentExternalIdsPage = sourceCcjExternalRepository.findJudgmentIds(pageNumber, externalRepositoryPageSize, null); log.info("Downloaded {} judgment ids from external repository", (pageNumber*externalRepositoryPageSize) + judgmentExternalIdsPage.size()); if (judgmentExternalIdsPage.isEmpty()) { break; } List<Long> judgmentIdsPage = findCorrespondingJudgmentIds(judgmentExternalIdsPage); removedJudgmentsIds.removeAll(judgmentIdsPage); ++pageNumber; } return removedJudgmentsIds; }
CcRemovedJudgmentsFinder { public List<Long> findCcRemovedJudgmentSourceIds() { log.info("Searching for ccJudgments removed from external repository"); List<Long> removedJudgmentsIds = judgmentRepository.findAllIdsBySourceCode(SourceCode.COMMON_COURT); int pageNumber = 0; while(true) { List<String> judgmentExternalIdsPage = sourceCcjExternalRepository.findJudgmentIds(pageNumber, externalRepositoryPageSize, null); log.info("Downloaded {} judgment ids from external repository", (pageNumber*externalRepositoryPageSize) + judgmentExternalIdsPage.size()); if (judgmentExternalIdsPage.isEmpty()) { break; } List<Long> judgmentIdsPage = findCorrespondingJudgmentIds(judgmentExternalIdsPage); removedJudgmentsIds.removeAll(judgmentIdsPage); ++pageNumber; } return removedJudgmentsIds; } }
CcRemovedJudgmentsFinder { public List<Long> findCcRemovedJudgmentSourceIds() { log.info("Searching for ccJudgments removed from external repository"); List<Long> removedJudgmentsIds = judgmentRepository.findAllIdsBySourceCode(SourceCode.COMMON_COURT); int pageNumber = 0; while(true) { List<String> judgmentExternalIdsPage = sourceCcjExternalRepository.findJudgmentIds(pageNumber, externalRepositoryPageSize, null); log.info("Downloaded {} judgment ids from external repository", (pageNumber*externalRepositoryPageSize) + judgmentExternalIdsPage.size()); if (judgmentExternalIdsPage.isEmpty()) { break; } List<Long> judgmentIdsPage = findCorrespondingJudgmentIds(judgmentExternalIdsPage); removedJudgmentsIds.removeAll(judgmentIdsPage); ++pageNumber; } return removedJudgmentsIds; }  }
CcRemovedJudgmentsFinder { public List<Long> findCcRemovedJudgmentSourceIds() { log.info("Searching for ccJudgments removed from external repository"); List<Long> removedJudgmentsIds = judgmentRepository.findAllIdsBySourceCode(SourceCode.COMMON_COURT); int pageNumber = 0; while(true) { List<String> judgmentExternalIdsPage = sourceCcjExternalRepository.findJudgmentIds(pageNumber, externalRepositoryPageSize, null); log.info("Downloaded {} judgment ids from external repository", (pageNumber*externalRepositoryPageSize) + judgmentExternalIdsPage.size()); if (judgmentExternalIdsPage.isEmpty()) { break; } List<Long> judgmentIdsPage = findCorrespondingJudgmentIds(judgmentExternalIdsPage); removedJudgmentsIds.removeAll(judgmentIdsPage); ++pageNumber; } return removedJudgmentsIds; }  List<Long> findCcRemovedJudgmentSourceIds(); @Autowired void setSourceCcjExternalRepository(SourceCcjExternalRepository sourceCcjExternalRepository); @Autowired void setJudgmentRepository(JudgmentRepository judgmentRepository); void setExternalRepositoryPageSize(int externalRepositoryPageSize); }
CcRemovedJudgmentsFinder { public List<Long> findCcRemovedJudgmentSourceIds() { log.info("Searching for ccJudgments removed from external repository"); List<Long> removedJudgmentsIds = judgmentRepository.findAllIdsBySourceCode(SourceCode.COMMON_COURT); int pageNumber = 0; while(true) { List<String> judgmentExternalIdsPage = sourceCcjExternalRepository.findJudgmentIds(pageNumber, externalRepositoryPageSize, null); log.info("Downloaded {} judgment ids from external repository", (pageNumber*externalRepositoryPageSize) + judgmentExternalIdsPage.size()); if (judgmentExternalIdsPage.isEmpty()) { break; } List<Long> judgmentIdsPage = findCorrespondingJudgmentIds(judgmentExternalIdsPage); removedJudgmentsIds.removeAll(judgmentIdsPage); ++pageNumber; } return removedJudgmentsIds; }  List<Long> findCcRemovedJudgmentSourceIds(); @Autowired void setSourceCcjExternalRepository(SourceCcjExternalRepository sourceCcjExternalRepository); @Autowired void setJudgmentRepository(JudgmentRepository judgmentRepository); void setExternalRepositoryPageSize(int externalRepositoryPageSize);  }