GraphiteSource implements DataSource { @Override public List<DataSourceResult> getMetricData(long earliestTime, long latestTime, int intervalLength, String target) { return buildDataSourceResult(earliestTime, latestTime, intervalLength, target); }  @Override List<DataSourceResult> getMetricData(long earliestTime, long latestTime, int intervalLength, String target); static final Double MISSING_VALUE; }
@Test public void testGetMetricData_seven_days() { val windowLength = 7; val latestTimeInEpoch = earliestTimeInEpoch + windowLength * TimeConstantsUtil.SECONDS_PER_DAY; val expected = buildExpectedResults(earliestTimeInEpoch, windowLength); val actual = sourceUnderTest.getMetricData(earliestTimeInEpoch, latestTimeInEpoch, intervalLength, "metric_name"); assertEquals(expected, actual); assertEquals(noOfBinsInADay * windowLength, actual.size()); }
@Test public void testGetMetricData_time_window_less_than_day() { val latestTimeInEpoch = earliestTimeInEpoch + TimeConstantsUtil.SECONDS_PER_DAY / 2; val expected = buildExpectedResults(earliestTimeInEpoch, 1); val actual = sourceUnderTest.getMetricData(earliestTimeInEpoch, latestTimeInEpoch, intervalLength, "metric_name"); assertEquals(expected, actual); }
@Test public void testGetMetricData_empty_list() { val latestTimeInEpoch = earliestTimeInEpoch + TimeConstantsUtil.SECONDS_PER_DAY; val actual = sourceUnderTest.getMetricData(earliestTimeInEpoch, latestTimeInEpoch, intervalLength, "null_metric"); assertEquals(new ArrayList<>(), actual); }