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

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