AppReportFetcher { public FetchedAppReport getApplicationReport(ApplicationId appId) throws YarnException, IOException { GetApplicationReportRequest request = recordFactory .newRecordInstance(GetApplicationReportRequest.class); request.setApplicationId(appId); ApplicationReport appReport; FetchedAppReport fetchedAppReport; try { appReport = applicationsManager. getApplicationReport(request).getApplicationReport(); fetchedAppReport = new FetchedAppReport(appReport, AppReportSource.RM); } catch (ApplicationNotFoundException e) { if (!isAHSEnabled) { throw e; } appReport = historyManager. getApplicationReport(request).getApplicationReport(); fetchedAppReport = new FetchedAppReport(appReport, AppReportSource.AHS); } return fetchedAppReport; } AppReportFetcher(Configuration conf);  AppReportFetcher(Configuration conf, ApplicationClientProtocol applicationsManager); FetchedAppReport getApplicationReport(ApplicationId appId); void stop();  }
@Test public void testFetchReportAHSEnabled() throws YarnException, IOException { testHelper(true); Mockito.verify(historyManager, Mockito.times(1)) .getApplicationReport(Mockito.any(GetApplicationReportRequest.class)); Mockito.verify(appManager, Mockito.times(1)) .getApplicationReport(Mockito.any(GetApplicationReportRequest.class)); }
@Test public void testFetchReportAHSDisabled() throws YarnException, IOException { try { testHelper(false); } catch (ApplicationNotFoundException e) { Assert.assertTrue(e.getMessage() == appNotFoundExceptionMsg); } Mockito.verify(appManager, Mockito.times(1)) .getApplicationReport(Mockito.any(GetApplicationReportRequest.class)); if (historyManager != null) { Assert.fail("HistoryManager should be null as AHS is disabled"); } }