### Question:
MetricsServer { public Iterable<AggregateNumericMetric> calculateAggregates() { return aggregationManager.run(); }  void setDAO(MetricsDAO dao); void setConfiguration(MetricsConfiguration configuration); void setDateTimeService(DateTimeService dateTimeService); int getRawDataAgeLimit(); void setRawDataAgeLimit(int rawDataAgeLimit); void setIndexPartitions(int indexPartitions); void init(); AggregationManager getAggregationManager(); void shutdown(); RawNumericMetric findLatestValueForResource(int scheduleId); Iterable<MeasurementDataNumericHighLowComposite> findDataForResource(int scheduleId, long beginTime,
        long endTime, int numberOfBuckets); List<MeasurementDataNumericHighLowComposite> findDataForGroup(List<Integer> scheduleIds, long beginTime,
        long endTime, int numberOfBuckets); AggregateNumericMetric getSummaryAggregate(int scheduleId, long beginTime, long endTime); ListenableFuture<AggregateNumericMetric> getSummaryAggregateAsync(int scheduleId, long beginTime,
        long endTime); AggregateNumericMetric getSummaryAggregate(List<Integer> scheduleIds, long beginTime, long endTime); synchronized void addNumericData(final Set<MeasurementDataNumeric> dataSet, final FutureCallback<Void> callback); Iterable<AggregateNumericMetric> calculateAggregates(); int getQueueAvailableCapacity();  }### Answer:
@Test(dataProvider = "testDates") public void aggregateRawDataDuring9thHour(DateTime testNow) throws Exception { initServer(testNow); int scheduleId = 123; DateTime hour0 = hour0(); DateTime hour9 = hour0.plusHours(9); DateTime hour8 = hour9.minusHours(1); DateTime firstMetricTime = hour8.plusMinutes(5); DateTime secondMetricTime = hour8.plusMinutes(10); DateTime thirdMetricTime = hour8.plusMinutes(15); double firstValue = 1.1; double secondValue = 2.2; double thirdValue = 3.3; dateTimeServiceStub.setNow(hour(8).plusMinutes(55)); insertRawData( new MeasurementDataNumeric(firstMetricTime.getMillis(), scheduleId, firstValue), new MeasurementDataNumeric(secondMetricTime.getMillis(), scheduleId, secondValue), new MeasurementDataNumeric(thirdMetricTime.getMillis(), scheduleId, thirdValue) ); dateTimeServiceStub.setNow(hour(10)); metricsServer.calculateAggregates(); List<AggregateNumericMetric> expected = asList( new AggregateNumericMetric(scheduleId, Bucket.ONE_HOUR, divide((1.1 + 2.2 + 3.3), 3), firstValue, thirdValue, hour8.getMillis())); assertMetricDataEquals(scheduleId, Bucket.ONE_HOUR, expected); assert6HourDataEmpty(scheduleId); }