RabbitMqUtils { public static void declareApplicationExchanges( String domain, String applicationName, Channel channel ) throws IOException { if( applicationName != null ) { String exch = buildExchangeNameForAgent( domain, applicationName ); channel.exchangeDeclare( exch, "topic" ); } } private  RabbitMqUtils(); static void configureFactory( ConnectionFactory factory, Map<String,String> configuration ); static void closeConnection( Channel channel ); static void declareApplicationExchanges( String domain, String applicationName, Channel channel ); static void declareGlobalExchanges( String domain, Channel channel ); static String buildExchangeNameForAgent( String domain, String applicationName ); static String buildExchangeNameForTheDm( String domain ); static String buildExchangeNameForInterApp( String domain ); static String buildExchangeName( MessagingContext ctx );  }
@Test public void testDeclareApplicationExchanges() throws Exception { Channel channel = Mockito.mock( Channel.class ); RabbitMqUtils.declareApplicationExchanges( null, null, channel ); Mockito.verifyZeroInteractions( channel ); RabbitMqUtils.declareApplicationExchanges( "domain", "te", channel ); String exchangeName = RabbitMqUtils.buildExchangeNameForAgent( "domain", "te" ); Mockito.verify( channel, Mockito.times( 1 )).exchangeDeclare( exchangeName, "topic" ); }