@Test
public void testMergeAppsFinished() {

  AppsInfo apps = new AppsInfo();
  String amHost = "http://i_am_the_AM1:1234";
  AppInfo am = new AppInfo();
  am.setAppId(APPID1.toString());
  am.setAMHostHttpAddress(amHost);
  am.setState(YarnApplicationState.FINISHED);
  int value = 1000;
  setAppInfoFinished(am, value);
  apps.add(am);
  AppInfo uam1 = new AppInfo();
  uam1.setAppId(APPID1.toString());
  apps.add(uam1);
  setAppInfoFinished(uam1, value);
  AppInfo uam2 = new AppInfo();
  uam2.setAppId(APPID1.toString());
  apps.add(uam2);
  setAppInfoFinished(uam2, value);
  // in this case the result does not change if we enable partial result
  AppsInfo result = RouterWebServiceUtil.mergeAppsInfo(apps.getApps(), false);
  Assert.assertNotNull(result);
  Assert.assertEquals(1, result.getApps().size());
  AppInfo app = result.getApps().get(0);
  Assert.assertEquals(APPID1.toString(), app.getAppId());
  Assert.assertEquals(amHost, app.getAMHostHttpAddress());
  Assert.assertEquals(value * 3, app.getPreemptedResourceMB());
  Assert.assertEquals(value * 3, app.getPreemptedResourceVCores());
  Assert.assertEquals(value * 3, app.getNumNonAMContainerPreempted());
  Assert.assertEquals(value * 3, app.getNumAMContainerPreempted());
  Assert.assertEquals(value * 3, app.getPreemptedMemorySeconds());
  Assert.assertEquals(value * 3, app.getPreemptedVcoreSeconds());
}