@Override
  @Private
  public boolean isApplicationActive(ApplicationId id) throws YarnException {
    ApplicationReport report = null;
    try {
      report = client.getApplicationReport(id);
    } catch (ApplicationNotFoundException e) {
      // the app does not exist
      return false;
    } catch (IOException e) {
      throw new YarnException(e);
    }

    if (report == null) {
      // the app does not exist
      return false;
    }

    return ACTIVE_STATES.contains(report.getYarnApplicationState());
  }
@Test
  void testNonExistentApp() throws Exception {
    YarnClient client = createCheckerWithMockedClient();
    ApplicationId id = ApplicationId.newInstance(1, 1);

    // test for null
    doReturn(null).when(client).getApplicationReport(id);
    assertFalse(checker.isApplicationActive(id));

    // test for ApplicationNotFoundException
    doThrow(new ApplicationNotFoundException("Throw!")).when(client)
        .getApplicationReport(id);
    assertFalse(checker.isApplicationActive(id));
  }