29
29
import io .micrometer .core .instrument .observation .DefaultMeterObservationHandler ;
30
30
import io .micrometer .core .instrument .simple .SimpleMeterRegistry ;
31
31
import io .micrometer .observation .ObservationRegistry ;
32
- import net .minidev .json .JSONArray ;
33
32
import org .assertj .core .api .InstanceOfAssertFactories ;
34
33
import org .junit .jupiter .api .Test ;
35
34
@@ -128,10 +127,10 @@ void test() throws Exception {
128
127
assertThat (nodes ).isNotNull ();
129
128
assertThat (nodes .size ()).isEqualTo (35 );
130
129
131
- JSONArray jsonArray =
130
+ List <?> jsonArray =
132
131
JsonPathUtils .evaluate (baos .toByteArray (), "$..nodes[?(@.componentType == 'gateway')]" );
133
132
134
- assertThat (jsonArray . size ()). isEqualTo (3 );
133
+ assertThat (jsonArray ). hasSize (3 );
135
134
136
135
Map <String , Object > gateway1 = (Map <String , Object >) jsonArray .get (0 );
137
136
@@ -159,9 +158,6 @@ void test() throws Exception {
159
158
this .testSource .receive ();
160
159
this .expressionRouterInput .send (MessageBuilder .withPayload ("foo" ).setHeader ("foo" , "fizChannel" ).build ());
161
160
162
- jsonArray = JsonPathUtils .evaluate (baos .toByteArray (), "$..nodes[?(@.name == 'router.router')]" );
163
- String routerJson = jsonArray .toJSONString ();
164
-
165
161
this .server .rebuild ();
166
162
graph = this .server .getGraph ();
167
163
baos = new ByteArrayOutputStream ();
@@ -181,13 +177,13 @@ void test() throws Exception {
181
177
assertThat (links .size ()).isEqualTo (35 );
182
178
183
179
jsonArray = JsonPathUtils .evaluate (baos .toByteArray (), "$..nodes[?(@.name == 'router.router')]" );
184
- routerJson = jsonArray .toJSONString ();
180
+ String routerJson = jsonArray .toString ();
185
181
assertThat (routerJson ).contains ("\" sendTimers\" :{\" successes\" :{\" count\" :4" );
186
182
jsonArray = JsonPathUtils .evaluate (baos .toByteArray (), "$..nodes[?(@.name == 'toRouter')]" );
187
- String toRouterJson = jsonArray .toJSONString ();
183
+ String toRouterJson = jsonArray .toString ();
188
184
assertThat (toRouterJson ).contains ("\" sendTimers\" :{\" successes\" :{\" count\" :4" );
189
185
jsonArray = JsonPathUtils .evaluate (baos .toByteArray (), "$..nodes[?(@.name == 'testSource')]" );
190
- String sourceJson = jsonArray .toJSONString ();
186
+ String sourceJson = jsonArray .toString ();
191
187
assertThat (sourceJson ).contains ("\" receiveCounters\" :{\" successes\" :1,\" failures\" :0" );
192
188
193
189
// stats refresh without rebuild()
@@ -196,29 +192,29 @@ void test() throws Exception {
196
192
objectMapper .enable (SerializationFeature .INDENT_OUTPUT );
197
193
objectMapper .writeValue (baos , graph );
198
194
jsonArray = JsonPathUtils .evaluate (baos .toByteArray (), "$..nodes[?(@.name == 'testSource')]" );
199
- sourceJson = jsonArray .toJSONString ();
195
+ sourceJson = jsonArray .toString ();
200
196
assertThat (sourceJson ).contains ("\" receiveCounters\" :{\" successes\" :2,\" failures\" :0" );
201
197
202
198
assertThatIllegalStateException ().isThrownBy (() -> this .testSource .receive ());
203
199
baos = new ByteArrayOutputStream ();
204
200
objectMapper .enable (SerializationFeature .INDENT_OUTPUT );
205
201
objectMapper .writeValue (baos , graph );
206
202
jsonArray = JsonPathUtils .evaluate (baos .toByteArray (), "$..nodes[?(@.name == 'testSource')]" );
207
- sourceJson = jsonArray .toJSONString ();
203
+ sourceJson = jsonArray .toString ();
208
204
assertThat (sourceJson ).contains ("\" receiveCounters\" :{\" successes\" :2,\" failures\" :1" );
209
205
210
206
jsonArray =
211
207
JsonPathUtils .evaluate (baos .toByteArray (), "$..nodes[?(@.name == 'expressionRouter.router')]" );
212
208
213
209
expressionRouter = (Map <String , Object >) jsonArray .get (0 );
214
- JSONArray routes = (JSONArray ) expressionRouter .get ("routes" );
210
+ List <?> routes = (List <?> ) expressionRouter .get ("routes" );
215
211
assertThat (routes ).hasSize (1 );
216
212
assertThat (routes .get (0 )).isEqualTo ("fizChannel" );
217
213
218
214
Object routerNodeId = expressionRouter .get ("nodeId" );
219
215
220
216
Object fizChannelNodeId =
221
- ((JSONArray ) JsonPathUtils .evaluate (baos .toByteArray (),
217
+ ((List <?> ) JsonPathUtils .evaluate (baos .toByteArray (),
222
218
"$..nodes[?(@.name == 'fizChannel')].nodeId" )).get (0 );
223
219
224
220
jsonArray =
0 commit comments