@Test public void deleteFromIndexWithoutCorrespondingJudgmentInDb_EMPTY_INDEX() throws SolrServerException, IOException { when(solrJudgmentsServer.query(any())).thenReturn(createSolrResponse(0, Lists.newArrayList())); judgmentIndexDeleter.deleteFromIndexWithoutCorrespondingJudgmentInDb(); verify(solrJudgmentsServer).query(solrParamsCaptor.capture()); verifyZeroInteractions(judgmentRepository); assertSolrParams(solrParamsCaptor.getValue(), 0, 2); }
public void deleteFromIndexWithoutCorrespondingJudgmentInDb() throws SolrServerException, IOException { int pageNumber = 0; while (true) { SolrQuery query = createIndexIteratingQuery(pageNumber); QueryResponse response = solrJudgmentsServer.query(query); if (response.getResults().size() == 0) { break; } List<Long> indexJudgmentIds = extractIdsFromResult(response); List<Long> existingJudgmentIds = judgmentRepository.filterIdsToExisting(indexJudgmentIds); List<Long> judgmentIdsToDelete = Lists.newArrayList(indexJudgmentIds); judgmentIdsToDelete.removeAll(existingJudgmentIds); if (judgmentIdsToDelete.size() > 0) { log.info("Removing judgments from index which don't have corresponding entry in database: {}", judgmentIdsToDelete); solrJudgmentsServer.deleteById(judgmentIdsToDelete.stream().map(x -> String.valueOf(x)).collect(Collectors.toList())); } ++pageNumber; } }
JudgmentIndexDeleter { public void deleteFromIndexWithoutCorrespondingJudgmentInDb() throws SolrServerException, IOException { int pageNumber = 0; while (true) { SolrQuery query = createIndexIteratingQuery(pageNumber); QueryResponse response = solrJudgmentsServer.query(query); if (response.getResults().size() == 0) { break; } List<Long> indexJudgmentIds = extractIdsFromResult(response); List<Long> existingJudgmentIds = judgmentRepository.filterIdsToExisting(indexJudgmentIds); List<Long> judgmentIdsToDelete = Lists.newArrayList(indexJudgmentIds); judgmentIdsToDelete.removeAll(existingJudgmentIds); if (judgmentIdsToDelete.size() > 0) { log.info("Removing judgments from index which don't have corresponding entry in database: {}", judgmentIdsToDelete); solrJudgmentsServer.deleteById(judgmentIdsToDelete.stream().map(x -> String.valueOf(x)).collect(Collectors.toList())); } ++pageNumber; } } }
JudgmentIndexDeleter { public void deleteFromIndexWithoutCorrespondingJudgmentInDb() throws SolrServerException, IOException { int pageNumber = 0; while (true) { SolrQuery query = createIndexIteratingQuery(pageNumber); QueryResponse response = solrJudgmentsServer.query(query); if (response.getResults().size() == 0) { break; } List<Long> indexJudgmentIds = extractIdsFromResult(response); List<Long> existingJudgmentIds = judgmentRepository.filterIdsToExisting(indexJudgmentIds); List<Long> judgmentIdsToDelete = Lists.newArrayList(indexJudgmentIds); judgmentIdsToDelete.removeAll(existingJudgmentIds); if (judgmentIdsToDelete.size() > 0) { log.info("Removing judgments from index which don't have corresponding entry in database: {}", judgmentIdsToDelete); solrJudgmentsServer.deleteById(judgmentIdsToDelete.stream().map(x -> String.valueOf(x)).collect(Collectors.toList())); } ++pageNumber; } }  }
JudgmentIndexDeleter { public void deleteFromIndexWithoutCorrespondingJudgmentInDb() throws SolrServerException, IOException { int pageNumber = 0; while (true) { SolrQuery query = createIndexIteratingQuery(pageNumber); QueryResponse response = solrJudgmentsServer.query(query); if (response.getResults().size() == 0) { break; } List<Long> indexJudgmentIds = extractIdsFromResult(response); List<Long> existingJudgmentIds = judgmentRepository.filterIdsToExisting(indexJudgmentIds); List<Long> judgmentIdsToDelete = Lists.newArrayList(indexJudgmentIds); judgmentIdsToDelete.removeAll(existingJudgmentIds); if (judgmentIdsToDelete.size() > 0) { log.info("Removing judgments from index which don't have corresponding entry in database: {}", judgmentIdsToDelete); solrJudgmentsServer.deleteById(judgmentIdsToDelete.stream().map(x -> String.valueOf(x)).collect(Collectors.toList())); } ++pageNumber; } }  void deleteFromIndexWithoutCorrespondingJudgmentInDb(); @Autowired void setJudgmentRepository(JudgmentRepository judgmentRepository); @Autowired @Qualifier("solrJudgmentsServer") void setSolrJudgmentsServer(SolrServer solrJudgmentsServer); void setIndexIteratingPageSize(int indexIteratingPageSize); }
JudgmentIndexDeleter { public void deleteFromIndexWithoutCorrespondingJudgmentInDb() throws SolrServerException, IOException { int pageNumber = 0; while (true) { SolrQuery query = createIndexIteratingQuery(pageNumber); QueryResponse response = solrJudgmentsServer.query(query); if (response.getResults().size() == 0) { break; } List<Long> indexJudgmentIds = extractIdsFromResult(response); List<Long> existingJudgmentIds = judgmentRepository.filterIdsToExisting(indexJudgmentIds); List<Long> judgmentIdsToDelete = Lists.newArrayList(indexJudgmentIds); judgmentIdsToDelete.removeAll(existingJudgmentIds); if (judgmentIdsToDelete.size() > 0) { log.info("Removing judgments from index which don't have corresponding entry in database: {}", judgmentIdsToDelete); solrJudgmentsServer.deleteById(judgmentIdsToDelete.stream().map(x -> String.valueOf(x)).collect(Collectors.toList())); } ++pageNumber; } }  void deleteFromIndexWithoutCorrespondingJudgmentInDb(); @Autowired void setJudgmentRepository(JudgmentRepository judgmentRepository); @Autowired @Qualifier("solrJudgmentsServer") void setSolrJudgmentsServer(SolrServer solrJudgmentsServer); void setIndexIteratingPageSize(int indexIteratingPageSize);  }