@Test
public void testSingleAttempt() throws Exception {

  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  WebResource r = resource();
  ClientResponse response =
      r.path("ws").path("v1").path("applicationhistory").path("apps")
        .path(appId.toString()).path("appattempts")
        .path(appAttemptId.toString()).accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject appAttempt = json.getJSONObject("appAttempt");
  assertEquals(appAttemptId.toString(), appAttempt.getString("appAttemptId"));
  assertEquals(appAttemptId.toString(), appAttempt.getString("host"));
  assertEquals(appAttemptId.toString(),
    appAttempt.getString("diagnosticsInfo"));
  assertEquals("test tracking url", appAttempt.getString("trackingUrl"));
  assertEquals(YarnApplicationAttemptState.FINISHED.toString(),
    appAttempt.get("appAttemptState"));
}