EventBinder { void bindExchange(ExchangeBinding exchangeBinding) { EventPublisher.PublisherConfiguration configuration = new EventPublisher.PublisherConfiguration( exchangeBinding.exchange, exchangeBinding.routingKey, exchangeBinding.persistent, exchangeBinding.reliability, exchangeBinding.deliveryOptions, exchangeBinding.basicProperties ); eventPublisher.addEvent(exchangeBinding.eventType, configuration); LOGGER.info("Binding between exchange {} and event type {} activated", exchangeBinding.exchange, exchangeBinding.eventType.getSimpleName()); }  void initialize(); EventBindingBuilder bind(Class<?> event);  }
@Test public void testBindExchange() { eventBinder.bind(TestEventOne.class).toExchange(TestSetup.TEST_EXCHANGE_ONE); eventBinder.bind(TestEventTwo.class).toExchange(TestSetup.TEST_EXCHANGE_TWO) .withRoutingKey(TestSetup.TEST_ROUTING_KEY_TWO) .withPersistentMessages() .withPublisherTransactions() .withImmediateDelivery(); eventBinder.bind(TestEventThree.class).toExchange(TestSetup.TEST_EXCHANGE_THREE) .withRoutingKey(TestSetup.TEST_ROUTING_KEY_THREE) .withPublisherConfirms() .withMandatoryDelivery(); eventBinder.processExchangeBindings(); Map<Class<?>, EventPublisher.PublisherConfiguration> configurations = eventBinder.eventPublisher.publisherConfigurations; EventPublisher.PublisherConfiguration config = configurations.get(TestEventOne.class); Assert.assertEquals(TestSetup.TEST_EXCHANGE_ONE, config.exchange); Assert.assertNull(config.routingKey); Assert.assertEquals(PublisherReliability.NONE, config.reliability); Assert.assertEquals(DeliveryOptions.NONE, config.deliveryOptions); config = configurations.get(TestEventTwo.class); Assert.assertEquals(TestSetup.TEST_EXCHANGE_TWO, config.exchange); Assert.assertEquals(TestSetup.TEST_ROUTING_KEY_TWO, config.routingKey); Assert.assertEquals(PublisherReliability.TRANSACTIONAL, config.reliability); Assert.assertEquals(DeliveryOptions.IMMEDIATE, config.deliveryOptions); config = configurations.get(TestEventThree.class); Assert.assertEquals(TestSetup.TEST_EXCHANGE_THREE, config.exchange); Assert.assertEquals(TestSetup.TEST_ROUTING_KEY_THREE, config.routingKey); Assert.assertEquals(PublisherReliability.CONFIRMED, config.reliability); Assert.assertEquals(DeliveryOptions.MANDATORY, config.deliveryOptions); }