when(_exchangeRegistry.getExchange(eq(TOPIC_EXCHANGE_ID))).thenReturn(_topicExchange);
when(_vhost.getQueue(eq(QUEUE_ID))).thenReturn(queue);
final ArgumentCaptor<Exchange> registeredExchange = ArgumentCaptor.forClass(Exchange.class);
doAnswer(new Answer()
{
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable
{
Exchange exchange = registeredExchange.getValue();
when(_exchangeRegistry.getExchange(eq(exchange.getId()))).thenReturn(exchange);
when(_exchangeRegistry.getExchange(eq(exchange.getName()))).thenReturn(exchange);
return null;
}
}).when(_exchangeRegistry).registerExchange(registeredExchange.capture());
final ArgumentCaptor<UUID> idArg = ArgumentCaptor.forClass(UUID.class);
final ArgumentCaptor<String> queueArg = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Map> argsArg = ArgumentCaptor.forClass(Map.class);
_queueFactory = mock(QueueFactory.class);
when(_queueFactory.restoreQueue(idArg.capture(), queueArg.capture(),
anyString(), anyBoolean(), anyBoolean(), anyBoolean(), argsArg.capture())).then(
new Answer()
{
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable
{
final AMQQueue queue = mock(AMQQueue.class);
final String queueName = queueArg.getValue();
final UUID queueId = idArg.getValue();
when(queue.getName()).thenReturn(queueName);
when(queue.getId()).thenReturn(queueId);
when(_vhost.getQueue(eq(queueName))).thenReturn(queue);
when(_vhost.getQueue(eq(queueId))).thenReturn(queue);
final ArgumentCaptor<Exchange> altExchangeArg = ArgumentCaptor.forClass(Exchange.class);
doAnswer(
new Answer()
{
@Override
public Object answer(InvocationOnMock invocation) throws Throwable
{
final Exchange value = altExchangeArg.getValue();