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

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