protected void dispatchJobImpl(final DispatchableJob job) {
dispatched.add(job);
}
};
final StandardJob parent = new StandardJob(dispatcher, job1, receiver);
final WholeWatchedJob wjob1 = parent.createWholeWatchedJob(job1);
final CalculationJobResult result1 = new CalculationJobResult(job1.getSpecification(), 0, Arrays.asList(CalculationJobResultItem.success()), "Test");
wjob1.getResultReceiver(result1).resultReceived(result1);
Mockito.verify(receiver).resultReceived(result1);
Mockito.reset();
assertEquals(dispatched.size(), 2);
final WholeWatchedJob wjob2 = (WholeWatchedJob) dispatched.poll();
final WholeWatchedJob wjob3 = (WholeWatchedJob) dispatched.poll();
final CalculationJobResult result2 = new CalculationJobResult(job2.getSpecification(), 0, Arrays.asList(CalculationJobResultItem.success()), "Test");
final CalculationJobResult result3 = new CalculationJobResult(job3.getSpecification(), 0, Arrays.asList(CalculationJobResultItem.success()), "Test");
wjob3.getResultReceiver(result3).resultReceived(result3);
Mockito.verify(receiver).resultReceived(result3);
Mockito.reset();
assertEquals(dispatched.size(), 0);
wjob2.getResultReceiver(result2).resultReceived(result2);
Mockito.verify(receiver).resultReceived(result2);
Mockito.reset();
assertEquals(dispatched.size(), 1);
final WholeWatchedJob wjob4 = (WholeWatchedJob) dispatched.poll();
final CalculationJobResult result4 = new CalculationJobResult(job4.getSpecification(), 0, Arrays.asList(CalculationJobResultItem.success()), "Test");
wjob4.getResultReceiver(result4).resultReceived(result4);
Mockito.verify(receiver).resultReceived(result4);
Mockito.reset();
}