public void testActionCallbacks() throws InterruptedException {
// creates a mock action
final PartitionTaskManager.Action action = context.mock( PartitionTaskManager.Action.class );
// this is a jmock helper class that implements the ExecutorService interface
DeterministicScheduler pool = new DeterministicScheduler();
// set expectations for the scenario
context.checking( new Expectations() {{
exactly(5).of( action ).execute( workingMemory );
}});
// enqueue before pool
manager.enqueue( action );
manager.enqueue( action );
// set the pool
manager.setPool( pool );
// enqueue after setting the pool
manager.enqueue( action );
manager.enqueue( action );
manager.enqueue( action );
// executes all pending actions using current thread
pool.runUntilIdle();
// check expectations
context.assertIsSatisfied();
}