Search in sources :

Example 16 with JobManager

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"));
}
Also used : MockPcapJob(org.apache.metron.rest.mock.MockPcapJob) InMemoryJobManager(org.apache.metron.job.manager.InMemoryJobManager) JobManager(org.apache.metron.job.manager.JobManager) Test(org.junit.jupiter.api.Test)

Aggregations

InMemoryJobManager (org.apache.metron.job.manager.InMemoryJobManager)16 JobManager (org.apache.metron.job.manager.JobManager)16 Test (org.junit.jupiter.api.Test)16 MockPcapJob (org.apache.metron.rest.mock.MockPcapJob)12 FileSystem (org.apache.hadoop.fs.FileSystem)6 PcapJobSupplier (org.apache.metron.rest.config.PcapJobSupplier)6 MockPcapJobSupplier (org.apache.metron.rest.mock.MockPcapJobSupplier)6 RestException (org.apache.metron.rest.RestException)3 Path (org.apache.hadoop.fs.Path)2 FixedPcapFilter (org.apache.metron.pcap.filter.fixed.FixedPcapFilter)2 HashMap (java.util.HashMap)1 QueryPcapFilter (org.apache.metron.pcap.filter.query.QueryPcapFilter)1