Bug 2327: Handle binary data in NormalizedNode streaming
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / datastore / util / TestModel.java
1 /*
2  *
3  *  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  *  This program and the accompanying materials are made available under the
6  *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  *  and is available at http://www.eclipse.org/legal/epl-v10.html
8  *
9  */
10
11 package org.opendaylight.controller.cluster.datastore.util;
12
13 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
14 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
15 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
16 import com.google.common.collect.ImmutableSet;
17 import java.io.InputStream;
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.HashSet;
21 import java.util.List;
22 import java.util.Map;
23 import java.util.Set;
24 import org.opendaylight.yangtools.yang.common.QName;
25 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
26 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
27 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
28 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
29 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
30 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
31 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
32 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
33 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
34 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
35 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
36 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
37 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
38 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
39 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
40 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
41 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
42 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
43 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
44 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
45 import org.opendaylight.yangtools.yang.model.api.Module;
46 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
47 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
48
49 public class TestModel {
50
51   public static final QName TEST_QNAME = QName.create(
52       "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test",
53       "2014-03-13", "test");
54
55   public static final QName AUG_NAME_QNAME = QName.create(
56       "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
57       "2014-03-13", "name");
58
59   public static final QName AUG_CONT_QNAME = QName.create(
60       "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
61       "2014-03-13", "cont");
62
63
64   public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc");
65   public static final QName POINTER_QNAME = QName.create(TEST_QNAME, "pointer");
66   public static final QName SOME_BINARY_DATE_QNAME = QName.create(TEST_QNAME, "some-binary-data");
67   public static final QName BINARY_LEAF_LIST_QNAME = QName.create(TEST_QNAME, "binary_leaf_list");
68   public static final QName SOME_REF_QNAME = QName.create(TEST_QNAME,
69       "some-ref");
70   public static final QName MYIDENTITY_QNAME = QName.create(TEST_QNAME,
71       "myidentity");
72   public static final QName SWITCH_FEATURES_QNAME = QName.create(TEST_QNAME,
73       "switch-features");
74
75   public static final QName AUGMENTED_LIST_QNAME = QName.create(TEST_QNAME,
76       "augmented-list");
77
78   public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME,
79       "outer-list");
80   public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME,
81       "inner-list");
82   public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME,
83       "outer-choice");
84   public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
85   public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
86   public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
87   private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
88   private static final String DATASTORE_AUG_YANG =
89       "/odl-datastore-augmentation.yang";
90   private static final String DATASTORE_TEST_NOTIFICATION_YANG =
91       "/odl-datastore-test-notification.yang";
92
93
94   public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier
95       .of(TEST_QNAME);
96   public static final YangInstanceIdentifier DESC_PATH = YangInstanceIdentifier
97       .builder(TEST_PATH).node(DESC_QNAME).build();
98   public static final YangInstanceIdentifier OUTER_LIST_PATH =
99       YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
100   public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
101   public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
102
103   private static final Integer ONE_ID = 1;
104   private static final Integer TWO_ID = 2;
105   private static final String TWO_ONE_NAME = "one";
106   private static final String TWO_TWO_NAME = "two";
107   private static final String DESC = "Hello there";
108   private static final Long LONG_ID = 1L;
109   private static final Boolean ENABLED = false;
110   private static final Short SHORT_ID = 1;
111   private static final Byte BYTE_ID = 1;
112   // Family specific constants
113   public static final QName FAMILY_QNAME =
114       QName
115           .create(
116               "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test",
117               "2014-04-17", "family");
118   public static final QName CHILDREN_QNAME = QName.create(FAMILY_QNAME,
119       "children");
120   public static final QName GRAND_CHILDREN_QNAME = QName.create(FAMILY_QNAME,
121       "grand-children");
122   public static final QName CHILD_NUMBER_QNAME = QName.create(FAMILY_QNAME,
123       "child-number");
124   public static final QName CHILD_NAME_QNAME = QName.create(FAMILY_QNAME,
125       "child-name");
126   public static final QName GRAND_CHILD_NUMBER_QNAME = QName.create(
127       FAMILY_QNAME, "grand-child-number");
128   public static final QName GRAND_CHILD_NAME_QNAME = QName.create(FAMILY_QNAME,
129       "grand-child-name");
130
131   public static final YangInstanceIdentifier FAMILY_PATH =
132       YangInstanceIdentifier.of(FAMILY_QNAME);
133   public static final YangInstanceIdentifier FAMILY_DESC_PATH =
134       YangInstanceIdentifier.builder(FAMILY_PATH).node(DESC_QNAME).build();
135   public static final YangInstanceIdentifier CHILDREN_PATH =
136       YangInstanceIdentifier.builder(FAMILY_PATH).node(CHILDREN_QNAME).build();
137
138   private static final Integer FIRST_CHILD_ID = 1;
139   private static final Integer SECOND_CHILD_ID = 2;
140
141   private static final String FIRST_CHILD_NAME = "first child";
142   private static final String SECOND_CHILD_NAME = "second child";
143
144   private static final Integer FIRST_GRAND_CHILD_ID = 1;
145   private static final Integer SECOND_GRAND_CHILD_ID = 2;
146
147   private static final String FIRST_GRAND_CHILD_NAME = "first grand child";
148   private static final String SECOND_GRAND_CHILD_NAME = "second grand child";
149
150
151   // first child
152   private static final YangInstanceIdentifier CHILDREN_1_PATH =
153       YangInstanceIdentifier.builder(CHILDREN_PATH)
154           .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID) //
155           .build();
156   private static final YangInstanceIdentifier CHILDREN_1_NAME_PATH =
157       YangInstanceIdentifier.builder(CHILDREN_PATH)
158           .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, FIRST_CHILD_NAME) //
159           .build();
160
161   private static final YangInstanceIdentifier CHILDREN_2_PATH =
162       YangInstanceIdentifier.builder(CHILDREN_PATH)
163           .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID) //
164           .build();
165   private static final YangInstanceIdentifier CHILDREN_2_NAME_PATH =
166       YangInstanceIdentifier.builder(CHILDREN_PATH)
167           .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, SECOND_CHILD_NAME) //
168           .build();
169
170
171   private static final YangInstanceIdentifier GRAND_CHILD_1_PATH =
172       YangInstanceIdentifier
173           .builder(CHILDREN_1_PATH)
174           .node(GRAND_CHILDREN_QNAME)
175           //
176           .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
177               FIRST_GRAND_CHILD_ID) //
178           .build();
179
180   private static final YangInstanceIdentifier GRAND_CHILD_1_NAME_PATH =
181       YangInstanceIdentifier
182           .builder(CHILDREN_1_PATH)
183           .node(GRAND_CHILDREN_QNAME)
184           //
185           .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME,
186               FIRST_GRAND_CHILD_NAME) //
187           .build();
188
189   private static final YangInstanceIdentifier GRAND_CHILD_2_PATH =
190       YangInstanceIdentifier
191           .builder(CHILDREN_2_PATH)
192           .node(GRAND_CHILDREN_QNAME)
193           //
194           .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
195               SECOND_GRAND_CHILD_ID) //
196           .build();
197
198   private static final YangInstanceIdentifier GRAND_CHILD_2_NAME_PATH =
199       YangInstanceIdentifier
200           .builder(CHILDREN_2_PATH)
201           .node(GRAND_CHILDREN_QNAME)
202           //
203           .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME,
204               SECOND_GRAND_CHILD_NAME) //
205           .build();
206
207   private static final YangInstanceIdentifier DESC_PATH_ID =
208       YangInstanceIdentifier.builder(DESC_PATH).build();
209   private static final YangInstanceIdentifier OUTER_LIST_1_PATH =
210       YangInstanceIdentifier.builder(OUTER_LIST_PATH)
211           .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, ONE_ID) //
212           .build();
213
214   private static final YangInstanceIdentifier OUTER_LIST_2_PATH =
215       YangInstanceIdentifier.builder(OUTER_LIST_PATH)
216           .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
217           .build();
218
219   private static final YangInstanceIdentifier TWO_TWO_PATH =
220       YangInstanceIdentifier.builder(OUTER_LIST_2_PATH).node(INNER_LIST_QNAME) //
221           .nodeWithKey(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME) //
222           .build();
223
224   private static final YangInstanceIdentifier TWO_TWO_VALUE_PATH =
225       YangInstanceIdentifier.builder(TWO_TWO_PATH).node(VALUE_QNAME) //
226           .build();
227
228   private static final MapEntryNode BAR_NODE = mapEntryBuilder(
229       OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
230       .withChild(mapNodeBuilder(INNER_LIST_QNAME) //
231           .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) //
232           .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) //
233           .build()) //
234       .build();
235
236   public static final InputStream getDatastoreTestInputStream() {
237     return getInputStream(DATASTORE_TEST_YANG);
238   }
239
240   public static final InputStream getDatastoreAugInputStream() {
241     return getInputStream(DATASTORE_AUG_YANG);
242   }
243
244   public static final InputStream getDatastoreTestNotificationInputStream() {
245     return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG);
246   }
247
248   private static InputStream getInputStream(final String resourceName) {
249     return TestModel.class.getResourceAsStream(resourceName);
250   }
251
252   public static SchemaContext createTestContext() {
253     List<InputStream> inputStreams = new ArrayList<>();
254     inputStreams.add(getDatastoreTestInputStream());
255     inputStreams.add(getDatastoreAugInputStream());
256     inputStreams.add(getDatastoreTestNotificationInputStream());
257
258     YangParserImpl parser = new YangParserImpl();
259     Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
260     return parser.resolveSchemaContext(modules);
261   }
262
263   /**
264    * Returns a test document
265    * <p/>
266    *
267    * <pre>
268    * test
269    *     outer-list
270    *          id 1
271    *     outer-list
272    *          id 2
273    *          inner-list
274    *                  name "one"
275    *          inner-list
276    *                  name "two"
277    *
278    * </pre>
279    *
280    * @return
281    */
282   public static NormalizedNode<?, ?> createDocumentOne(
283       SchemaContext schemaContext) {
284     return ImmutableContainerNodeBuilder
285         .create()
286         .withNodeIdentifier(
287             new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName()))
288         .withChild(createTestContainer()).build();
289
290   }
291
292   public static DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> createBaseTestContainerBuilder() {
293       // Create a list of shoes
294       // This is to test leaf list entry
295       final LeafSetEntryNode<Object> nike =
296               ImmutableLeafSetEntryNodeBuilder
297                       .create()
298                       .withNodeIdentifier(
299                               new YangInstanceIdentifier.NodeWithValue(QName.create(
300                                       TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
301
302       final LeafSetEntryNode<Object> puma =
303               ImmutableLeafSetEntryNodeBuilder
304                       .create()
305                       .withNodeIdentifier(
306                               new YangInstanceIdentifier.NodeWithValue(QName.create(
307                                       TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
308
309       final LeafSetNode<Object> shoes =
310               ImmutableLeafSetNodeBuilder
311                       .create()
312                       .withNodeIdentifier(
313                               new YangInstanceIdentifier.NodeIdentifier(QName.create(
314                                       TEST_QNAME, "shoe"))).withChild(nike).withChild(puma)
315                       .build();
316
317
318       // Test a leaf-list where each entry contains an identity
319       final LeafSetEntryNode<Object> cap1 =
320               ImmutableLeafSetEntryNodeBuilder
321                       .create()
322                       .withNodeIdentifier(
323                               new YangInstanceIdentifier.NodeWithValue(QName.create(
324                                       TEST_QNAME, "capability"), DESC_QNAME))
325                       .withValue(DESC_QNAME).build();
326
327       final LeafSetNode<Object> capabilities =
328               ImmutableLeafSetNodeBuilder
329                       .create()
330                       .withNodeIdentifier(
331                               new YangInstanceIdentifier.NodeIdentifier(QName.create(
332                                       TEST_QNAME, "capability"))).withChild(cap1).build();
333
334       ContainerNode switchFeatures =
335               ImmutableContainerNodeBuilder
336                       .create()
337                       .withNodeIdentifier(
338                               new YangInstanceIdentifier.NodeIdentifier(SWITCH_FEATURES_QNAME))
339                       .withChild(capabilities).build();
340
341       // Create a leaf list with numbers
342       final LeafSetEntryNode<Object> five =
343               ImmutableLeafSetEntryNodeBuilder
344                       .create()
345                       .withNodeIdentifier(
346                               (new YangInstanceIdentifier.NodeWithValue(QName.create(
347                                       TEST_QNAME, "number"), 5))).withValue(5).build();
348       final LeafSetEntryNode<Object> fifteen =
349               ImmutableLeafSetEntryNodeBuilder
350                       .create()
351                       .withNodeIdentifier(
352                               (new YangInstanceIdentifier.NodeWithValue(QName.create(
353                                       TEST_QNAME, "number"), 15))).withValue(15).build();
354       final LeafSetNode<Object> numbers =
355               ImmutableLeafSetNodeBuilder
356                       .create()
357                       .withNodeIdentifier(
358                               new YangInstanceIdentifier.NodeIdentifier(QName.create(
359                                       TEST_QNAME, "number"))).withChild(five).withChild(fifteen)
360                       .build();
361
362
363       // Create augmentations
364       MapEntryNode mapEntry = createAugmentedListEntry(1, "First Test");
365
366       // Create a bits leaf
367       NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>>
368               myBits = Builders.leafBuilder().withNodeIdentifier(
369               new YangInstanceIdentifier.NodeIdentifier(
370                       QName.create(TEST_QNAME, "my-bits"))).withValue(
371               ImmutableSet.of("foo", "bar"));
372
373       // Create unkey list entry
374       UnkeyedListEntryNode binaryDataKey =
375           Builders.unkeyedListEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).
376               withChild(ImmutableNodes.leafNode(SOME_BINARY_DATE_QNAME, DESC)).build();
377
378       Map<QName, Object> keyValues = new HashMap<>();
379       keyValues.put(CHILDREN_QNAME, FIRST_CHILD_NAME);
380
381
382       // Create the document
383       return ImmutableContainerNodeBuilder
384               .create()
385               .withNodeIdentifier(
386                   new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
387               .withChild(myBits.build())
388               .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC))
389               .withChild(ImmutableNodes.leafNode(POINTER_QNAME, ENABLED))
390               .withChild(ImmutableNodes.leafNode(POINTER_QNAME, SHORT_ID))
391               .withChild(ImmutableNodes.leafNode(POINTER_QNAME, BYTE_ID))
392               .withChild(
393                   ImmutableNodes.leafNode(SOME_REF_QNAME, GRAND_CHILD_1_PATH))
394               .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME))
395                .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(OUTER_LIST_QNAME))
396                    .withChild(binaryDataKey).build())
397                .withChild(Builders.orderedMapBuilder()
398                    .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(mapEntry).build())
399                .withChild(Builders.choiceBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
400                    .withChild(ImmutableNodes.leafNode(DESC_QNAME, LONG_ID)).build())
401                       // .withChild(augmentationNode)
402               .withChild(shoes)
403               .withChild(numbers)
404               .withChild(switchFeatures)
405               .withChild(
406                   mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(mapEntry).build())
407               .withChild(
408                   mapNodeBuilder(OUTER_LIST_QNAME)
409                       .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
410                       .withChild(BAR_NODE).build()
411               );
412   }
413
414   public static ContainerNode createTestContainer() {
415       return createBaseTestContainerBuilder().build();
416   }
417
418   public static MapEntryNode createAugmentedListEntry(int id, String name) {
419
420     Set<QName> childAugmentations = new HashSet<>();
421     childAugmentations.add(AUG_CONT_QNAME);
422
423     ContainerNode augCont =
424         ImmutableContainerNodeBuilder
425             .create()
426             .withNodeIdentifier(
427                 new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME))
428             .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)).build();
429
430
431     final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier =
432         new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
433
434     final AugmentationNode augmentationNode =
435         Builders.augmentationBuilder()
436             .withNodeIdentifier(augmentationIdentifier).withChild(augCont)
437             .build();
438
439     return ImmutableMapEntryNodeBuilder
440         .create()
441         .withNodeIdentifier(
442             new YangInstanceIdentifier.NodeIdentifierWithPredicates(
443                 AUGMENTED_LIST_QNAME, ID_QNAME, id))
444         .withChild(ImmutableNodes.leafNode(ID_QNAME, id))
445         .withChild(augmentationNode).build();
446   }
447
448
449   public static ContainerNode createFamily() {
450     final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> familyContainerBuilder =
451         ImmutableContainerNodeBuilder.create().withNodeIdentifier(
452             new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME));
453
454     final CollectionNodeBuilder<MapEntryNode, MapNode> childrenBuilder =
455         mapNodeBuilder(CHILDREN_QNAME);
456
457     final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> firstChildBuilder =
458         mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID);
459     final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> secondChildBuilder =
460         mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID);
461
462     final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> firstGrandChildBuilder =
463         mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
464             FIRST_GRAND_CHILD_ID);
465     final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> secondGrandChildBuilder =
466         mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
467             SECOND_GRAND_CHILD_ID);
468
469     firstGrandChildBuilder
470         .withChild(
471             ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME,
472                 FIRST_GRAND_CHILD_ID)).withChild(
473             ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME,
474                 FIRST_GRAND_CHILD_NAME));
475
476     secondGrandChildBuilder.withChild(
477         ImmutableNodes
478             .leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID))
479         .withChild(
480             ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME,
481                 SECOND_GRAND_CHILD_NAME));
482
483     firstChildBuilder
484         .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID))
485         .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME))
486         .withChild(
487             mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(
488                 firstGrandChildBuilder.build()).build());
489
490
491     secondChildBuilder
492         .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID))
493         .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME))
494         .withChild(
495             mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(
496                 firstGrandChildBuilder.build()).build());
497
498     childrenBuilder.withChild(firstChildBuilder.build());
499     childrenBuilder.withChild(secondChildBuilder.build());
500
501     return familyContainerBuilder.withChild(childrenBuilder.build()).build();
502   }
503
504 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.