@Test public void testBuildDetector() { val factoryUnderTest = new LegacySeasonalNaiveDetectorFactoryProvider(); val document = readDocument("seasonal-naive"); val detector = factoryUnderTest.buildDetector(document); val seasonalNaive = (SeasonalNaivePointForecaster) detector.getPointForecaster(); val seasonalNaiveParams = seasonalNaive.getParams(); val multiplicative = (MultiplicativeIntervalForecaster) detector.getIntervalForecaster(); val multiplicativeParams = multiplicative.getParams(); assertEquals(ForecastingDetector.class, detector.getClass()); assertEquals("6ec81aa2-2cdc-415e-b4f3-abc123cba321", detector.getUuid().toString()); assertEquals(AnomalyType.RIGHT_TAILED, detector.getAnomalyType()); assertEquals(ONE_WEEK_IN_SECONDS, seasonalNaiveParams.getCycleLength(), TOLERANCE); assertEquals(ONE_MINUTE_IN_SECONDS, seasonalNaiveParams.getIntervalLength(), TOLERANCE); assertEquals(DEFAULT_MISSING_VALUE_PLACEHOLDER, seasonalNaiveParams.getMissingValuePlaceholder(), TOLERANCE); assertEquals(3, multiplicativeParams.getWeakMultiplier(), TOLERANCE); assertEquals(4, multiplicativeParams.getStrongMultiplier(), TOLERANCE); }
@Override public ForecastingDetector buildDetector(DetectorDocument document) { val uuid = document.getUuid(); val config = document.getConfig(); val type = AnomalyType.valueOf((String) config.get("type")); val paramsMap = config.get("params"); val legacyParams = objectMapper.convertValue(paramsMap, LegacySeasonalNaiveDetectorParams.class); val seasonalNaiveParams = legacyParams.toSeasonalNaiveParams(); val multiplicativeParams = legacyParams.toMultiplicativeParams(); val seasonalNaive = new SeasonalNaivePointForecaster(seasonalNaiveParams); val multiplicativeIntervalForecaster = new MultiplicativeIntervalForecaster(multiplicativeParams); val trusted = document.isTrusted(); return new ForecastingDetector(uuid, seasonalNaive, multiplicativeIntervalForecaster, type, trusted, "seasonalnaive"); }
LegacySeasonalNaiveDetectorFactoryProvider implements DetectorFactoryProvider<ForecastingDetector> { @Override public ForecastingDetector buildDetector(DetectorDocument document) { val uuid = document.getUuid(); val config = document.getConfig(); val type = AnomalyType.valueOf((String) config.get("type")); val paramsMap = config.get("params"); val legacyParams = objectMapper.convertValue(paramsMap, LegacySeasonalNaiveDetectorParams.class); val seasonalNaiveParams = legacyParams.toSeasonalNaiveParams(); val multiplicativeParams = legacyParams.toMultiplicativeParams(); val seasonalNaive = new SeasonalNaivePointForecaster(seasonalNaiveParams); val multiplicativeIntervalForecaster = new MultiplicativeIntervalForecaster(multiplicativeParams); val trusted = document.isTrusted(); return new ForecastingDetector(uuid, seasonalNaive, multiplicativeIntervalForecaster, type, trusted, "seasonalnaive"); } }
LegacySeasonalNaiveDetectorFactoryProvider implements DetectorFactoryProvider<ForecastingDetector> { @Override public ForecastingDetector buildDetector(DetectorDocument document) { val uuid = document.getUuid(); val config = document.getConfig(); val type = AnomalyType.valueOf((String) config.get("type")); val paramsMap = config.get("params"); val legacyParams = objectMapper.convertValue(paramsMap, LegacySeasonalNaiveDetectorParams.class); val seasonalNaiveParams = legacyParams.toSeasonalNaiveParams(); val multiplicativeParams = legacyParams.toMultiplicativeParams(); val seasonalNaive = new SeasonalNaivePointForecaster(seasonalNaiveParams); val multiplicativeIntervalForecaster = new MultiplicativeIntervalForecaster(multiplicativeParams); val trusted = document.isTrusted(); return new ForecastingDetector(uuid, seasonalNaive, multiplicativeIntervalForecaster, type, trusted, "seasonalnaive"); }  }
LegacySeasonalNaiveDetectorFactoryProvider implements DetectorFactoryProvider<ForecastingDetector> { @Override public ForecastingDetector buildDetector(DetectorDocument document) { val uuid = document.getUuid(); val config = document.getConfig(); val type = AnomalyType.valueOf((String) config.get("type")); val paramsMap = config.get("params"); val legacyParams = objectMapper.convertValue(paramsMap, LegacySeasonalNaiveDetectorParams.class); val seasonalNaiveParams = legacyParams.toSeasonalNaiveParams(); val multiplicativeParams = legacyParams.toMultiplicativeParams(); val seasonalNaive = new SeasonalNaivePointForecaster(seasonalNaiveParams); val multiplicativeIntervalForecaster = new MultiplicativeIntervalForecaster(multiplicativeParams); val trusted = document.isTrusted(); return new ForecastingDetector(uuid, seasonalNaive, multiplicativeIntervalForecaster, type, trusted, "seasonalnaive"); }  @Override ForecastingDetector buildDetector(DetectorDocument document); }
LegacySeasonalNaiveDetectorFactoryProvider implements DetectorFactoryProvider<ForecastingDetector> { @Override public ForecastingDetector buildDetector(DetectorDocument document) { val uuid = document.getUuid(); val config = document.getConfig(); val type = AnomalyType.valueOf((String) config.get("type")); val paramsMap = config.get("params"); val legacyParams = objectMapper.convertValue(paramsMap, LegacySeasonalNaiveDetectorParams.class); val seasonalNaiveParams = legacyParams.toSeasonalNaiveParams(); val multiplicativeParams = legacyParams.toMultiplicativeParams(); val seasonalNaive = new SeasonalNaivePointForecaster(seasonalNaiveParams); val multiplicativeIntervalForecaster = new MultiplicativeIntervalForecaster(multiplicativeParams); val trusted = document.isTrusted(); return new ForecastingDetector(uuid, seasonalNaive, multiplicativeIntervalForecaster, type, trusted, "seasonalnaive"); }  @Override ForecastingDetector buildDetector(DetectorDocument document);  }