@Test public void doFilterWithChain_ensureChainKeepsResultFromFilter() { DetectionFilter stubDetectionFilter = (detectorRequest, detectorResponse, chain) -> detectorResponse.setDetectorResult(detectorResult); DetectorContainer detectorContainer = new DetectorContainer(detector, ImmutableList.of(stubDetectionFilter)); chainUnderTest = new DetectionFilterChain(detectorContainer); DetectorResponse actualDetectorResponse = new DetectorResponse(); chainUnderTest.doFilter(detectorRequest, actualDetectorResponse); assertSame(detectorResult, actualDetectorResponse.getDetectorResult()); }
public void doFilter(@NonNull DetectorRequest request, @NonNull DetectorResponse response) { if (!filtersIterator.hasNext()) { val result = detector.detect(request.getMetricData()); response.setDetectorResult(result); } else { DetectionFilter f = filtersIterator.next(); f.doFilter(request, response, this); } }
DetectionFilterChain { public void doFilter(@NonNull DetectorRequest request, @NonNull DetectorResponse response) { if (!filtersIterator.hasNext()) { val result = detector.detect(request.getMetricData()); response.setDetectorResult(result); } else { DetectionFilter f = filtersIterator.next(); f.doFilter(request, response, this); } } }
DetectionFilterChain { public void doFilter(@NonNull DetectorRequest request, @NonNull DetectorResponse response) { if (!filtersIterator.hasNext()) { val result = detector.detect(request.getMetricData()); response.setDetectorResult(result); } else { DetectionFilter f = filtersIterator.next(); f.doFilter(request, response, this); } } DetectionFilterChain(DetectorContainer detectorContainer); }
DetectionFilterChain { public void doFilter(@NonNull DetectorRequest request, @NonNull DetectorResponse response) { if (!filtersIterator.hasNext()) { val result = detector.detect(request.getMetricData()); response.setDetectorResult(result); } else { DetectionFilter f = filtersIterator.next(); f.doFilter(request, response, this); } } DetectionFilterChain(DetectorContainer detectorContainer); void doFilter(@NonNull DetectorRequest request, @NonNull DetectorResponse response); }
DetectionFilterChain { public void doFilter(@NonNull DetectorRequest request, @NonNull DetectorResponse response) { if (!filtersIterator.hasNext()) { val result = detector.detect(request.getMetricData()); response.setDetectorResult(result); } else { DetectionFilter f = filtersIterator.next(); f.doFilter(request, response, this); } } DetectionFilterChain(DetectorContainer detectorContainer); void doFilter(@NonNull DetectorRequest request, @NonNull DetectorResponse response);  }