1616
1717package org .springframework .integration .support .management .graph ;
1818
19- import static org .hamcrest .Matchers .equalTo ;
20- import static org .hamcrest .Matchers .is ;
21- import static org .hamcrest .Matchers .notNullValue ;
22- import static org .junit .Assert .assertThat ;
19+ import static org .assertj .core .api .Assertions .assertThat ;
2320
2421import java .io .ByteArrayOutputStream ;
2522import java .util .Arrays ;
4542import org .springframework .integration .config .EnableIntegration ;
4643import org .springframework .integration .config .EnableIntegrationManagement ;
4744import org .springframework .integration .core .MessageProducer ;
45+ import org .springframework .integration .dsl .IntegrationFlow ;
46+ import org .springframework .integration .dsl .context .IntegrationFlowContext ;
47+ import org .springframework .integration .dsl .context .IntegrationFlowContext .IntegrationFlowRegistration ;
4848import org .springframework .integration .endpoint .EventDrivenConsumer ;
4949import org .springframework .integration .endpoint .MessageProducerSupport ;
5050import org .springframework .integration .endpoint .PollingConsumer ;
@@ -85,6 +85,9 @@ public class IntegrationGraphServerTests {
8585 @ Autowired
8686 private MessageChannel toRouter ;
8787
88+ @ Autowired
89+ private IntegrationFlowContext flowContext ;
90+
8891 @ SuppressWarnings ("unchecked" )
8992 @ Test
9093 public void test () throws Exception {
@@ -97,13 +100,13 @@ public void test() throws Exception {
97100// System . out . println(new String(baos.toByteArray()));
98101
99102 Map <?, ?> map = objectMapper .readValue (baos .toByteArray (), Map .class );
100- assertThat (map .size (), is ( equalTo ( 3 )) );
103+ assertThat (map .size ()). isEqualTo ( 3 );
101104 List <Map <?, ?>> nodes = (List <Map <?, ?>>) map .get ("nodes" );
102- assertThat (nodes , is ( notNullValue ()) );
103- assertThat (nodes .size (), is ( equalTo ( 32 )) );
105+ assertThat (nodes ). isNotNull ( );
106+ assertThat (nodes .size ()). isEqualTo ( 32 );
104107 List <Map <?, ?>> links = (List <Map <?, ?>>) map .get ("links" );
105- assertThat (links , is ( notNullValue ()) );
106- assertThat (links .size (), is ( equalTo ( 33 )) );
108+ assertThat (links ). isNotNull ( );
109+ assertThat (links .size ()). isEqualTo ( 33 );
107110
108111 toRouter .send (MessageBuilder .withPayload ("foo" ).setHeader ("foo" , "bar" ).build ());
109112 toRouter .send (MessageBuilder .withPayload ("foo" ).setHeader ("foo" , "baz" ).build ());
@@ -119,13 +122,26 @@ public void test() throws Exception {
119122// System . out . println(new String(baos.toByteArray()));
120123
121124 map = objectMapper .readValue (baos .toByteArray (), Map .class );
122- assertThat (map .size (), is ( equalTo ( 3 )) );
125+ assertThat (map .size ()). isEqualTo ( 3 );
123126 nodes = (List <Map <?, ?>>) map .get ("nodes" );
124- assertThat (nodes , is ( notNullValue ()) );
125- assertThat (nodes .size (), is ( equalTo ( 32 )) );
127+ assertThat (nodes ). isNotNull ( );
128+ assertThat (nodes .size ()). isEqualTo ( 32 );
126129 links = (List <Map <?, ?>>) map .get ("links" );
127- assertThat (links , is (notNullValue ()));
128- assertThat (links .size (), is (equalTo (35 )));
130+ assertThat (links ).isNotNull ();
131+ assertThat (links .size ()).isEqualTo (35 );
132+ }
133+
134+ @ Test
135+ public void testIncludesDynamic () {
136+ Graph graph = this .server .getGraph ();
137+ assertThat (graph .getNodes ().size ()).isEqualTo (32 );
138+ IntegrationFlow flow = f -> f .handle (m -> { });
139+ IntegrationFlowRegistration reg = this .flowContext .registration (flow ).register ();
140+ graph = this .server .rebuild ();
141+ assertThat (graph .getNodes ().size ()).isEqualTo (34 );
142+ this .flowContext .remove (reg .getId ());
143+ graph = this .server .rebuild ();
144+ assertThat (graph .getNodes ().size ()).isEqualTo (32 );
129145 }
130146
131147 @ Configuration
0 commit comments