### Question:
HdfsStatsService { public static long getOlderRunId(int i, long runId) { int randomizedHourInSeconds = (int) (Math.random() * 23) * 3600; if (i >= HdfsConstants.ageMult.length) { throw new ProcessingException("Can't look back in time that far " + i + ", only upto " + HdfsConstants.ageMult.length); } long newTs = runId - (HdfsConstants.ageMult[i] * HdfsConstants.NUM_SECONDS_IN_A_DAY + randomizedHourInSeconds); LOG.info(" Getting older runId for " + runId + ", returning " + newTs + " since ageMult[" + i + "]=" + HdfsConstants.ageMult[i] + " randomizedHourInSeconds=" + randomizedHourInSeconds); return newTs; } HdfsStatsService(Configuration hbaseConf, Connection hbaseConnection); static long getEncodedRunId(long now); List<HdfsStats> getAllDirs(String cluster, String pathPrefix,
      int limit, long runId); static long getOlderRunId(int i, long runId); List<HdfsStats> getHdfsTimeSeriesStats(String cluster, String path,
      int limit, long starttime, long endtime);  }### Answer:
@Test public void TestGetOlderRunId() { long ts = 1392123600L; int retryCount = 0; for (int i = 0; i < HdfsConstants.ageMult.length; i++) { long oldts = HdfsStatsService.getOlderRunId(retryCount, ts); long diff = (ts - oldts) / HdfsConstants.NUM_SECONDS_IN_A_DAY; assertTrue(diff <= HdfsConstants.ageMult[retryCount]); retryCount++; } }
@Test(expected = ProcessingException.class) public void testGetOlderRunIdsException() { int i = HdfsConstants.ageMult.length + 10; HdfsStatsService.getOlderRunId(i, System.currentTimeMillis() / 1000); }