Search in sources :

Example 6 with DistributionQueueStatus

use of org.apache.sling.distribution.queue.DistributionQueueStatus in project sling by apache.

the class AsyncDeliveryDispatchingStrategyTest method testAddWithOneItemInRunningQueues.

@Test
public void testAddWithOneItemInRunningQueues() throws Exception {
    Map<String, String> deliveryMappings = new HashMap<String, String>();
    String queue1 = "queue1";
    deliveryMappings.put(queue1, "delivery1");
    String queue2 = "queue2";
    deliveryMappings.put(queue2, "delivery2");
    AsyncDeliveryDispatchingStrategy asyncDeliveryDispatchingStrategy = new AsyncDeliveryDispatchingStrategy(deliveryMappings);
    // setup package
    SharedDistributionPackage distributionPackage = mock(SharedDistributionPackage.class);
    when(distributionPackage.getId()).thenReturn("1221312");
    DistributionPackageInfo info = new DistributionPackageInfo("dummy", new HashMap<String, Object>());
    when(distributionPackage.getInfo()).thenReturn(info);
    // setup queues
    DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
    DistributionQueue dq1 = mock(DistributionQueue.class);
    DistributionQueueItemStatus status = mock(DistributionQueueItemStatus.class);
    DistributionQueueEntry entry = new DistributionQueueEntry("1242112", new DistributionQueueItem(distributionPackage.getId(), new HashMap<String, Object>()), status);
    when(dq1.add(any(DistributionQueueItem.class))).thenReturn(entry);
    DistributionQueueStatus status1 = new DistributionQueueStatus(1, DistributionQueueState.RUNNING);
    when(dq1.getStatus()).thenReturn(status1);
    when(queueProvider.getQueue(queue1)).thenReturn(dq1);
    DistributionQueue dq2 = mock(DistributionQueue.class);
    when(dq2.add(any(DistributionQueueItem.class))).thenReturn(entry);
    DistributionQueueStatus status2 = new DistributionQueueStatus(1, DistributionQueueState.RUNNING);
    when(dq2.getStatus()).thenReturn(status2);
    when(queueProvider.getQueue(queue2)).thenReturn(dq2);
    Iterable<DistributionQueueItemStatus> statuses = asyncDeliveryDispatchingStrategy.add(distributionPackage, queueProvider);
    assertNotNull(statuses);
}
Also used : DistributionQueueStatus(org.apache.sling.distribution.queue.DistributionQueueStatus) DistributionQueueItemStatus(org.apache.sling.distribution.queue.DistributionQueueItemStatus) DistributionPackageInfo(org.apache.sling.distribution.packaging.DistributionPackageInfo) HashMap(java.util.HashMap) DistributionQueue(org.apache.sling.distribution.queue.DistributionQueue) DistributionQueueEntry(org.apache.sling.distribution.queue.DistributionQueueEntry) DistributionQueueItem(org.apache.sling.distribution.queue.DistributionQueueItem) SharedDistributionPackage(org.apache.sling.distribution.packaging.impl.SharedDistributionPackage) DistributionQueueProvider(org.apache.sling.distribution.queue.DistributionQueueProvider) Test(org.junit.Test)

Aggregations

DistributionQueueStatus (org.apache.sling.distribution.queue.DistributionQueueStatus)6 DistributionQueue (org.apache.sling.distribution.queue.DistributionQueue)4 HashMap (java.util.HashMap)3 DistributionQueueEntry (org.apache.sling.distribution.queue.DistributionQueueEntry)3 DistributionQueueItem (org.apache.sling.distribution.queue.DistributionQueueItem)3 DistributionQueueItemStatus (org.apache.sling.distribution.queue.DistributionQueueItemStatus)3 Test (org.junit.Test)3 Nonnull (javax.annotation.Nonnull)2 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 List (java.util.List)1 Map (java.util.Map)1 DistributionPackageInfo (org.apache.sling.distribution.packaging.DistributionPackageInfo)1 SharedDistributionPackage (org.apache.sling.distribution.packaging.impl.SharedDistributionPackage)1 DistributionQueueProvider (org.apache.sling.distribution.queue.DistributionQueueProvider)1 DistributionQueueState (org.apache.sling.distribution.queue.DistributionQueueState)1 Job (org.apache.sling.event.jobs.Job)1