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

©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.