use of org.apache.metron.job.manager.JobManager in project metron by apache.
the class PcapServiceImplTest method getStatusShouldProperlyReturnStatus.
@Test
public void getStatusShouldProperlyReturnStatus() throws Exception {
MockPcapJob mockPcapJob = mock(MockPcapJob.class);
JobManager jobManager = mock(JobManager.class);
JobStatus actualJobStatus = new JobStatus().withJobId("jobId").withState(JobStatus.State.SUCCEEDED).withDescription("description").withPercentComplete(100.0);
Pageable pageable = mock(Pageable.class);
when(pageable.getSize()).thenReturn(2);
when(mockPcapJob.getStatus()).thenReturn(actualJobStatus);
when(mockPcapJob.isDone()).thenReturn(true);
when(mockPcapJob.get()).thenReturn(pageable);
when(jobManager.getJob("user", "jobId")).thenReturn(mockPcapJob);
PcapServiceImpl pcapService = new PcapServiceImpl(environment, configuration, mockPcapJobSupplier, jobManager, pcapToPdmlScriptWrapper);
PcapStatus expectedPcapStatus = new PcapStatus();
expectedPcapStatus.setJobId("jobId");
expectedPcapStatus.setJobStatus(JobStatus.State.SUCCEEDED.name());
expectedPcapStatus.setDescription("description");
expectedPcapStatus.setPercentComplete(100.0);
expectedPcapStatus.setPageTotal(2);
assertEquals(expectedPcapStatus, pcapService.getJobStatus("user", "jobId"));
}
Aggregations