SCMAdminProtocolService extends AbstractService implements
    SCMAdminProtocol { @Override public RunSharedCacheCleanerTaskResponse runCleanerTask( RunSharedCacheCleanerTaskRequest request) throws YarnException { checkAcls("runCleanerTask"); RunSharedCacheCleanerTaskResponse response = recordFactory.newRecordInstance(RunSharedCacheCleanerTaskResponse.class); this.cleanerService.runCleanerTask(); response.setAccepted(true); return response; } SCMAdminProtocolService(CleanerService cleanerService); @Override RunSharedCacheCleanerTaskResponse runCleanerTask(
      RunSharedCacheCleanerTaskRequest request);  }
@Test public void testRunCleanerTask() throws Exception { doNothing().when(cleaner).runCleanerTask(); RunSharedCacheCleanerTaskRequest request = recordFactory.newRecordInstance(RunSharedCacheCleanerTaskRequest.class); RunSharedCacheCleanerTaskResponse response = SCMAdminProxy.runCleanerTask(request); Assert.assertTrue("cleaner task request isn't accepted", response.getAccepted()); verify(service, times(1)).runCleanerTask(any(RunSharedCacheCleanerTaskRequest.class)); }
@Test public void testRunCleanerTaskCLI() throws Exception { String[] args = { "-runCleanerTask" }; RunSharedCacheCleanerTaskResponse rp = new RunSharedCacheCleanerTaskResponsePBImpl(); rp.setAccepted(true); when(mockAdmin.runCleanerTask(isA(RunSharedCacheCleanerTaskRequest.class))) .thenReturn(rp); assertEquals(0, adminCLI.run(args)); rp.setAccepted(false); when(mockAdmin.runCleanerTask(isA(RunSharedCacheCleanerTaskRequest.class))) .thenReturn(rp); assertEquals(1, adminCLI.run(args)); verify(mockAdmin, times(2)).runCleanerTask( any(RunSharedCacheCleanerTaskRequest.class)); }