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

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