CusumDetectorFactoryProvider implements DetectorFactoryProvider<CusumDetector> { @Override public CusumDetector buildDetector(DetectorDocument document) { notNull(document, "document can't be null"); val paramsMap = document.getConfig().get("params"); val params = objectMapper.convertValue(paramsMap, CusumDetectorParams.class); val trusted = document.isTrusted(); return new CusumDetector(document.getUuid(), params, trusted); }  @Override CusumDetector buildDetector(DetectorDocument document);  }
@Test public void testBuildDetector() { val factoryUnderTest = new CusumDetectorFactoryProvider(); val document = readDocument("cusum"); val detector = factoryUnderTest.buildDetector(document); val params = detector.getParams(); assertNotNull(detector); assertEquals(CusumDetector.class, detector.getClass()); assertEquals("3ec81aa2-2cdc-415e-b4f3-c1beb223ae60", detector.getUuid().toString()); assertEquals(120.0, params.getTargetValue(), TOLERANCE); assertEquals(0.8, params.getSlackParam(), TOLERANCE); assertEquals(110.0, params.getInitMeanEstimate(), TOLERANCE); assertEquals(AnomalyType.RIGHT_TAILED, params.getType()); assertEquals(2.5, params.getWeakSigmas(), TOLERANCE); assertEquals(3.5, params.getStrongSigmas(), TOLERANCE); }