SpringConfigurationResolver { @Bean @Lazy public ListenersContainer listenersContainer() { Map<String, ConnectionStateListener> frameworkHandlers = springIntegration.getFrameworkBeansOfType(ConnectionStateListener.class); Map<String, ConnectionStateListener> customHandlers = springIntegration.getApplicationBeansOfType(ConnectionStateListener.class); List<ConnectionStateListener> connectionStateListeners = new ArrayList<ConnectionStateListener>(frameworkHandlers.values()); connectionStateListeners.addAll(customHandlers.values()); sortInIncreasingOrder(connectionStateListeners); return new ListenersContainer(connectionStateListeners); }  @Bean BristleConfig bristlebackConfigurationFinal(); @Bean(name = CONFIG_BEAN_NAME) BristleConfig bristlebackConfiguration(); @Bean BristleSpringIntegration springIntegration(); @Bean @Lazy ServerEngine serverEngine(); @Bean @Lazy SerializationEngine serializationEngine(); @Bean @Lazy DataControllers dataControllers(); @Bean @Lazy ListenersContainer listenersContainer(); @Bean @Lazy MessageConfiguration messageConfiguration(); @Bean MessageDispatcher messageDispatcher(); void initObjectSenders(); @SuppressWarnings("unchecked") @Bean UserConfiguration userConfiguration(); @Bean UserContextFactory userContextFactory(); void setSpringIntegration(BristleSpringIntegration springIntegration); static final String CONFIG_BEAN_NAME; }
@Test public void shouldShouldSortInIncreasingOrder() { Map<String, ConnectionStateListener> connectionListeners = new LinkedHashMap<String, ConnectionStateListener>(); connectionListeners.put("one", withoutOrder); connectionListeners.put("two", order1); connectionListeners.put("three", order2); connectionListeners.put("four", withoutAnnotation); when(bristlebackFrameworkContextMock.getBeansOfType(ConnectionStateListener.class)).thenReturn(connectionListeners); ListenersContainer listenersContainer = resolver.listenersContainer(); assertThat(listenersContainer).isNotNull(); List<ConnectionStateListener> connectionStateListeners = listenersContainer.getConnectionStateListeners(); assertThat(connectionStateListeners) .isNotNull() .hasSize(connectionListeners.size()) .containsSequence(order1, order2); }
@Test public void shouldShouldSortInIncreasingOrder2() { Map<String, ConnectionStateListener> connectionListeners = new LinkedHashMap<String, ConnectionStateListener>(); connectionListeners.put("one", order1); connectionListeners.put("two", withoutOrder); connectionListeners.put("three", order2); connectionListeners.put("four", withoutAnnotation); when(bristlebackFrameworkContextMock.getBeansOfType(ConnectionStateListener.class)).thenReturn(connectionListeners); ListenersContainer listenersContainer = resolver.listenersContainer(); assertThat(listenersContainer).isNotNull(); List<ConnectionStateListener> connectionStateListeners = listenersContainer.getConnectionStateListeners(); assertThat(connectionStateListeners) .isNotNull() .hasSize(connectionListeners.size()) .containsSequence(order1, order2); }
@Test public void shouldShouldSortInIncreasingOrder3() { Map<String, ConnectionStateListener> connectionListeners = new LinkedHashMap<String, ConnectionStateListener>(); connectionListeners.put("one", order1); connectionListeners.put("two", withoutOrder); connectionListeners.put("three", withoutAnnotation); connectionListeners.put("four", order2); when(bristlebackFrameworkContextMock.getBeansOfType(ConnectionStateListener.class)).thenReturn(connectionListeners); ListenersContainer listenersContainer = resolver.listenersContainer(); assertThat(listenersContainer).isNotNull(); List<ConnectionStateListener> connectionStateListeners = listenersContainer.getConnectionStateListeners(); assertThat(connectionStateListeners) .isNotNull() .hasSize(connectionListeners.size()) .containsSequence(order1, order2); }
@Test public void shouldShouldSortInIncreasingOrder4() { Map<String, ConnectionStateListener> connectionListeners = new LinkedHashMap<String, ConnectionStateListener>(); connectionListeners.put("one", order1); connectionListeners.put("two", order2); connectionListeners.put("three", withoutOrder); connectionListeners.put("four", withoutAnnotation); when(bristlebackFrameworkContextMock.getBeansOfType(ConnectionStateListener.class)).thenReturn(connectionListeners); ListenersContainer listenersContainer = resolver.listenersContainer(); assertThat(listenersContainer).isNotNull(); List<ConnectionStateListener> connectionStateListeners = listenersContainer.getConnectionStateListeners(); assertThat(connectionStateListeners) .isNotNull() .hasSize(connectionListeners.size()) .containsSequence(order1, order2); }