DetectorController { @GetMapping(path = "/getDetectorsToTrain", produces = "application/json") @ResponseStatus(HttpStatus.OK) public List<Detector> getDetectorsToTrain(@RequestParam Long timestampMs, @RequestHeader HttpHeaders headers) { SpanContext parentSpanContext = trace.extractParentSpan(headers); Span span = trace.startSpan("find-detectors-to-train-next", parentSpanContext); val detectorList = service.getDetectorsToBeTrained(timestampMs); span.finish(); return detectorList; }  @PostMapping @ResponseStatus(HttpStatus.CREATED) String createDetector(@Valid @RequestBody Detector detector, @RequestHeader HttpHeaders headers); @GetMapping(path = "/findByUuid", produces = "application/json") @ResponseStatus(HttpStatus.OK) Detector findByUuid(@RequestParam String uuid, @RequestHeader HttpHeaders headers); @GetMapping(path = "/findByCreatedBy", produces = "application/json") @ResponseStatus(HttpStatus.OK) List<Detector> findByCreatedBy(@RequestParam String user); @PostMapping(path = "/toggleDetector") @ResponseStatus(HttpStatus.OK) void toggleDetector(@RequestParam String uuid, @RequestParam Boolean enabled); @PostMapping(path = "/trustDetector") @ResponseStatus(HttpStatus.OK) void trustDetector(@RequestParam String uuid, @RequestParam Boolean trusted); @GetMapping(path = "/getLastUpdatedDetectors", produces = "application/json") @ResponseStatus(HttpStatus.OK) List<Detector> getLastUpdatedDetectors(@RequestParam long interval); @GetMapping(path = "/getLastUsedDetectors", produces = "application/json") @ResponseStatus(HttpStatus.OK) List<Detector> getLastUsedDetectors(@RequestParam int noOfDays); @PutMapping @ResponseStatus(HttpStatus.OK) void updateDetector(@RequestParam String uuid, @RequestBody Detector detector); @PostMapping(path = "/updateDetectorLastUsed", consumes = "application/json", produces = "application/json") @ResponseStatus(HttpStatus.OK) void updatedDetectorLastUsed(@RequestBody Map<String, String> params); @DeleteMapping @ResponseStatus(HttpStatus.OK) void deleteDetector(@RequestParam String uuid); @GetMapping(path = "/getDetectorsToTrain", produces = "application/json") @ResponseStatus(HttpStatus.OK) List<Detector> getDetectorsToTrain(@RequestParam Long timestampMs, @RequestHeader HttpHeaders headers); @PostMapping(path = "/updateDetectorTrainingTime") void updateDetectorTrainingTime(@RequestParam String uuid,
                                           @RequestParam Long nextRun,
                                           @RequestHeader HttpHeaders headers);  }
@Test public void testGetDetectorsToTrain() { val testDetectorMappingSpanContext = new SpanContext(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()); val testChildSpan = noOpsTracer.buildSpan("find-detectors-to-train-next").asChildOf(testDetectorMappingSpanContext).start(); when(trace.extractParentSpan(httpHeaders)).thenReturn(testDetectorMappingSpanContext); when(trace.startSpan("find-detectors-to-train-next", testDetectorMappingSpanContext)).thenReturn(testChildSpan); controllerUnderTest.getDetectorsToTrain(1595152176000L, httpHeaders); verify(detectorService, times(1)).getDetectorsToBeTrained(1595152176000L); }