AMQPModule extends AbstractModule { @Provides public Map<Task.Status, ObservableQueue> getQueues(Configuration config) { String stack = ""; if (config.getStack() != null && config.getStack().length() > 0) { stack = config.getStack() + "_"; } final boolean useExchange = config.getBooleanProperty("workflow.listener.queue.useExchange", USE_EXCHANGE_BY_DEFAULT); Task.Status[] statuses = new Task.Status[] { Task.Status.COMPLETED, Task.Status.FAILED }; Map<Task.Status, ObservableQueue> queues = new HashMap<>(); for (Task.Status status : statuses) { String queueName = config.getProperty("workflow.listener.queue.prefix", config.getAppId() + "_amqp_notify_" + stack + status.name()); final ObservableQueue queue = new AMQPObservableQueue.Builder(config).build(useExchange, queueName); queues.put(status, queue); } return queues; }  @ProvidesIntoMap @StringMapKey("amqp_queue") @Singleton @Named(EVENT_QUEUE_PROVIDERS_QUALIFIER) EventQueueProvider getAMQQueueEventQueueProvider(Configuration config); @ProvidesIntoMap @StringMapKey("amqp_exchange") @Singleton @Named(EVENT_QUEUE_PROVIDERS_QUALIFIER) EventQueueProvider getAMQExchangeEventQueueProvider(Configuration config); @Provides Map<Task.Status, ObservableQueue> getQueues(Configuration config);  }
@Test public void testGetQueues() { AMQPModule module = new AMQPModule(); Mockito.when(config.getProperty(Mockito.anyString(), Mockito.anyString())) .thenAnswer(invocation -> invocation.getArgument(1)); Mockito.when(config.getBooleanProperty(Mockito.anyString(), Mockito.anyBoolean())) .thenAnswer(invocation -> invocation.getArgument(1)); Mockito.when(config.getIntProperty(Mockito.anyString(), Mockito.anyInt())) .thenAnswer(invocation -> invocation.getArgument(1)); Map<Task.Status, ObservableQueue> queues = module.getQueues(config); Assert.assertNotNull(queues); Assert.assertEquals(2, queues.size()); Assert.assertEquals(queues.containsKey(Task.Status.COMPLETED), true); Assert.assertEquals(queues.containsKey(Task.Status.FAILED), true); }