### Question:
LauncherMain { public static void killChildYarnJobs(Configuration actionConf) { try { Set<ApplicationId> childYarnJobs = getChildYarnJobs(actionConf); if (!childYarnJobs.isEmpty()) { checkAndKillChildYarnJobs(YarnClient.createYarnClient(), actionConf, childYarnJobs); } } catch (IOException | YarnException ye) { throw new RuntimeException("Exception occurred while killing child job(s)", ye); } }  static Set<ApplicationId> getChildYarnJobs(Configuration actionConf); static Set<ApplicationId> getChildYarnJobs(Configuration actionConf, ApplicationsRequestScope scope,
                                                      long startTime); static Set<ApplicationId> getChildYarnJobs(Configuration actionConf, ApplicationsRequestScope scope); static List<ApplicationReport> getChildYarnApplications(final Configuration actionConf,
                                                                   final ApplicationsRequestScope scope,
                                                                   long startTime); static void killChildYarnJobs(Configuration actionConf); static Configuration loadActionConf(); void propagateToHadoopConf(); static final String ACTION_PREFIX; static final String EXTERNAL_CHILD_IDS; static final String EXTERNAL_ACTION_STATS; static final String EXTERNAL_STATS_WRITE; static final String OUTPUT_PROPERTIES; static final String HADOOP_JOBS; static final String MAPREDUCE_JOB_TAGS; static final String CHILD_MAPREDUCE_JOB_TAGS; static final String OOZIE_JOB_LAUNCH_TIME; static final String TEZ_APPLICATION_TAGS; static final String SPARK_YARN_TAGS; static final String PROPAGATION_CONF_XML; }### Answer:
@Test public void testKillChildYarnJobs() throws Exception { YarnClient yc = Mockito.mock(YarnClient.class); ApplicationReport ar = Mockito.mock(ApplicationReport.class); Mockito.when(yc.getApplicationReport(Mockito.any(ApplicationId.class))).thenReturn(ar); Mockito.when(ar.getFinalApplicationStatus()) .thenReturn(FinalApplicationStatus.UNDEFINED) .thenReturn(FinalApplicationStatus.FAILED) .thenReturn(FinalApplicationStatus.KILLED); ApplicationId appz[] = { ApplicationId.newInstance(System.currentTimeMillis(), 1), ApplicationId.newInstance(System.currentTimeMillis(), 2), ApplicationId.newInstance(System.currentTimeMillis(), 3) }; Collection<ApplicationId> result = LauncherMain.checkAndKillChildYarnJobs(yc, null, Arrays.asList(appz)); assertEquals(1, result.size()); assertEquals(appz[0].getId(), result.iterator().next().getId()); }