use of org.apache.sling.event.jobs.JobBuilder in project sling by apache.
the class JobHandlingDistributionQueueTest method testPackageAdditionAndStatusCheck.
@SuppressWarnings("unchecked")
@Test
public void testPackageAdditionAndStatusCheck() throws Exception {
JobManager jobManager = mock(JobManager.class);
JobBuilder builder = mock(JobBuilder.class);
when(builder.properties(any(Map.class))).thenReturn(builder);
Job job = mock(Job.class);
when(job.getId()).thenReturn("id-123");
when(builder.add()).thenReturn(job);
String topic = JobHandlingDistributionQueue.DISTRIBUTION_QUEUE_TOPIC + "/aname";
when(jobManager.createJob(topic)).thenReturn(builder);
when(jobManager.getJobById(anyString())).thenReturn(job);
when(builder.properties(any(Map.class))).thenReturn(builder);
DistributionQueue queue = new JobHandlingDistributionQueue("aname", topic, jobManager, true, DistributionQueueType.ORDERED);
DistributionPackageInfo packageInfo = new DistributionPackageInfo("type");
packageInfo.put(DistributionPackageInfo.PROPERTY_REQUEST_PATHS, new String[] { "/foo" });
packageInfo.put(DistributionPackageInfo.PROPERTY_REQUEST_TYPE, DistributionRequestType.ADD);
DistributionQueueItem distributionQueueItem = new DistributionQueueItem("an-id", packageInfo);
assertNotNull(queue.add(distributionQueueItem));
DistributionQueueItemStatus status = queue.getItem(job.getId()).getStatus();
assertNotNull(status);
assertEquals(DistributionQueueItemState.QUEUED, status.getItemState());
}
use of org.apache.sling.event.jobs.JobBuilder in project sling by apache.
the class JobHandlingDistributionQueueTest method testPackageAddition.
@SuppressWarnings("unchecked")
@Test
public void testPackageAddition() throws Exception {
JobManager jobManager = mock(JobManager.class);
JobBuilder builder = mock(JobBuilder.class);
when(builder.properties(any(Map.class))).thenReturn(builder);
Job job = mock(Job.class);
when(job.getId()).thenReturn("id-123");
when(builder.add()).thenReturn(job);
String topic = JobHandlingDistributionQueue.DISTRIBUTION_QUEUE_TOPIC + "/aname";
when(jobManager.createJob(topic)).thenReturn(builder);
when(jobManager.findJobs(JobManager.QueryType.ALL, topic, -1)).thenReturn(Collections.<Job>emptySet());
when(builder.properties(any(Map.class))).thenReturn(builder);
DistributionQueue queue = new JobHandlingDistributionQueue("aname", topic, jobManager, true, DistributionQueueType.ORDERED);
DistributionPackageInfo packageInfo = new DistributionPackageInfo("type");
packageInfo.put(DistributionPackageInfo.PROPERTY_REQUEST_PATHS, new String[] { "/foo" });
packageInfo.put(DistributionPackageInfo.PROPERTY_REQUEST_TYPE, DistributionRequestType.ADD);
DistributionQueueItem distributionQueueItem = new DistributionQueueItem("an-id", packageInfo);
assertNotNull(queue.add(distributionQueueItem));
}
Aggregations