ConstantThresholdDetectorFactoryProvider implements DetectorFactoryProvider<ConstantThresholdDetector> { @Override public ConstantThresholdDetector buildDetector(DetectorDocument document) { notNull(document, "document can't be null"); val params = parseParams(document); return new ConstantThresholdDetector(document.getUuid(), params, document.isTrusted()); }  @Override ConstantThresholdDetector buildDetector(DetectorDocument document);  }
@Test public void testBuildDetector() { val factoryUnderTest = new ConstantThresholdDetectorFactoryProvider(); val document = readDocument("constant-threshold"); val detector = factoryUnderTest.buildDetector(document); val params = detector.getParams(); val thresholds = params.getThresholds(); assertNotNull(detector); assertSame(ConstantThresholdDetector.class, detector.getClass()); assertEquals("e2e290a0-d1c1-471e-9d72-79d43282cfbd", detector.getUuid().toString()); assertEquals(AnomalyType.RIGHT_TAILED, params.getType()); assertEquals(16666.0, thresholds.getUpperStrong(), TOLERANCE); assertEquals(2161.0, thresholds.getUpperWeak(), TOLERANCE); }
@Test public void testBuildDetectorWithFilters() { val factoryUnderTest = new ConstantThresholdDetectorFactoryProvider(); val document = readDocument("constant-threshold-9amTo5pm-filter"); val detector = factoryUnderTest.buildDetector(document); assertNotNull(detector); assertSame(ConstantThresholdDetector.class, detector.getClass()); assertEquals("42d242d2-42d2-42d2-42d2-42d242d242d2", detector.getUuid().toString()); }
@Test(expected = RuntimeException.class) public void testBuildDetector_invalidParams() { val factory = new ConstantThresholdDetectorFactoryProvider(); val document = readDocument("constant-threshold-invalid-params"); factory.buildDetector(document); }