### Question:
AbstractMetadataReport implements MetadataReport { long calculateStartTime() { Calendar calendar = Calendar.getInstance(); long nowMill = calendar.getTimeInMillis(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); long subtract = calendar.getTimeInMillis() + ONE_DAY_IN_MIll - nowMill; Random r = new Random(); return subtract + (FOUR_HOURS_IN_MIll / 2) + r.nextInt(FOUR_HOURS_IN_MIll); } AbstractMetadataReport(URL reportServerURL); URL getUrl(); @Override String toString(); @Override void storeProviderMetadata(MetadataIdentifier providerMetadataIdentifier, FullServiceDefinition serviceDefinition); @Override void storeConsumerMetadata(MetadataIdentifier consumerMetadataIdentifier, Map<String, String> serviceParameterMap); void storeConsumerMetadataTask(MetadataIdentifier consumerMetadataIdentifier, Map<String, String> serviceParameterMap); boolean retry(); public MetadataReportRetry metadataReportRetry; }### Answer:
@Test public void testCalculateStartTime() { for (int i = 0; i < 300; i++) { long t = abstractMetadataReport.calculateStartTime() + System.currentTimeMillis(); Calendar c = Calendar.getInstance(); c.setTimeInMillis(t); Assertions.assertTrue(c.get(Calendar.HOUR_OF_DAY) >= 2); Assertions.assertTrue(c.get(Calendar.HOUR_OF_DAY) <= 6); } }