@Test(expected = RuntimeException.class) public void deleteDetectorMapping_fail() throws IOException { val id = "adsvade8^szx"; DeleteRequest deleteRequest = new DeleteRequest(elasticSearchProperties.getIndexName(), elasticSearchProperties.getDocType(), id); when(legacyElasticSearchClient.delete(any(DeleteRequest.class), eq(RequestOptions.DEFAULT))).thenThrow(new IOException()); repoUnderTest.deleteDetectorMapping(id); }
@Override public void deleteDetectorMapping(String id) { val deleteRequest = new DeleteRequest(elasticSearchProperties.getIndexName(), elasticSearchProperties.getDocType(), id); try { val deleteResponse = legacyElasticSearchClient.delete(deleteRequest, RequestOptions.DEFAULT); if (elasticsearchUtil.checkNullResponse(deleteResponse.getResult())) { throw new RecordNotFoundException("Invalid request: " + id); } } catch (IOException e) { log.error(String.format("Deleting mapping %s failed", id), e); throw new RuntimeException(e); } }
DetectorMappingRepositoryImpl implements DetectorMappingRepository { @Override public void deleteDetectorMapping(String id) { val deleteRequest = new DeleteRequest(elasticSearchProperties.getIndexName(), elasticSearchProperties.getDocType(), id); try { val deleteResponse = legacyElasticSearchClient.delete(deleteRequest, RequestOptions.DEFAULT); if (elasticsearchUtil.checkNullResponse(deleteResponse.getResult())) { throw new RecordNotFoundException("Invalid request: " + id); } } catch (IOException e) { log.error(String.format("Deleting mapping %s failed", id), e); throw new RuntimeException(e); } } }
DetectorMappingRepositoryImpl implements DetectorMappingRepository { @Override public void deleteDetectorMapping(String id) { val deleteRequest = new DeleteRequest(elasticSearchProperties.getIndexName(), elasticSearchProperties.getDocType(), id); try { val deleteResponse = legacyElasticSearchClient.delete(deleteRequest, RequestOptions.DEFAULT); if (elasticsearchUtil.checkNullResponse(deleteResponse.getResult())) { throw new RecordNotFoundException("Invalid request: " + id); } } catch (IOException e) { log.error(String.format("Deleting mapping %s failed", id), e); throw new RuntimeException(e); } } @Autowired  DetectorMappingRepositoryImpl(MetricRegistry metricRegistry); }
DetectorMappingRepositoryImpl implements DetectorMappingRepository { @Override public void deleteDetectorMapping(String id) { val deleteRequest = new DeleteRequest(elasticSearchProperties.getIndexName(), elasticSearchProperties.getDocType(), id); try { val deleteResponse = legacyElasticSearchClient.delete(deleteRequest, RequestOptions.DEFAULT); if (elasticsearchUtil.checkNullResponse(deleteResponse.getResult())) { throw new RecordNotFoundException("Invalid request: " + id); } } catch (IOException e) { log.error(String.format("Deleting mapping %s failed", id), e); throw new RuntimeException(e); } } @Autowired  DetectorMappingRepositoryImpl(MetricRegistry metricRegistry); @Override String createDetectorMapping(CreateDetectorMappingRequest request); @Override MatchingDetectorsResponse findMatchingDetectorMappings(List<Map<String, String>> tagsList); @Override DetectorMapping findDetectorMapping(String id); @Override List<DetectorMapping> findLastUpdated(int timeInSeconds); @Override List<DetectorMapping> search(SearchMappingsRequest request); @Override void disableDetectorMapping(String id); @Override void deleteDetectorMapping(String id); @Override void deleteMappingsByDetectorUUID(UUID uuid); }
DetectorMappingRepositoryImpl implements DetectorMappingRepository { @Override public void deleteDetectorMapping(String id) { val deleteRequest = new DeleteRequest(elasticSearchProperties.getIndexName(), elasticSearchProperties.getDocType(), id); try { val deleteResponse = legacyElasticSearchClient.delete(deleteRequest, RequestOptions.DEFAULT); if (elasticsearchUtil.checkNullResponse(deleteResponse.getResult())) { throw new RecordNotFoundException("Invalid request: " + id); } } catch (IOException e) { log.error(String.format("Deleting mapping %s failed", id), e); throw new RuntimeException(e); } } @Autowired  DetectorMappingRepositoryImpl(MetricRegistry metricRegistry); @Override String createDetectorMapping(CreateDetectorMappingRequest request); @Override MatchingDetectorsResponse findMatchingDetectorMappings(List<Map<String, String>> tagsList); @Override DetectorMapping findDetectorMapping(String id); @Override List<DetectorMapping> findLastUpdated(int timeInSeconds); @Override List<DetectorMapping> search(SearchMappingsRequest request); @Override void disableDetectorMapping(String id); @Override void deleteDetectorMapping(String id); @Override void deleteMappingsByDetectorUUID(UUID uuid);  }