@Test public void testCreateDetectorMapping() { val mom = ObjectMother.instance(); val expr = mom.getExpression(); val consumerDetectorMapping = new ConsumerDetectorMapping("cid", UUID.randomUUID()); val user = new User("yoda"); val request = new CreateDetectorMappingRequest(expr, consumerDetectorMapping, user); repoUnderTest.createDetectorMapping(request); }
@Override public String createDetectorMapping(CreateDetectorMappingRequest request) { val indexName = elasticSearchProperties.getIndexName(); val docType = elasticSearchProperties.getDocType(); val fields = request.getFields(); val newFieldMappings = elasticsearchUtil.removeFieldsHavingExistingMapping(fields, indexName, docType); elasticsearchUtil.updateIndexMappings(newFieldMappings, indexName, docType); val indexRequest = new IndexRequest(indexName, docType); val now = System.currentTimeMillis(); val mapping = new PercolatorDetectorMapping() .setUser(request.getUser()) .setConsumerDetectorMapping(request.getConsumerDetectorMapping()) .setQuery(QueryUtil.buildQuery(request.getExpression())) .setEnabled(true) .setLastModifiedTimeInMillis(now) .setCreatedTimeInMillis(now); val mappingJson = objectMapperUtil.convertToString(mapping); return elasticsearchUtil.index(indexRequest, mappingJson).getId(); }
DetectorMappingRepositoryImpl implements DetectorMappingRepository { @Override public String createDetectorMapping(CreateDetectorMappingRequest request) { val indexName = elasticSearchProperties.getIndexName(); val docType = elasticSearchProperties.getDocType(); val fields = request.getFields(); val newFieldMappings = elasticsearchUtil.removeFieldsHavingExistingMapping(fields, indexName, docType); elasticsearchUtil.updateIndexMappings(newFieldMappings, indexName, docType); val indexRequest = new IndexRequest(indexName, docType); val now = System.currentTimeMillis(); val mapping = new PercolatorDetectorMapping() .setUser(request.getUser()) .setConsumerDetectorMapping(request.getConsumerDetectorMapping()) .setQuery(QueryUtil.buildQuery(request.getExpression())) .setEnabled(true) .setLastModifiedTimeInMillis(now) .setCreatedTimeInMillis(now); val mappingJson = objectMapperUtil.convertToString(mapping); return elasticsearchUtil.index(indexRequest, mappingJson).getId(); } }
DetectorMappingRepositoryImpl implements DetectorMappingRepository { @Override public String createDetectorMapping(CreateDetectorMappingRequest request) { val indexName = elasticSearchProperties.getIndexName(); val docType = elasticSearchProperties.getDocType(); val fields = request.getFields(); val newFieldMappings = elasticsearchUtil.removeFieldsHavingExistingMapping(fields, indexName, docType); elasticsearchUtil.updateIndexMappings(newFieldMappings, indexName, docType); val indexRequest = new IndexRequest(indexName, docType); val now = System.currentTimeMillis(); val mapping = new PercolatorDetectorMapping() .setUser(request.getUser()) .setConsumerDetectorMapping(request.getConsumerDetectorMapping()) .setQuery(QueryUtil.buildQuery(request.getExpression())) .setEnabled(true) .setLastModifiedTimeInMillis(now) .setCreatedTimeInMillis(now); val mappingJson = objectMapperUtil.convertToString(mapping); return elasticsearchUtil.index(indexRequest, mappingJson).getId(); } @Autowired  DetectorMappingRepositoryImpl(MetricRegistry metricRegistry); }
DetectorMappingRepositoryImpl implements DetectorMappingRepository { @Override public String createDetectorMapping(CreateDetectorMappingRequest request) { val indexName = elasticSearchProperties.getIndexName(); val docType = elasticSearchProperties.getDocType(); val fields = request.getFields(); val newFieldMappings = elasticsearchUtil.removeFieldsHavingExistingMapping(fields, indexName, docType); elasticsearchUtil.updateIndexMappings(newFieldMappings, indexName, docType); val indexRequest = new IndexRequest(indexName, docType); val now = System.currentTimeMillis(); val mapping = new PercolatorDetectorMapping() .setUser(request.getUser()) .setConsumerDetectorMapping(request.getConsumerDetectorMapping()) .setQuery(QueryUtil.buildQuery(request.getExpression())) .setEnabled(true) .setLastModifiedTimeInMillis(now) .setCreatedTimeInMillis(now); val mappingJson = objectMapperUtil.convertToString(mapping); return elasticsearchUtil.index(indexRequest, mappingJson).getId(); } @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 String createDetectorMapping(CreateDetectorMappingRequest request) { val indexName = elasticSearchProperties.getIndexName(); val docType = elasticSearchProperties.getDocType(); val fields = request.getFields(); val newFieldMappings = elasticsearchUtil.removeFieldsHavingExistingMapping(fields, indexName, docType); elasticsearchUtil.updateIndexMappings(newFieldMappings, indexName, docType); val indexRequest = new IndexRequest(indexName, docType); val now = System.currentTimeMillis(); val mapping = new PercolatorDetectorMapping() .setUser(request.getUser()) .setConsumerDetectorMapping(request.getConsumerDetectorMapping()) .setQuery(QueryUtil.buildQuery(request.getExpression())) .setEnabled(true) .setLastModifiedTimeInMillis(now) .setCreatedTimeInMillis(now); val mappingJson = objectMapperUtil.convertToString(mapping); return elasticsearchUtil.index(indexRequest, mappingJson).getId(); } @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);  }