@Test
 public void removePokesAfterJobTest() {
   MessageFactory factory = new MessageFactory();
   PriorityMessageQueue pmq = new PriorityMessageQueue(timer, factory);
   setRunning(pmq);
   SafeMessageQueue mq = spy(new SafeMessageQueue(timer, factory, "test"));
   setRunning(mq);
   timer.setNow(2001);
   Consumer consumer = new Consumer(pmq, mq, factory, timer);
   RunJobMessage rjm = factory.obtain(RunJobMessage.class);
   JobHolder mockHolder = mock(JobHolder.class);
   when(mockHolder.safeRun(0, new MockTimer())).thenReturn(JobHolder.RUN_RESULT_SUCCESS);
   rjm.setJobHolder(mockHolder);
   timer.setNow(3001);
   verify(mq, times(0)).cancelMessages(Consumer.pokeMessagePredicate);
   consumer.queueConsumer.handleMessage(rjm);
   verify(mq, times(1)).cancelMessages(Consumer.pokeMessagePredicate);
 }
  @Test
  public void runJobMessage() {
    MessageFactory factory = new MessageFactory();
    PriorityMessageQueue pmq = new PriorityMessageQueue(timer, factory);
    setRunning(pmq);
    SafeMessageQueue mq = new SafeMessageQueue(timer, factory, "test");
    setRunning(mq);
    timer.setNow(2001);
    Consumer consumer = new Consumer(pmq, mq, factory, timer);
    RunJobMessage rjm = factory.obtain(RunJobMessage.class);
    JobHolder mockHolder = mock(JobHolder.class);
    when(mockHolder.safeRun(0, timer)).thenReturn(JobHolder.RUN_RESULT_SUCCESS);
    rjm.setJobHolder(mockHolder);
    timer.setNow(3001);
    consumer.queueConsumer.handleMessage(rjm);

    Message message = pmq.next(dummyConsumer);
    assertThat(message, CoreMatchers.instanceOf(RunJobResultMessage.class));
    RunJobResultMessage result = (RunJobResultMessage) message;
    assertThat(result.getResult(), CoreMatchers.is(JobHolder.RUN_RESULT_SUCCESS));
    assertThat(result.getJobHolder(), CoreMatchers.is(mockHolder));
    assertThat(consumer.lastJobCompleted, CoreMatchers.is(3001L));
  }