when(_exchangeRegistry.getExchange(eq(TOPIC_EXCHANGE_ID))).thenReturn(_topicExchange);
when(_vhost.getQueue(eq(QUEUE_ID))).thenReturn(queue);
final ArgumentCaptor<ExchangeImpl> registeredExchange = ArgumentCaptor.forClass(ExchangeImpl.class);
doAnswer(new Answer()
{
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable
{
ExchangeImpl 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<Map> attributesArg = ArgumentCaptor.forClass(Map.class);
_queueFactory = mock(QueueFactory.class);
when(_queueFactory.restoreQueue(attributesArg.capture())).then(
new Answer()
{
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable
{
final AMQQueue queue = mock(AMQQueue.class);
final Map attributes = attributesArg.getValue();
final String queueName = (String) attributes.get(Queue.NAME);
final UUID queueId = MapValueConverter.getUUIDAttribute(Queue.ID, attributes);
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<ExchangeImpl> altExchangeArg = ArgumentCaptor.forClass(ExchangeImpl.class);
doAnswer(
new Answer()
{
@Override
public Object answer(InvocationOnMock invocation) throws Throwable
{
final ExchangeImpl value = altExchangeArg.getValue();