@@ -161,12 +161,11 @@ void testConvertDocument() throws Exception {
161
161
Object result = XmlDomUtils .convertDocument (doc , MAX_RECURSION );
162
162
163
163
assertNotNull (result );
164
- assertTrue (result instanceof List );
164
+ assertTrue (result instanceof Map );
165
165
166
166
@ SuppressWarnings ("unchecked" )
167
- List <Object > resultList = (List <Object >) result ;
168
- assertEquals (1 , resultList .size ());
169
- assertTrue (resultList .get (0 ) instanceof Map );
167
+ Map <String , Object > resultMap = (Map <String , Object >) result ;
168
+ assertTrue (resultMap .containsKey ("children" ));
170
169
}
171
170
172
171
@ Test
@@ -184,12 +183,11 @@ void testConvertElement() throws Exception {
184
183
Object result = XmlDomUtils .convertElement (element , MAX_RECURSION );
185
184
186
185
assertNotNull (result );
187
- assertTrue (result instanceof List );
186
+ assertTrue (result instanceof Map );
188
187
189
188
@ SuppressWarnings ("unchecked" )
190
- List <Object > resultList = (List <Object >) result ;
191
- assertEquals (1 , resultList .size ());
192
- assertTrue (resultList .get (0 ) instanceof Map );
189
+ Map <String , Object > resultMap = (Map <String , Object >) result ;
190
+ assertTrue (resultMap .containsKey ("children" ));
193
191
}
194
192
195
193
@ Test
@@ -206,7 +204,7 @@ void testProcessXmlForWaf_withDocument() throws Exception {
206
204
Object result = XmlDomUtils .processXmlForWaf (doc , MAX_RECURSION );
207
205
208
206
assertNotNull (result );
209
- assertTrue (result instanceof List );
207
+ assertTrue (result instanceof Map );
210
208
}
211
209
212
210
@ Test
@@ -218,7 +216,7 @@ void testProcessXmlForWaf_withElement() throws Exception {
218
216
Object result = XmlDomUtils .processXmlForWaf (element , MAX_RECURSION );
219
217
220
218
assertNotNull (result );
221
- assertTrue (result instanceof List );
219
+ assertTrue (result instanceof Map );
222
220
}
223
221
224
222
@ Test
@@ -228,12 +226,11 @@ void testProcessXmlForWaf_withXmlString() {
228
226
Object result = XmlDomUtils .processXmlForWaf (xmlContent , MAX_RECURSION );
229
227
230
228
assertNotNull (result );
231
- assertTrue (result instanceof List );
229
+ assertTrue (result instanceof Map );
232
230
233
231
@ SuppressWarnings ("unchecked" )
234
- List <Object > resultList = (List <Object >) result ;
235
- assertEquals (1 , resultList .size ());
236
- assertTrue (resultList .get (0 ) instanceof Map );
232
+ Map <String , Object > resultMap = (Map <String , Object >) result ;
233
+ assertTrue (resultMap .containsKey ("children" ));
237
234
}
238
235
239
236
@ Test
@@ -258,19 +255,14 @@ void testParseXmlStringToWafFormat_validXml() throws Exception {
258
255
Object result = XmlDomUtils .parseXmlStringToWafFormat (xmlContent , MAX_RECURSION );
259
256
260
257
assertNotNull (result );
261
- assertTrue (result instanceof List );
262
-
263
- @ SuppressWarnings ("unchecked" )
264
- List <Object > resultList = (List <Object >) result ;
265
- assertEquals (1 , resultList .size ());
266
- assertTrue (resultList .get (0 ) instanceof Map );
258
+ assertTrue (result instanceof Map );
267
259
268
260
@ SuppressWarnings ("unchecked" )
269
- Map <String , Object > rootMap = (Map <String , Object >) resultList . get ( 0 ) ;
270
- assertTrue (rootMap .containsKey ("children" ));
261
+ Map <String , Object > resultMap = (Map <String , Object >) result ;
262
+ assertTrue (resultMap .containsKey ("children" ));
271
263
272
264
@ SuppressWarnings ("unchecked" )
273
- List <Object > children = (List <Object >) rootMap .get ("children" );
265
+ List <Object > children = (List <Object >) resultMap .get ("children" );
274
266
assertEquals (2 , children .size ()); // title and author elements
275
267
}
276
268
@@ -301,7 +293,7 @@ void testHandleXmlString_validXml() {
301
293
Object result = XmlDomUtils .handleXmlString (xmlContent , MAX_RECURSION );
302
294
303
295
assertNotNull (result );
304
- assertTrue (result instanceof List );
296
+ assertTrue (result instanceof Map );
305
297
}
306
298
307
299
@ Test
@@ -332,7 +324,7 @@ void testXmlWithNamespaces() throws Exception {
332
324
Object result = XmlDomUtils .processXmlForWaf (xmlContent , MAX_RECURSION );
333
325
334
326
assertNotNull (result );
335
- assertTrue (result instanceof List );
327
+ assertTrue (result instanceof Map );
336
328
}
337
329
338
330
@ Test
@@ -342,7 +334,7 @@ void testXmlWithCDATA() throws Exception {
342
334
Object result = XmlDomUtils .processXmlForWaf (xmlContent , MAX_RECURSION );
343
335
344
336
assertNotNull (result );
345
- assertTrue (result instanceof List );
337
+ assertTrue (result instanceof Map );
346
338
}
347
339
348
340
@ Test
@@ -371,19 +363,14 @@ void testComplexXmlStructure() throws Exception {
371
363
Object result = XmlDomUtils .processXmlForWaf (xmlContent , MAX_RECURSION );
372
364
373
365
assertNotNull (result );
374
- assertTrue (result instanceof List );
375
-
376
- @ SuppressWarnings ("unchecked" )
377
- List <Object > resultList = (List <Object >) result ;
378
- assertEquals (1 , resultList .size ());
379
- assertTrue (resultList .get (0 ) instanceof Map );
366
+ assertTrue (result instanceof Map );
380
367
381
368
@ SuppressWarnings ("unchecked" )
382
- Map <String , Object > rootMap = (Map <String , Object >) resultList . get ( 0 ) ;
383
- assertTrue (rootMap .containsKey ("children" ));
369
+ Map <String , Object > resultMap = (Map <String , Object >) result ;
370
+ assertTrue (resultMap .containsKey ("children" ));
384
371
385
372
@ SuppressWarnings ("unchecked" )
386
- List <Object > children = (List <Object >) rootMap .get ("children" );
373
+ List <Object > children = (List <Object >) resultMap .get ("children" );
387
374
// Should have 2 book elements (ignoring whitespace text nodes)
388
375
long bookElements = children .stream ().filter (child -> child instanceof Map ).count ();
389
376
assertEquals (2 , bookElements );
0 commit comments