@Test
public void testSingleApp() throws Exception {

  ApplicationId appId = ApplicationId.newInstance(0, 1);
  WebResource r = resource();
  ClientResponse response =
      r.path("ws").path("v1").path("applicationhistory").path("apps")
        .path(appId.toString())
        .queryParam("user.name", USERS[round])
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
      response.getType().toString());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject app = json.getJSONObject("app");
  assertEquals(appId.toString(), app.getString("appId"));
  assertEquals("test app", app.get("name"));
  assertEquals(round == 0 ? "test diagnostics info" : "",
      app.get("diagnosticsInfo"));
  assertEquals(Integer.MAX_VALUE + 1L, app.get("submittedTime"));
  assertEquals("test queue", app.get("queue"));
  assertEquals("user1", app.get("user"));
  assertEquals("test app type", app.get("type"));
  assertEquals(FinalApplicationStatus.UNDEFINED.toString(),
    app.get("finalAppStatus"));
  assertEquals(YarnApplicationState.FINISHED.toString(), app.get("appState"));
  assertNotNull("Aggregate resource allocation is null",
      app.get("aggregateResourceAllocation"));
  assertNotNull("Aggregate Preempted Resource Allocation is null",
      app.get("aggregatePreemptedResourceAllocation"));
}