@Test
public void testGetApplicationAttemptReport() throws Exception {

  final ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1);
  ApplicationAttemptReport appAttempt;
  if (callerUGI == null) {
    appAttempt = historyManager.getApplicationAttempt(appAttemptId);
  } else {
    try {
      appAttempt =
          callerUGI.doAs(new PrivilegedExceptionAction<ApplicationAttemptReport> () {
        @Override
        public ApplicationAttemptReport run() throws Exception {
          return historyManager.getApplicationAttempt(appAttemptId);
        }
      });
      if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) {
        // The exception is expected
        Assert.fail();
      }
    } catch (AuthorizationException e) {
      if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) {
        // The exception is expected
        return;
      }
      throw e;
    }
  }
  Assert.assertNotNull(appAttempt);
  Assert.assertEquals(appAttemptId, appAttempt.getApplicationAttemptId());
  Assert.assertEquals(ContainerId.newContainerId(appAttemptId, 1),
      appAttempt.getAMContainerId());
  Assert.assertEquals("test host", appAttempt.getHost());
  Assert.assertEquals(100, appAttempt.getRpcPort());
  Assert.assertEquals("test tracking url", appAttempt.getTrackingUrl());
  Assert.assertEquals("test original tracking url",
      appAttempt.getOriginalTrackingUrl());
  Assert.assertEquals("test diagnostics info", appAttempt.getDiagnostics());
  Assert.assertEquals(YarnApplicationAttemptState.FINISHED,
      appAttempt.getYarnApplicationAttemptState());
}