16
16
17
17
package org .springframework .integration .support .management .graph ;
18
18
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 ;
23
20
24
21
import java .io .ByteArrayOutputStream ;
25
22
import java .util .Arrays ;
45
42
import org .springframework .integration .config .EnableIntegration ;
46
43
import org .springframework .integration .config .EnableIntegrationManagement ;
47
44
import 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 ;
48
48
import org .springframework .integration .endpoint .EventDrivenConsumer ;
49
49
import org .springframework .integration .endpoint .MessageProducerSupport ;
50
50
import org .springframework .integration .endpoint .PollingConsumer ;
@@ -85,6 +85,9 @@ public class IntegrationGraphServerTests {
85
85
@ Autowired
86
86
private MessageChannel toRouter ;
87
87
88
+ @ Autowired
89
+ private IntegrationFlowContext flowContext ;
90
+
88
91
@ SuppressWarnings ("unchecked" )
89
92
@ Test
90
93
public void test () throws Exception {
@@ -97,13 +100,13 @@ public void test() throws Exception {
97
100
// System . out . println(new String(baos.toByteArray()));
98
101
99
102
Map <?, ?> map = objectMapper .readValue (baos .toByteArray (), Map .class );
100
- assertThat (map .size (), is ( equalTo ( 3 )) );
103
+ assertThat (map .size ()). isEqualTo ( 3 );
101
104
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 );
104
107
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 );
107
110
108
111
toRouter .send (MessageBuilder .withPayload ("foo" ).setHeader ("foo" , "bar" ).build ());
109
112
toRouter .send (MessageBuilder .withPayload ("foo" ).setHeader ("foo" , "baz" ).build ());
@@ -119,13 +122,26 @@ public void test() throws Exception {
119
122
// System . out . println(new String(baos.toByteArray()));
120
123
121
124
map = objectMapper .readValue (baos .toByteArray (), Map .class );
122
- assertThat (map .size (), is ( equalTo ( 3 )) );
125
+ assertThat (map .size ()). isEqualTo ( 3 );
123
126
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 );
126
129
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 );
129
145
}
130
146
131
147
@ Configuration
0 commit comments