### Question:
ResourceMgrDelegate extends YarnClientImpl { public JobStatus[] getAllJobs() throws IOException, InterruptedException { return TypeConverter.fromYarnApps(super.getApplicationList(), this.conf); } ResourceMgrDelegate(YarnConfiguration conf); void cancelDelegationToken(Token<DelegationTokenIdentifier> arg0); TaskTrackerInfo[] getActiveTrackers(); JobStatus[] getAllJobs(); TaskTrackerInfo[] getBlacklistedTrackers(); ClusterMetrics getClusterMetrics(); @SuppressWarnings("rawtypes") Token getDelegationToken(Text renewer); String getFilesystemName(); JobID getNewJobID(); QueueInfo getQueue(String queueName); QueueAclsInfo[] getQueueAclsForCurrentUser(); QueueInfo[] getQueues(); QueueInfo[] getRootQueues(); QueueInfo[] getChildQueues(String parent); String getStagingAreaDir(); String getSystemDir(); long getTaskTrackerExpiryInterval(); void setJobPriority(JobID arg0, String arg1); long getProtocolVersion(String arg0, long arg1); long renewDelegationToken(Token<DelegationTokenIdentifier> arg0); ApplicationId getApplicationId();  }### Answer:
@Test public void tesAllJobs() throws Exception { final ClientRMProtocol applicationsManager = Mockito.mock(ClientRMProtocol.class); GetAllApplicationsResponse allApplicationsResponse = Records .newRecord(GetAllApplicationsResponse.class); List<ApplicationReport> applications = new ArrayList<ApplicationReport>(); applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.FAILED)); applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.SUCCEEDED)); applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.KILLED)); applications.add(getApplicationReport(YarnApplicationState.FAILED, FinalApplicationStatus.FAILED)); allApplicationsResponse.setApplicationList(applications); Mockito.when( applicationsManager.getAllApplications(Mockito .any(GetAllApplicationsRequest.class))).thenReturn( allApplicationsResponse); ResourceMgrDelegate resourceMgrDelegate = new ResourceMgrDelegate( new YarnConfiguration()) { @Override public synchronized void start() { this.rmClient = applicationsManager; } }; JobStatus[] allJobs = resourceMgrDelegate.getAllJobs(); Assert.assertEquals(State.FAILED, allJobs[0].getState()); Assert.assertEquals(State.SUCCEEDED, allJobs[1].getState()); Assert.assertEquals(State.KILLED, allJobs[2].getState()); Assert.assertEquals(State.FAILED, allJobs[3].getState()); }