YarnJobValidationTool { public ApplicationId validateAppId() throws Exception { ApplicationId appId = null; for (ApplicationReport applicationReport : this.client.getApplications()) { if (applicationReport.getName().equals(this.jobName)) { ApplicationId id = applicationReport.getApplicationId(); if (appId == null || appId.compareTo(id) < 0) { appId = id; } } } if (appId != null) { log.info("Job lookup success. ApplicationId " + appId.toString()); return appId; } else { throw new SamzaException("Job lookup failure " + this.jobName); } } YarnJobValidationTool(JobConfig config, YarnClient client, MetricsValidator validator); void run(); ApplicationId validateAppId(); ApplicationAttemptId validateRunningAttemptId(ApplicationId appId); int validateContainerCount(ApplicationAttemptId attemptId); void validateJmxMetrics(); static void main(String[] args);  }
@Test public void testValidateAppId() throws Exception { ApplicationReport appReport = mock(ApplicationReport.class); when(appReport.getName()).thenReturn(jobName + "_" + jobId); when(appReport.getApplicationId()).thenReturn(appId); when(client.getApplications()).thenReturn(Collections.singletonList(appReport)); assertTrue(tool.validateAppId().equals(appId)); when(appReport.getName()).thenReturn("dummy"); exception.expect(SamzaException.class); tool.validateAppId(); }