PcapServiceImpl implements PcapService { @Override public PcapStatus killJob(String username, String jobId) throws RestException { try { jobManager.killJob(username, jobId); } catch (JobNotFoundException e) { LOG.warn(String.format("Could not kill job. Job not found for user %s with job id %s", username, jobId)); return null; } catch (JobException e) { throw new RestException(e); } return getJobStatus(username, jobId); } @Autowired  PcapServiceImpl(Environment environment, Configuration configuration, PcapJobSupplier pcapJobSupplier, JobManager<Path> jobManager, PcapToPdmlScriptWrapper pcapToPdmlScriptWrapper); @Override PcapStatus submit(String username, PcapRequest pcapRequest); @Override PcapStatus getJobStatus(String username, String jobId); @Override List<PcapStatus> getJobStatus(String username, JobStatus.State state); @Override PcapStatus killJob(String username, String jobId); @Override Path getPath(String username, String jobId, Integer page); @Override Pdml getPdml(String username, String jobId, Integer page); @Override InputStream getRawPcap(String username, String jobId, Integer page); @Override Map<String, Object> getConfiguration(String username, String jobId);  }
@Test public void killNonExistentJobShouldReturnNull() throws Exception { MockPcapJob mockPcapJob = mock(MockPcapJob.class); JobManager jobManager = mock(JobManager.class); doThrow(new JobNotFoundException("Not found test exception.")).when(jobManager).killJob("user", "jobId"); PcapServiceImpl pcapService = new PcapServiceImpl(environment, configuration, mockPcapJobSupplier, jobManager, pcapToPdmlScriptWrapper); PcapStatus status = pcapService.killJob("user", "jobId"); verify(jobManager, times(1)).killJob("user", "jobId"); assertNull(status); }