diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/IntegrationGraphServer.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/IntegrationGraphServer.java index 91f899aec0..c8899496ee 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/IntegrationGraphServer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/IntegrationGraphServer.java @@ -135,7 +135,7 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat private Map channels(Collection nodes) { Map channels = this.applicationContext - .getBeansOfType(MessageChannel.class); + .getBeansOfType(MessageChannel.class, true, false); Map channelNodes = new HashMap(); for (Entry entry : channels.entrySet()) { MessageChannel channel = entry.getValue(); @@ -150,7 +150,7 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat private void pollingAdapters(Collection nodes, Collection links, Map channelNodes) { Map spcas = this.applicationContext - .getBeansOfType(SourcePollingChannelAdapter.class); + .getBeansOfType(SourcePollingChannelAdapter.class, true, false); for (Entry entry : spcas.entrySet()) { SourcePollingChannelAdapter adapter = entry.getValue(); MessageSourceNode sourceNode = this.nodeFactory.sourceNode(entry.getKey(), adapter); @@ -162,7 +162,7 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat private void gateways(Collection nodes, Collection links, Map channelNodes) { Map gateways = this.applicationContext - .getBeansOfType(MessagingGatewaySupport.class); + .getBeansOfType(MessagingGatewaySupport.class, true, false); for (Entry entry : gateways.entrySet()) { MessagingGatewaySupport gateway = entry.getValue(); MessageGatewayNode gatewayNode = this.nodeFactory.gatewayNode(entry.getKey(), gateway); @@ -170,7 +170,7 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat producerLink(links, channelNodes, gatewayNode); } Map gpfbs = this.applicationContext - .getBeansOfType(GatewayProxyFactoryBean.class); + .getBeansOfType(GatewayProxyFactoryBean.class, true, false); for (Entry entry : gpfbs.entrySet()) { Map methodMap = entry.getValue().getGateways(); for (Entry gwEntry : methodMap.entrySet()) { @@ -195,7 +195,7 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat private void producers(Collection nodes, Collection links, Map channelNodes) { Map producers = this.applicationContext - .getBeansOfType(MessageProducerSupport.class); + .getBeansOfType(MessageProducerSupport.class, true, false); for (Entry entry : producers.entrySet()) { MessageProducerSupport producer = entry.getValue(); MessageProducerNode producerNode = this.nodeFactory.producerNode(entry.getKey(), producer); @@ -206,7 +206,8 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat private void consumers(Collection nodes, Collection links, Map channelNodes) { - Map consumers = this.applicationContext.getBeansOfType(IntegrationConsumer.class); + Map consumers = this.applicationContext.getBeansOfType(IntegrationConsumer.class, + true, false); for (Entry entry : consumers.entrySet()) { IntegrationConsumer consumer = entry.getValue(); MessageHandlerNode handlerNode = consumer instanceof PollingConsumer diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java index adfc9a8f2d..528803c786 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java @@ -16,10 +16,7 @@ package org.springframework.integration.support.management.graph; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import java.io.ByteArrayOutputStream; import java.util.Arrays; @@ -45,6 +42,9 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.config.EnableIntegrationManagement; import org.springframework.integration.core.MessageProducer; +import org.springframework.integration.dsl.IntegrationFlow; +import org.springframework.integration.dsl.context.IntegrationFlowContext; +import org.springframework.integration.dsl.context.IntegrationFlowRegistration; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.endpoint.MessageProducerSupport; import org.springframework.integration.endpoint.PollingConsumer; @@ -82,6 +82,9 @@ public class IntegrationGraphServerTests { @Autowired private MessageChannel toRouter; + @Autowired + private IntegrationFlowContext flowContext; + @SuppressWarnings("unchecked") @Test public void test() throws Exception { @@ -94,13 +97,13 @@ public class IntegrationGraphServerTests { // System . out . println(new String(baos.toByteArray())); Map map = objectMapper.readValue(baos.toByteArray(), Map.class); - assertThat(map.size(), is(equalTo(3))); + assertThat(map.size()).isEqualTo(3); List> nodes = (List>) map.get("nodes"); - assertThat(nodes, is(notNullValue())); - assertThat(nodes.size(), is(equalTo(32))); + assertThat(nodes).isNotNull(); + assertThat(nodes.size()).isEqualTo(32); List> links = (List>) map.get("links"); - assertThat(links, is(notNullValue())); - assertThat(links.size(), is(equalTo(33))); + assertThat(links).isNotNull(); + assertThat(links.size()).isEqualTo(33); toRouter.send(MessageBuilder.withPayload("foo").setHeader("foo", "bar").build()); toRouter.send(MessageBuilder.withPayload("foo").setHeader("foo", "baz").build()); @@ -116,13 +119,26 @@ public class IntegrationGraphServerTests { // System . out . println(new String(baos.toByteArray())); map = objectMapper.readValue(baos.toByteArray(), Map.class); - assertThat(map.size(), is(equalTo(3))); + assertThat(map.size()).isEqualTo(3); nodes = (List>) map.get("nodes"); - assertThat(nodes, is(notNullValue())); - assertThat(nodes.size(), is(equalTo(32))); + assertThat(nodes).isNotNull(); + assertThat(nodes.size()).isEqualTo(32); links = (List>) map.get("links"); - assertThat(links, is(notNullValue())); - assertThat(links.size(), is(equalTo(35))); + assertThat(links).isNotNull(); + assertThat(links.size()).isEqualTo(35); + } + + @Test + public void testIncludesDynamic() { + Graph graph = this.server.getGraph(); + assertThat(graph.getNodes().size()).isEqualTo(32); + IntegrationFlow flow = f -> f.handle(m -> { }); + IntegrationFlowRegistration reg = this.flowContext.registration(flow).register(); + graph = this.server.rebuild(); + assertThat(graph.getNodes().size()).isEqualTo(34); + this.flowContext.remove(reg.getId()); + graph = this.server.rebuild(); + assertThat(graph.getNodes().size()).isEqualTo(32); } @Configuration