Search in sources :

Example 1 with QueueEntryVisitor

use of org.apache.qpid.server.queue.QueueEntryVisitor in project qpid-broker-j by apache.

the class ReportRunnerTest method createMockQueue.

private Queue createMockQueue(final ServerMessage<?>... messages) {
    final Queue<?> queue = mock(Queue.class);
    final ArgumentCaptor<QueueEntryVisitor> captor = ArgumentCaptor.forClass(QueueEntryVisitor.class);
    doAnswer(new Answer() {

        @Override
        public Object answer(final InvocationOnMock invocation) throws Throwable {
            QueueEntryVisitor visitor = captor.getValue();
            for (ServerMessage<?> message : messages) {
                if (visitor.visit(makeEntry(queue, message))) {
                    break;
                }
            }
            return null;
        }
    }).when(queue).visit(captor.capture());
    return queue;
}
Also used : Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) QueueEntryVisitor(org.apache.qpid.server.queue.QueueEntryVisitor) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ServerMessage(org.apache.qpid.server.message.ServerMessage)

Aggregations

ServerMessage (org.apache.qpid.server.message.ServerMessage)1 QueueEntryVisitor (org.apache.qpid.server.queue.QueueEntryVisitor)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1