Renaming openecomp to onap
[aai/sparky-be.git] / src / test / java / org / onap / aai / sparky / util / TreeWalkerTest.java
1 /* 
2 * ============LICENSE_START=======================================================
3 * SPARKY (AAI UI service)
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
7 * All rights reserved.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12
13 *      http://www.apache.org/licenses/LICENSE-2.0
14
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
21
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
24 */
25
26 package org.onap.aai.sparky.util;
27
28 import static org.junit.Assert.assertEquals;
29 import static org.junit.Assert.assertNotNull;
30 import static org.junit.Assert.assertNull;
31 import static org.junit.Assert.assertTrue;
32
33 import java.io.IOException;
34 import java.util.ArrayList;
35 import java.util.List;
36
37 import org.junit.Before;
38 import org.junit.Test;
39 import org.onap.aai.sparky.util.NodeUtils;
40 import org.onap.aai.sparky.util.TreeWalker;
41
42 import com.fasterxml.jackson.core.JsonProcessingException;
43 import com.fasterxml.jackson.databind.JsonNode;
44 import com.fasterxml.jackson.databind.ObjectMapper;
45
46 import ch.qos.logback.classic.Level;
47
48 /**
49  * The Class TreeWalkerTest.
50  */
51 public class TreeWalkerTest {
52
53
54   /**
55    * Inits the.
56    *
57    * @throws Exception the exception
58    */
59   @Before
60   public void init() throws Exception {
61   }
62
63   /**
64    * Validate json node conversion null input.
65    */
66   @Test
67   public void validateJsonNodeConversionNullInput() {
68
69     TreeWalker walker = new TreeWalker();
70
71     try {
72       JsonNode convertedNode = walker.convertJsonToNode(null);
73       assertNull("Converted node should have be null", convertedNode);
74
75     } catch (JsonProcessingException exc) {
76       // expected
77     } catch (IOException exc) {
78       // expeted
79     }
80
81   }
82
83   /**
84    * Validate json node conversion empty non json input.
85    */
86   @Test
87   public void validateJsonNodeConversionEmptyNonJsonInput() {
88
89     TreeWalker walker = new TreeWalker();
90
91     try {
92       JsonNode convertedNode = walker.convertJsonToNode("");
93       assertNull("Converted node should have be null", convertedNode);
94
95     } catch (JsonProcessingException exc) {
96       // expected
97     } catch (IOException exc) {
98       // expeted
99     }
100
101   }
102
103   /**
104    * Validate json node conversion empty json input.
105    */
106   @Test
107   public void validateJsonNodeConversionEmptyJsonInput() {
108
109     TreeWalker walker = new TreeWalker();
110
111     try {
112       JsonNode convertedNode = walker.convertJsonToNode("{}");
113       assertNotNull("Converted node should not be null", convertedNode);
114
115       ObjectMapper objectMapper = new ObjectMapper();
116       String convertedNodeAsStr = objectMapper.writeValueAsString(convertedNode);
117
118       assertEquals("{}", convertedNodeAsStr);
119
120     } catch (JsonProcessingException exc) {
121       // expected
122     } catch (IOException exc) {
123       // expeted
124     }
125
126   }
127
128   /**
129    * Validate walk tree null input.
130    */
131   @Test
132   public void validateWalkTreeNullInput() {
133
134     TreeWalker walker = new TreeWalker();
135
136     List<String> paths = new ArrayList<String>();
137     walker.walkTree(paths, null);
138     assertEquals(0, paths.size());
139
140   }
141
142   /**
143    * Validate walk tree empty node.
144    */
145   @Test
146   public void validateWalkTreeEmptyNode() {
147
148     try {
149       TreeWalker walker = new TreeWalker();
150       List<String> paths = new ArrayList<String>();
151       walker.walkTree(paths, walker.convertJsonToNode("{}"));
152       assertEquals(0, paths.size());
153     } catch (JsonProcessingException exc) {
154       // expected
155     } catch (IOException exc) {
156       // expected
157     }
158
159   }
160
161   /**
162    * Validate walk tree one parent node.
163    */
164   @Test
165   public void validateWalkTreeOneParentNode() {
166
167     try {
168       TreeWalker walker = new TreeWalker();
169       List<String> paths = new ArrayList<String>();
170       walker.walkTree(paths, walker.convertJsonToNode("{ \"root\" : { } }"));
171       assertEquals(1, paths.size());
172     } catch (JsonProcessingException exc) {
173       // expected
174     } catch (IOException exc) {
175       // expected
176     }
177
178   }
179
180   /**
181    * Validate walk tree one parent node with object array.
182    */
183   @Test
184   public void validateWalkTreeOneParentNodeWithObjectArray() {
185
186     try {
187       String jsonStr =
188           "{\"Employee\":[{\"id\":\"101\",\"name\":\"Pushkar\",\"salary\":\"5000\"},"
189           + "{\"id\":\"102\",\"name\":\"Rahul\",\"salary\":\"4000\"},"
190           + "{\"id\":\"103\",\"name\":\"tanveer\",\"salary\":\"56678\"}]}";
191       TreeWalker walker = new TreeWalker();
192       List<String> paths = new ArrayList<String>();
193       walker.walkTree(paths, walker.convertJsonToNode(jsonStr));
194       assertEquals(9, paths.size());
195     } catch (JsonProcessingException exc) {
196       // expected
197     } catch (IOException exc) {
198       // expected
199     }
200
201   }
202
203   /**
204    * Validate walk tree one parent node with value array.
205    */
206   @Test
207   public void validateWalkTreeOneParentNodeWithValueArray() {
208
209     try {
210       String jsonStr = "{ \"colors\" : [ \"yellow\", \"blue\", \"red\" ] }";
211       TreeWalker walker = new TreeWalker();
212       List<String> paths = new ArrayList<String>();
213       walker.walkTree(paths, walker.convertJsonToNode(jsonStr));
214
215       assertEquals(3, paths.size());
216     } catch (JsonProcessingException exc) {
217       // expected
218     } catch (IOException exc) {
219       // expected
220     }
221
222   }
223
224   /**
225    * Test walk for complex entity type aai entity node descriptors.
226    */
227   @Test
228   public void testWalkForComplexEntityType_AaiEntityNodeDescriptors() {
229
230     try {
231       String jsonStr =
232           "{    \"generalNodeClass\": {        \"class\": \"aai-entity-node general-node\","
233           + "        \"visualElements\": [            {                \"type\": \"circle\","
234           + "                \"class\": \"outer\",                \"svgAttributes\": {"
235           + "                    \"r\": \"20\"                }            },            {"
236           + "                \"type\": \"circle\",                \"class\": \"inner\",     "
237           + "           \"svgAttributes\": {                    \"r\": \"10\"                "
238           + "}            },            {                \"type\": \"text\",                "
239           + "\"class\": \"id-type-label\",                \"displayKey\": \"itemType\",       "
240           + "         \"shapeAttributes\": {                    \"offset\": {                 "
241           + "       \"x\": \"0\",                        \"y\": \"30\"                    }  "
242           + "              }            },            {                \"type\": \"text\",    "
243           + "            \"class\": \"id-value-label\",                \"displayKey\":"
244           + " \"itemNameValue\",                \"shapeAttributes\": {                   "
245           + " \"offset\": {                        \"x\": \"0\",                       "
246           + " \"y\": \"40\"                    }                }            }        ] "
247           + "   },    \"searchedNodeClass\": {        \"class\": \"aai-entity-node search-node\","
248           + "        \"visualElements\": [            {                \"type\": \"circle\","
249           + "                \"class\": \"outer\",                \"svgAttributes\": { "
250           + "                   \"r\": \"20\"                }            },            { "
251           + "               \"type\": \"circle\",                \"class\": \"inner\",     "
252           + "           \"svgAttributes\": {                    \"r\": \"10\"                }"
253           + "            },            {                \"type\": \"text\",                "
254           + "\"class\": \"id-type-label\",                \"displayKey\": \"itemType\",     "
255           + "           \"shapeAttributes\": {                    \"offset\": {             "
256           + "           \"x\": \"0\",                        \"y\": \"30\"                    }"
257           + "                }            },            {                \"type\": \"text\", "
258           + "               \"class\": \"id-value-label\",                "
259           + "\"displayKey\": \"itemNameValue\",                \"shapeAttributes\": {"
260           + "                    \"offset\": {                        \"x\": \"0\","
261           + "                        \"y\": \"40\"                    }                }"
262           + "            }        ]    },    \"selectedSearchedNodeClass\": {        "
263           + "\"class\": \"aai-entity-node selected-search-node\",        \"visualElements\": ["
264           + "            {                \"type\": \"circle\",                "
265           + "\"class\": \"outer\",                \"svgAttributes\": {"
266           + "                    \"r\": \"20\"                }            },            {"
267           + "                \"type\": \"circle\",                \"class\": \"inner\","
268           + "                \"svgAttributes\": {                    \"r\": \"10\"     "
269           + "           }            },            {                \"type\": \"text\",     "
270           + "           \"class\": \"id-type-label\",                \"displayKey\": \"itemType\","
271           + "                \"shapeAttributes\": {                    \"offset\": {"
272           + "                        \"x\": \"0\",                        \"y\": \"30\""
273           + "                   }                }            },            {          "
274           + "      \"type\": \"text\",                \"class\": \"id-value-label\",     "
275           + "           \"displayKey\": \"itemNameValue\",                \"shapeAttributes\": {"
276           + "                    \"offset\": {                        \"x\": \"0\",           "
277           + "             \"y\": \"40\"                    }                }            }        ]"
278           + "    },    \"selectedNodeClass\": {        \"class\":"
279           + " \"aai-entity-node selected-node\","
280           + "        \"visualElements\": [            {                \"type\": \"circle\","
281           + "                \"class\": \"outer\",                \"svgAttributes\": {"
282           + "                    \"r\": \"20\"                }            },            {"
283           + "                \"type\": \"circle\",                \"class\": \"inner\","
284           + "                \"svgAttributes\": {                    \"r\": \"10\"    "
285           + "            }            },            {                \"type\": \"text\",    "
286           + "            \"class\": \"id-type-label\",                \"displayKey\": \"itemType\","
287           + "                \"shapeAttributes\": {                    \"offset\": "
288           + "{                "
289           + "        \"x\": \"0\",                        \"y\": \"30\"                    } "
290           + "               }            },            {                \"type\": \"text\","
291           + "                \"class\": \"id-value-label\",                \"displayKey\":"
292           + " \"itemNameValue\",                \"shapeAttributes\": {                    "
293           + "\"offset\": {                        \"x\": \"0\",                        "
294           + "\"y\": \"40\"                    }                }            }        ]    }}";
295       TreeWalker walker = new TreeWalker();
296       List<String> paths = new ArrayList<String>();
297       walker.walkTree(paths, walker.convertJsonToNode(jsonStr));
298
299       assertEquals(68, paths.size());
300
301       /*
302        * Example of expected value
303        * 
304        * generalNodeClass.class=aai-entity-node general-node
305        * generalNodeClass.visualElements.type=circle generalNodeClass.visualElements.class=outer
306        * generalNodeClass.visualElements.svgAttributes.r=20
307        * generalNodeClass.visualElements.type=circle generalNodeClass.visualElements.class=inner
308        * generalNodeClass.visualElements.svgAttributes.r=10
309        * generalNodeClass.visualElements.type=text
310        * generalNodeClass.visualElements.class=id-type-label
311        * generalNodeClass.visualElements.displayKey=itemType
312        * generalNodeClass.visualElements.shapeAttributes.offset.x=0
313        * generalNodeClass.visualElements.shapeAttributes.offset.y=30
314        * generalNodeClass.visualElements.type=text
315        * generalNodeClass.visualElements.class=id-value-label
316        * generalNodeClass.visualElements.displayKey=itemNameValue
317        * generalNodeClass.visualElements.shapeAttributes.offset.x=0
318        * generalNodeClass.visualElements.shapeAttributes.offset.y=40
319        * searchedNodeClass.class=aai-entity-node search-node
320        * searchedNodeClass.visualElements.type=circle searchedNodeClass.visualElements.class=outer
321        * searchedNodeClass.visualElements.svgAttributes.r=20
322        * searchedNodeClass.visualElements.type=circle searchedNodeClass.visualElements.class=inner
323        * searchedNodeClass.visualElements.svgAttributes.r=10
324        * searchedNodeClass.visualElements.type=text
325        * searchedNodeClass.visualElements.class=id-type-label
326        * searchedNodeClass.visualElements.displayKey=itemType
327        * searchedNodeClass.visualElements.shapeAttributes.offset.x=0
328        * searchedNodeClass.visualElements.shapeAttributes.offset.y=30
329        * searchedNodeClass.visualElements.type=text
330        * searchedNodeClass.visualElements.class=id-value-label
331        * searchedNodeClass.visualElements.displayKey=itemNameValue
332        * searchedNodeClass.visualElements.shapeAttributes.offset.x=0
333        * searchedNodeClass.visualElements.shapeAttributes.offset.y=40
334        * selectedSearchedNodeClass.class=aai-entity-node selected-search-node
335        * selectedSearchedNodeClass.visualElements.type=circle
336        * selectedSearchedNodeClass.visualElements.class=outer
337        * selectedSearchedNodeClass.visualElements.svgAttributes.r=20
338        * selectedSearchedNodeClass.visualElements.type=circle
339        * selectedSearchedNodeClass.visualElements.class=inner
340        * selectedSearchedNodeClass.visualElements.svgAttributes.r=10
341        * selectedSearchedNodeClass.visualElements.type=text
342        * selectedSearchedNodeClass.visualElements.class=id-type-label
343        * selectedSearchedNodeClass.visualElements.displayKey=itemType
344        * selectedSearchedNodeClass.visualElements.shapeAttributes.offset.x=0
345        * selectedSearchedNodeClass.visualElements.shapeAttributes.offset.y=30
346        * selectedSearchedNodeClass.visualElements.type=text
347        * selectedSearchedNodeClass.visualElements.class=id-value-label
348        * selectedSearchedNodeClass.visualElements.displayKey=itemNameValue
349        * selectedSearchedNodeClass.visualElements.shapeAttributes.offset.x=0
350        * selectedSearchedNodeClass.visualElements.shapeAttributes.offset.y=40
351        * selectedNodeClass.class=aai-entity-node selected-node
352        * selectedNodeClass.visualElements.type=circle selectedNodeClass.visualElements.class=outer
353        * selectedNodeClass.visualElements.svgAttributes.r=20
354        * selectedNodeClass.visualElements.type=circle selectedNodeClass.visualElements.class=inner
355        * selectedNodeClass.visualElements.svgAttributes.r=10
356        * selectedNodeClass.visualElements.type=text
357        * selectedNodeClass.visualElements.class=id-type-label
358        * selectedNodeClass.visualElements.displayKey=itemType
359        * selectedNodeClass.visualElements.shapeAttributes.offset.x=0
360        * selectedNodeClass.visualElements.shapeAttributes.offset.y=30
361        * selectedNodeClass.visualElements.type=text
362        * selectedNodeClass.visualElements.class=id-value-label
363        * selectedNodeClass.visualElements.displayKey=itemNameValue
364        * selectedNodeClass.visualElements.shapeAttributes.offset.x=0
365        * selectedNodeClass.visualElements.shapeAttributes.offset.y=40
366        */
367
368     } catch (JsonProcessingException exc) {
369       // expected
370     } catch (IOException exc) {
371       // expected
372     }
373
374   }
375
376   /**
377    * Test complex object inversion equality.
378    */
379   @Test
380   public void testComplexObjectInversionEquality() {
381
382     /**
383      * Dave Adams (1-Nov-2016):
384      *
385      * Ok.. I agree...weird title of the test-case. This test is focused on the isEqual equality
386      * test within the NodeUtils helper class which compares the sorted structural paths of two Json
387      * Object representations. I attempted to normalize unordered structures to produce an equality
388      * result, as there doesn't seem to be any natural equality test between two JsonNode objects
389      * that I could find to date.
390      *
391      * Basically, this test is confirming that if the same object values are present in different
392      * orders, they are effectively the same Json Object representation, and pass, at least my
393      * structural value equality test.
394      *
395      * I reordered the aaiEntityNodeDescriptors top level class types, and change the order of the
396      * x,y coordinates to be y,x. Same values different order. Once again, the expectation is that
397      * both representations are objectively equal, they just have different json representations.
398      */
399
400     try {
401       String n1Str =
402           "{    \"generalNodeClass\": {        \"class\": \"aai-entity-node general-node\","
403           + "        \"visualElements\": [            {                \"type\": \"circle\","
404           + "                \"class\": \"outer\",                \"svgAttributes\": {"
405           + "                    \"r\": \"20\"                }            },            {"
406           + "                \"type\": \"circle\",                \"class\": \"inner\","
407           + "                \"svgAttributes\": {                    \"r\": \"10\""
408           + "                }            },            {                \"type\": \"text\","
409           + "                \"class\": \"id-type-label\",                \"displayKey\":"
410           + " \"itemType\",                \"shapeAttributes\": {                    \"offset\":"
411           + " {                        \"x\": \"0\",                        \"y\": \"30\""
412           + "                    }                }            },            {"
413           + "                \"type\": \"text\",                \"class\": \"id-value-label\","
414           + "                \"displayKey\": \"itemNameValue\","
415           + "                \"shapeAttributes\": {                    \"offset\":"
416           + " {                        \"x\": \"0\",                        \"y\": \"40\""
417           + "                    }                }            }        ]    },"
418           + "    \"searchedNodeClass\": {        \"class\": \"aai-entity-node search-node\","
419           + "        \"visualElements\": [            {                \"type\": \"circle\","
420           + "                \"class\": \"outer\",                \"svgAttributes\": {"
421           + "                    \"r\": \"20\"                }            },            {"
422           + "                \"type\": \"circle\",                \"class\": \"inner\","
423           + "                \"svgAttributes\": {                    \"r\": \"10\""
424           + "                }            },            {                \"type\": \"text\","
425           + "                \"class\": \"id-type-label\",                \"displayKey\":"
426           + " \"itemType\",                \"shapeAttributes\": {                    \"offset\": {"
427           + "                        \"x\": \"0\",                        \"y\": \"30\""
428           + "                    }                }            },            {"
429           + "                \"type\": \"text\",                \"class\": \"id-value-label\","
430           + "                \"displayKey\": \"itemNameValue\","
431           + "                \"shapeAttributes\": {                    \"offset\": {"
432           + "                        \"x\": \"0\",                        \"y\": \"40\""
433           + "                    }                }            }        ]    },"
434           + "    \"selectedSearchedNodeClass\": {        \"class\":"
435           + " \"aai-entity-node selected-search-node\",        \"visualElements\": ["
436           + "            {                \"type\": \"circle\",                \"class\":"
437           + " \"outer\",                \"svgAttributes\": {                    \"r\": \"20\""
438           + "                }            },            {                \"type\": \"circle\","
439           + "                \"class\": \"inner\",                \"svgAttributes\": {"
440           + "                    \"r\": \"10\"                }            },            {"
441           + "                \"type\": \"text\",                \"class\": \"id-type-label\","
442           + "                \"displayKey\": \"itemType\",                \"shapeAttributes\": {"
443           + "                    \"offset\": {                        \"x\": \"0\","
444           + "                        \"y\": \"30\"                    }                }"
445           + "            },            {                \"type\": \"text\","
446           + "                \"class\": \"id-value-label\","
447           + "                \"displayKey\": \"itemNameValue\","
448           + "                \"shapeAttributes\": {                    \"offset\": {"
449           + "                        \"x\": \"0\",                        \"y\": \"40\""
450           + "                    }                }            }        ]    },"
451           + "    \"selectedNodeClass\": {        \"class\": \"aai-entity-node selected-node\","
452           + "        \"visualElements\": [            {                \"type\": \"circle\","
453           + "                \"class\": \"outer\",                \"svgAttributes\": {"
454           + "                    \"r\": \"20\"                }            },            {"
455           + "                \"type\": \"circle\",                \"class\": \"inner\","
456           + "                \"svgAttributes\": {                    \"r\": \"10\""
457           + "                }            },            {                \"type\": \"text\","
458           + "                \"class\": \"id-type-label\",                \"displayKey\":"
459           + " \"itemType\",                \"shapeAttributes\": {"
460           + "                    \"offset\": {                        \"x\": \"0\","
461           + "                        \"y\": \"30\"                    }"
462           + "                }            },            {                \"type\": \"text\","
463           + "                \"class\": \"id-value-label\",                \"displayKey\":"
464           + " \"itemNameValue\",                \"shapeAttributes\": {"
465           + "                    \"offset\": {                        \"x\": \"0\","
466           + "                        \"y\": \"40\"                    }                }"
467           + "            }        ]    }}";
468       String n2Str =
469           "{    \"searchedNodeClass\": {        \"class\": \"aai-entity-node search-node\","
470           + "        \"visualElements\": [            {                \"type\": \"circle\","
471           + "                \"class\": \"outer\",                \"svgAttributes\": {"
472           + "                    \"r\": \"20\"                }            },"
473           + "            {                \"type\": \"circle\","
474           + "                \"class\": \"inner\",                \"svgAttributes\": {"
475           + "                    \"r\": \"10\"                }            },            {"
476           + "                \"type\": \"text\",                \"class\": \"id-type-label\","
477           + "                \"displayKey\": \"itemType\",                \"shapeAttributes\": {"
478           + "                    \"offset\": {                        \"y\": \"30\","
479           + "                        \"x\": \"0\"                    }                }"
480           + "            },            {                \"type\": \"text\","
481           + "                \"class\": \"id-value-label\","
482           + "                \"displayKey\": \"itemNameValue\","
483           + "                \"shapeAttributes\": {                    \"offset\": {"
484           + "                        \"y\": \"40\",                        \"x\": \"0\""
485           + "                    }                }            }        ]    },"
486           + "    \"selectedSearchedNodeClass\": {        \"class\":"
487           + " \"aai-entity-node selected-search-node\",        \"visualElements\": ["
488           + "            {                \"type\": \"circle\",                \"class\":"
489           + " \"outer\",                \"svgAttributes\": {                    \"r\": \"20\""
490           + "                }            },            {                \"type\": \"circle\","
491           + "                \"class\": \"inner\",                \"svgAttributes\": {"
492           + "                    \"r\": \"10\"                }            },            {"
493           + "                \"type\": \"text\",                \"class\": \"id-type-label\","
494           + "                \"displayKey\": \"itemType\",                \"shapeAttributes\": {"
495           + "                    \"offset\": {                        \"y\": \"30\","
496           + "                        \"x\": \"0\"                    }                }"
497           + "            },            {                \"type\": \"text\","
498           + "                \"class\": \"id-value-label\","
499           + "                \"displayKey\": \"itemNameValue\","
500           + "                \"shapeAttributes\": {                    \"offset\": {"
501           + "                        \"y\": \"40\",                        \"x\": \"0\""
502           + "                    }                }            }        ]    },"
503           + "    \"selectedNodeClass\": {        \"class\": \"aai-entity-node selected-node\","
504           + "        \"visualElements\": [            {                \"type\": \"circle\","
505           + "                \"class\": \"outer\",                \"svgAttributes\": {"
506           + "                    \"r\": \"20\"                }            },            {"
507           + "                \"type\": \"circle\",                \"class\": \"inner\","
508           + "                \"svgAttributes\": {                    \"r\": \"10\""
509           + "                }            },            {                \"type\": \"text\","
510           + "                \"class\": \"id-type-label\","
511           + "                \"displayKey\": \"itemType\",                \"shapeAttributes\": {"
512           + "                    \"offset\": {                        \"y\": \"30\","
513           + "                        \"x\": \"0\"                    }                }"
514           + "            },            {                \"type\": \"text\","
515           + "                \"class\": \"id-value-label\","
516           + "                \"displayKey\": \"itemNameValue\","
517           + "                \"shapeAttributes\": {                    \"offset\": {"
518           + "                        \"y\": \"40\",                        \"x\": \"0\""
519           + "                    }                }            }        ]    },"
520           + "        \"generalNodeClass\": {            \"class\":"
521           + " \"aai-entity-node general-node\",            \"visualElements\": ["
522           + "                {                    \"type\": \"circle\","
523           + "                    \"class\": \"outer\",                    \"svgAttributes\": {"
524           + "                        \"r\": \"20\"                    }                },"
525           + "                {                    \"type\": \"circle\","
526           + "                    \"class\": \"inner\",                    \"svgAttributes\": {"
527           + "                        \"r\": \"10\"                    }                },"
528           + "                {                    \"type\": \"text\","
529           + "                    \"class\": \"id-type-label\",                    \"displayKey\":"
530           + " \"itemType\",                    \"shapeAttributes\": {"
531           + "                        \"offset\": {                 \"y\": \"30\","
532           + "                            \"x\": \"0\"                        }"
533           + "                    }                },                {"
534           + "                    \"type\": \"text\","
535           + "                    \"class\": \"id-value-label\",                    \"displayKey\":"
536           + " \"itemNameValue\",                    \"shapeAttributes\": {"
537           + "                        \"offset\": {                            \"y\": \"40\","
538           + "                            \"x\": \"0\"                        }"
539           + "                    }                }            ]    }}";
540
541       TreeWalker walker = new TreeWalker();
542       List<String> n1Paths = new ArrayList<String>();
543       List<String> n2Paths = new ArrayList<String>();
544
545       JsonNode n1 = walker.convertJsonToNode(n1Str);
546       JsonNode n2 = walker.convertJsonToNode(n2Str);
547       walker.walkTree(n1Paths, n1);
548       walker.walkTree(n2Paths, n2);
549
550       assertEquals(68, n1Paths.size());
551       assertEquals(68, n2Paths.size());
552
553       assertTrue(NodeUtils.isEqual(n1, n2));
554
555     } catch (JsonProcessingException exc) {
556       // expected
557     } catch (IOException exc) {
558       // expected
559     }
560
561   }
562
563
564
565 }