@Test public void testFindMatchingByTags() { val lookupTime = 60; List<Map<String, String>> tagsList = new ArrayList<>(); MatchingDetectorsResponse mockMatchingDetectorsResponse = mockMatchingDetectorsResponse(lookupTime, detectorUuid); when(detectorMappingRepo.findMatchingDetectorMappings(tagsList)).thenReturn(mockMatchingDetectorsResponse); MatchingDetectorsResponse matchingDetectorsResult = controllerUnderTest.searchDetectorMapping(tagsList); Assert.assertEquals(1, matchingDetectorsResult.getGroupedDetectorsBySearchIndex().size()); List<ConsumerDetectorMapping> consumerDetectorMappings = matchingDetectorsResult.getGroupedDetectorsBySearchIndex().get(1); assertEquals(1, consumerDetectorMappings.size()); assertEquals(UUID.fromString(detectorUuid), consumerDetectorMappings.get(0).getUuid()); }
@RequestMapping(value = "/search", method = RequestMethod.POST) public List<DetectorMapping> searchDetectorMapping(@RequestBody SearchMappingsRequest request, @RequestHeader HttpHeaders httpHeaders) { SpanContext parentSpanContext = trace.extractParentSpan(httpHeaders); Span span = trace.startSpan("mappings-search", parentSpanContext); AssertUtil.isTrue(request.getUserId() != null || request.getDetectorUuid() != null, "User id and Detector UUID can't both be null"); List<DetectorMapping> resultSearchDetectorMapping = detectorMappingRepo.search(request); span.finish(); return resultSearchDetectorMapping; }
DetectorMappingController { @RequestMapping(value = "/search", method = RequestMethod.POST) public List<DetectorMapping> searchDetectorMapping(@RequestBody SearchMappingsRequest request, @RequestHeader HttpHeaders httpHeaders) { SpanContext parentSpanContext = trace.extractParentSpan(httpHeaders); Span span = trace.startSpan("mappings-search", parentSpanContext); AssertUtil.isTrue(request.getUserId() != null || request.getDetectorUuid() != null, "User id and Detector UUID can't both be null"); List<DetectorMapping> resultSearchDetectorMapping = detectorMappingRepo.search(request); span.finish(); return resultSearchDetectorMapping; } }
DetectorMappingController { @RequestMapping(value = "/search", method = RequestMethod.POST) public List<DetectorMapping> searchDetectorMapping(@RequestBody SearchMappingsRequest request, @RequestHeader HttpHeaders httpHeaders) { SpanContext parentSpanContext = trace.extractParentSpan(httpHeaders); Span span = trace.startSpan("mappings-search", parentSpanContext); AssertUtil.isTrue(request.getUserId() != null || request.getDetectorUuid() != null, "User id and Detector UUID can't both be null"); List<DetectorMapping> resultSearchDetectorMapping = detectorMappingRepo.search(request); span.finish(); return resultSearchDetectorMapping; }  }
DetectorMappingController { @RequestMapping(value = "/search", method = RequestMethod.POST) public List<DetectorMapping> searchDetectorMapping(@RequestBody SearchMappingsRequest request, @RequestHeader HttpHeaders httpHeaders) { SpanContext parentSpanContext = trace.extractParentSpan(httpHeaders); Span span = trace.startSpan("mappings-search", parentSpanContext); AssertUtil.isTrue(request.getUserId() != null || request.getDetectorUuid() != null, "User id and Detector UUID can't both be null"); List<DetectorMapping> resultSearchDetectorMapping = detectorMappingRepo.search(request); span.finish(); return resultSearchDetectorMapping; }  @RequestMapping(produces = "application/json", method = RequestMethod.GET) DetectorMapping getDetectorMapping(@RequestParam String id); @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) String createDetectorMapping(@RequestBody CreateDetectorMappingRequest request, @RequestHeader HttpHeaders header); @RequestMapping(value = "/disable", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) void disableDeleteDetectorMapping(@RequestParam String id); @RequestMapping(method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void deleteDetectorMapping(@RequestParam String id); @RequestMapping(value = "/search", method = RequestMethod.POST) List<DetectorMapping> searchDetectorMapping(@RequestBody SearchMappingsRequest request,
                                                       @RequestHeader HttpHeaders httpHeaders); @RequestMapping(value = "/lastUpdated", method = RequestMethod.GET) List<DetectorMapping> findDetectorMapping(@RequestParam int timeInSecs); @RequestMapping(value = "/findMatchingByTags", method = RequestMethod.POST) MatchingDetectorsResponse searchDetectorMapping(@RequestBody List<Map<String, String>> tagsList); @RequestMapping(value = "/deleteMappingsByDetectorUuid", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void deleteMappingsByDetectorUUID(@RequestParam UUID uuid); }
DetectorMappingController { @RequestMapping(value = "/search", method = RequestMethod.POST) public List<DetectorMapping> searchDetectorMapping(@RequestBody SearchMappingsRequest request, @RequestHeader HttpHeaders httpHeaders) { SpanContext parentSpanContext = trace.extractParentSpan(httpHeaders); Span span = trace.startSpan("mappings-search", parentSpanContext); AssertUtil.isTrue(request.getUserId() != null || request.getDetectorUuid() != null, "User id and Detector UUID can't both be null"); List<DetectorMapping> resultSearchDetectorMapping = detectorMappingRepo.search(request); span.finish(); return resultSearchDetectorMapping; }  @RequestMapping(produces = "application/json", method = RequestMethod.GET) DetectorMapping getDetectorMapping(@RequestParam String id); @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) String createDetectorMapping(@RequestBody CreateDetectorMappingRequest request, @RequestHeader HttpHeaders header); @RequestMapping(value = "/disable", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) void disableDeleteDetectorMapping(@RequestParam String id); @RequestMapping(method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void deleteDetectorMapping(@RequestParam String id); @RequestMapping(value = "/search", method = RequestMethod.POST) List<DetectorMapping> searchDetectorMapping(@RequestBody SearchMappingsRequest request,
                                                       @RequestHeader HttpHeaders httpHeaders); @RequestMapping(value = "/lastUpdated", method = RequestMethod.GET) List<DetectorMapping> findDetectorMapping(@RequestParam int timeInSecs); @RequestMapping(value = "/findMatchingByTags", method = RequestMethod.POST) MatchingDetectorsResponse searchDetectorMapping(@RequestBody List<Map<String, String>> tagsList); @RequestMapping(value = "/deleteMappingsByDetectorUuid", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void deleteMappingsByDetectorUUID(@RequestParam UUID uuid);  }