@Test
public void testApplications() throws IOException, YarnException {

  ApplicationId appId = null;
  appId = ApplicationId.newInstance(0, 1);
  ApplicationId appId1 = ApplicationId.newInstance(0, 2);
  GetApplicationsRequest request = GetApplicationsRequest.newInstance();
  GetApplicationsResponse response =
      clientService.getApplications(request);
  List<ApplicationReport> appReport = response.getApplicationList();
  Assert.assertNotNull(appReport);
  Assert.assertEquals(appId, appReport.get(1).getApplicationId());
  Assert.assertEquals(appId1, appReport.get(0).getApplicationId());
  // Create a historyManager, and set the max_apps can be loaded
  // as 1.
  Configuration conf = new YarnConfiguration();
  conf.setLong(YarnConfiguration.APPLICATION_HISTORY_MAX_APPS, 1);
  ApplicationHistoryManagerOnTimelineStore historyManager2 =
      new ApplicationHistoryManagerOnTimelineStore(dataManager,
        new ApplicationACLsManager(conf));
  historyManager2.init(conf);
  historyManager2.start();
  @SuppressWarnings("resource")
  ApplicationHistoryClientService clientService2 =
      new ApplicationHistoryClientService(historyManager2);
  response = clientService2.getApplications(request);
  appReport = response.getApplicationList();
  Assert.assertNotNull(appReport);
  Assert.assertTrue(appReport.size() == 1);
  // Expected to get the appReport for application with appId1
  Assert.assertEquals(appId1, appReport.get(0).getApplicationId());
}