NaivePointForecaster implements PointForecaster { @Override public PointForecast forecast(MetricData metricData) { notNull(metricData, "metricData can't be null"); val forecastMetricData = lastMetricData; this.lastMetricData = metricData; return forecastMetricData == null ? null : new PointForecast(forecastMetricData.getValue(), false); }  @Override PointForecast forecast(MetricData metricData);  }
@Test public void testForecast() { double currValue = random.nextDouble(); MetricData metricData = new MetricData(metricDef, currValue, 0); PointForecast forecast = forecasterUnderTest.forecast(metricData); assertNull(forecast); for (int i = 0; i < 10; i++) { val prevValue = currValue; currValue = random.nextDouble(); metricData = new MetricData(metricDef, currValue, 0); forecast = forecasterUnderTest.forecast(metricData); assertEquals(forecast.getValue(), prevValue, TOLERANCE); } }
@Test(expected = IllegalArgumentException.class) public void testForecast_nullMetricData() { forecasterUnderTest.forecast(null); }