@Override
  public Map<ApplicationId, ApplicationReport> getApplications(long appsNum,
      long appStartedTimeBegin, long appStartedTimeEnd) throws IOException {
    Map<ApplicationId, ApplicationHistoryData> histData =
        historyStore.getAllApplications();
    HashMap<ApplicationId, ApplicationReport> applicationsReport =
        new HashMap<ApplicationId, ApplicationReport>();
    int count = 0;
    for (Entry<ApplicationId, ApplicationHistoryData> entry : histData
      .entrySet()) {
      if (count == appsNum) {
        break;
      }
      long appStartTime = entry.getValue().getStartTime();
      if (appStartTime < appStartedTimeBegin
          || appStartTime > appStartedTimeEnd) {
        continue;
      }
      applicationsReport.put(entry.getKey(),
        convertToApplicationReport(entry.getValue()));
      count++;
    }
    return applicationsReport;
  }
@Test
  void testApplications() throws IOException {
    ApplicationId appId1 = ApplicationId.newInstance(0, 1);
    ApplicationId appId2 = ApplicationId.newInstance(0, 2);
    ApplicationId appId3 = ApplicationId.newInstance(0, 3);
    writeApplicationStartData(appId1, 1000);
    writeApplicationFinishData(appId1);
    writeApplicationStartData(appId2, 3000);
    writeApplicationFinishData(appId2);
    writeApplicationStartData(appId3, 4000);
    writeApplicationFinishData(appId3);
    Map<ApplicationId, ApplicationReport> reports =
        applicationHistoryManagerImpl.getApplications(2, 2000L, 5000L);
    assertNotNull(reports);
    assertEquals(2, reports.size());
    assertNull(reports.get("1"));
    assertNull(reports.get("2"));
    assertNull(reports.get("3"));
  }