@Test(timeout = 10000)
  public void testGetApplicationAttempt() throws YarnException, IOException {
    Configuration conf = new Configuration();
    final YarnClient client = new MockYarnClient();
    client.init(conf);
    client.start();

    List<ApplicationReport> expectedReports = ((MockYarnClient) client).getReports();

    ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(applicationId, 1);
    ApplicationAttemptReport report = client.getApplicationAttemptReport(appAttemptId);
    Assert.assertNotNull(report);
    Assert.assertEquals(
        report.getApplicationAttemptId().toString(),
        expectedReports.get(0).getCurrentApplicationAttemptId().toString());
    client.stop();
  }
    private List<ApplicationReport> createAppReports() {
      ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
      ApplicationReport newApplicationReport =
          ApplicationReport.newInstance(
              applicationId,
              ApplicationAttemptId.newInstance(applicationId, 1),
              "user",
              "queue",
              "appname",
              "host",
              124,
              null,
              YarnApplicationState.RUNNING,
              "diagnostics",
              "url",
              0,
              0,
              FinalApplicationStatus.SUCCEEDED,
              null,
              "N/A",
              0.53789f,
              "YARN",
              null);
      List<ApplicationReport> applicationReports = new ArrayList<ApplicationReport>();
      applicationReports.add(newApplicationReport);
      List<ApplicationAttemptReport> appAttempts = new ArrayList<ApplicationAttemptReport>();
      ApplicationAttemptReport attempt =
          ApplicationAttemptReport.newInstance(
              ApplicationAttemptId.newInstance(applicationId, 1),
              "host",
              124,
              "url",
              "oUrl",
              "diagnostics",
              YarnApplicationAttemptState.FINISHED,
              ContainerId.newContainerId(newApplicationReport.getCurrentApplicationAttemptId(), 1));
      appAttempts.add(attempt);
      ApplicationAttemptReport attempt1 =
          ApplicationAttemptReport.newInstance(
              ApplicationAttemptId.newInstance(applicationId, 2),
              "host",
              124,
              "url",
              "oUrl",
              "diagnostics",
              YarnApplicationAttemptState.FINISHED,
              ContainerId.newContainerId(newApplicationReport.getCurrentApplicationAttemptId(), 2));
      appAttempts.add(attempt1);
      attempts.put(applicationId, appAttempts);

      List<ContainerReport> containerReports = new ArrayList<ContainerReport>();
      ContainerReport container =
          ContainerReport.newInstance(
              ContainerId.newContainerId(attempt.getApplicationAttemptId(), 1),
              null,
              NodeId.newInstance("host", 1234),
              Priority.UNDEFINED,
              1234,
              5678,
              "diagnosticInfo",
              "logURL",
              0,
              ContainerState.COMPLETE,
              "http://" + NodeId.newInstance("host", 2345).toString());
      containerReports.add(container);

      ContainerReport container1 =
          ContainerReport.newInstance(
              ContainerId.newContainerId(attempt.getApplicationAttemptId(), 2),
              null,
              NodeId.newInstance("host", 1234),
              Priority.UNDEFINED,
              1234,
              5678,
              "diagnosticInfo",
              "logURL",
              0,
              ContainerState.COMPLETE,
              "http://" + NodeId.newInstance("host", 2345).toString());

      containerReports.add(container1);
      containers.put(attempt.getApplicationAttemptId(), containerReports);

      ApplicationId applicationId2 = ApplicationId.newInstance(1234, 6);
      ApplicationReport newApplicationReport2 =
          ApplicationReport.newInstance(
              applicationId2,
              ApplicationAttemptId.newInstance(applicationId2, 2),
              "user2",
              "queue2",
              "appname2",
              "host2",
              125,
              null,
              YarnApplicationState.FINISHED,
              "diagnostics2",
              "url2",
              2,
              2,
              FinalApplicationStatus.SUCCEEDED,
              null,
              "N/A",
              0.63789f,
              "NON-YARN",
              null);
      applicationReports.add(newApplicationReport2);

      ApplicationId applicationId3 = ApplicationId.newInstance(1234, 7);
      ApplicationReport newApplicationReport3 =
          ApplicationReport.newInstance(
              applicationId3,
              ApplicationAttemptId.newInstance(applicationId3, 3),
              "user3",
              "queue3",
              "appname3",
              "host3",
              126,
              null,
              YarnApplicationState.RUNNING,
              "diagnostics3",
              "url3",
              3,
              3,
              FinalApplicationStatus.SUCCEEDED,
              null,
              "N/A",
              0.73789f,
              "MAPREDUCE",
              null);
      applicationReports.add(newApplicationReport3);

      ApplicationId applicationId4 = ApplicationId.newInstance(1234, 8);
      ApplicationReport newApplicationReport4 =
          ApplicationReport.newInstance(
              applicationId4,
              ApplicationAttemptId.newInstance(applicationId4, 4),
              "user4",
              "queue4",
              "appname4",
              "host4",
              127,
              null,
              YarnApplicationState.FAILED,
              "diagnostics4",
              "url4",
              4,
              4,
              FinalApplicationStatus.SUCCEEDED,
              null,
              "N/A",
              0.83789f,
              "NON-MAPREDUCE",
              null);
      applicationReports.add(newApplicationReport4);
      return applicationReports;
    }