70bae6fcb3feb98506a326e2d1b7f946fa83df7e
[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 import com.google.common.collect.ImmutableList;
15 import com.google.common.collect.ImmutableSet;
16 import java.io.InputStream;
17 import java.math.BigDecimal;
18 import java.math.BigInteger;
19 import java.util.ArrayList;
20 import java.util.HashMap;
21 import java.util.HashSet;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Set;
25 import org.opendaylight.yangtools.yang.common.QName;
26 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
27 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
28 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
29 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
30 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
31 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
32 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
33 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
34 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
35 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
36 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
37 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
38 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
39 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
40 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
41 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
42 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
43 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
44 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
45 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
46 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
47 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
48 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
49 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
50 import org.opendaylight.yangtools.yang.model.api.Module;
51 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
52 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
53
54 public class TestModel {
55
56     public static final QName TEST_QNAME = QName.create(
57             "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test",
58             "2014-03-13", "test");
59
60     public static final QName AUG_NAME_QNAME = QName.create(
61             "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
62             "2014-03-13", "name");
63
64     public static final QName AUG_CONT_QNAME = QName.create(
65             "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
66             "2014-03-13", "cont");
67
68
69     public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc");
70     public static final QName POINTER_QNAME = QName.create(TEST_QNAME, "pointer");
71     public static final QName SOME_BINARY_DATA_QNAME = QName.create(TEST_QNAME, "some-binary-data");
72     public static final QName BINARY_LEAF_LIST_QNAME = QName.create(TEST_QNAME, "binary_leaf_list");
73     public static final QName SOME_REF_QNAME = QName.create(TEST_QNAME, "some-ref");
74     public static final QName MYIDENTITY_QNAME = QName.create(TEST_QNAME, "myidentity");
75     public static final QName SWITCH_FEATURES_QNAME = QName.create(TEST_QNAME, "switch-features");
76
77     public static final QName AUGMENTED_LIST_QNAME = QName.create(TEST_QNAME, "augmented-list");
78     public static final QName AUGMENTED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "augmented-list-entry");
79
80     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
81     public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
82     public static final QName INNER_CONTAINER_QNAME = QName.create(TEST_QNAME, "inner-container");
83     public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
84     public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
85     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
86     public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
87     public static final QName BOOLEAN_LEAF_QNAME = QName.create(TEST_QNAME, "boolean-leaf");
88     public static final QName SHORT_LEAF_QNAME = QName.create(TEST_QNAME, "short-leaf");
89     public static final QName BYTE_LEAF_QNAME = QName.create(TEST_QNAME, "byte-leaf");
90     public static final QName BIGINTEGER_LEAF_QNAME = QName.create(TEST_QNAME, "biginteger-leaf");
91     public static final QName BIGDECIMAL_LEAF_QNAME = QName.create(TEST_QNAME, "bigdecimal-leaf");
92     public static final QName ORDERED_LIST_QNAME = QName.create(TEST_QNAME, "ordered-list");
93     public static final QName ORDERED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "ordered-list-leaf");
94     public static final QName UNKEYED_LIST_QNAME = QName.create(TEST_QNAME, "unkeyed-list");
95     public static final QName UNKEYED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "unkeyed-list-entry");
96     public static final QName CHOICE_QNAME = QName.create(TEST_QNAME, "choice");
97     public static final QName SHOE_QNAME = QName.create(TEST_QNAME, "shoe");
98     public static final QName ANY_XML_QNAME = QName.create(TEST_QNAME, "any");
99     public static final QName INVALID_QNAME = QName.create(TEST_QNAME, "invalid");
100     private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
101     private static final String DATASTORE_AUG_YANG = "/odl-datastore-augmentation.yang";
102     private static final String DATASTORE_TEST_NOTIFICATION_YANG = "/odl-datastore-test-notification.yang";
103
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 Long LONG_ID = 1L;
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
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         YangParserImpl parser = new YangParserImpl();
183         Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
184         return parser.resolveSchemaContext(modules);
185     }
186
187     public static SchemaContext createTestContextWithoutTestSchema() {
188         List<InputStream> inputStreams = new ArrayList<>();
189         inputStreams.add(getDatastoreTestNotificationInputStream());
190
191         YangParserImpl parser = new YangParserImpl();
192         Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
193         return parser.resolveSchemaContext(modules);
194     }
195
196
197     public static SchemaContext createTestContextWithoutAugmentationSchema() {
198         List<InputStream> inputStreams = new ArrayList<>();
199         inputStreams.add(getDatastoreTestInputStream());
200         inputStreams.add(getDatastoreTestNotificationInputStream());
201
202         YangParserImpl parser = new YangParserImpl();
203         Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
204         return parser.resolveSchemaContext(modules);
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      * @return
226      */
227     public static NormalizedNode<?, ?> createDocumentOne(
228             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(UNKEYED_LIST_QNAME)).
306                         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()).build())
345                 .withChild(shoes)
346                 .withChild(numbers)
347                 .withChild(switchFeatures)
348                 .withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(augMapEntry).build())
349                 .withChild(mapNodeBuilder(OUTER_LIST_QNAME)
350                                 .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
351                                 .withChild(BAR_NODE).build()
352                 );
353     }
354
355     public static ContainerNode createTestContainer() {
356         return createBaseTestContainerBuilder().build();
357     }
358
359     public static MapEntryNode createAugmentedListEntry(int id, String name) {
360
361         Set<QName> childAugmentations = new HashSet<>();
362         childAugmentations.add(AUG_CONT_QNAME);
363
364         ContainerNode augCont =
365                 ImmutableContainerNodeBuilder
366                         .create()
367                         .withNodeIdentifier(
368                                 new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME))
369                         .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)).build();
370
371
372         final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier =
373                 new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
374
375         final AugmentationNode augmentationNode =
376                 Builders.augmentationBuilder()
377                         .withNodeIdentifier(augmentationIdentifier).withChild(augCont)
378                         .build();
379
380         return ImmutableMapEntryNodeBuilder
381                 .create()
382                 .withNodeIdentifier(
383                         new YangInstanceIdentifier.NodeIdentifierWithPredicates(
384                                 AUGMENTED_LIST_QNAME, ID_QNAME, id))
385                 .withChild(ImmutableNodes.leafNode(ID_QNAME, id))
386                 .withChild(augmentationNode).build();
387     }
388
389
390     public static ContainerNode createFamily() {
391         final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> familyContainerBuilder =
392                 ImmutableContainerNodeBuilder.create().withNodeIdentifier(
393                         new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME));
394
395         final CollectionNodeBuilder<MapEntryNode, MapNode> childrenBuilder =
396                 mapNodeBuilder(CHILDREN_QNAME);
397
398         final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> firstChildBuilder =
399                 mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID);
400         final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> secondChildBuilder =
401                 mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID);
402
403         final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> firstGrandChildBuilder =
404                 mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
405                         FIRST_GRAND_CHILD_ID);
406         final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> secondGrandChildBuilder =
407                 mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
408                         SECOND_GRAND_CHILD_ID);
409
410         firstGrandChildBuilder
411                 .withChild(
412                         ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME,
413                                 FIRST_GRAND_CHILD_ID)).withChild(
414                 ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME,
415                         FIRST_GRAND_CHILD_NAME));
416
417         secondGrandChildBuilder.withChild(
418                 ImmutableNodes
419                         .leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID))
420                 .withChild(
421                         ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME,
422                                 SECOND_GRAND_CHILD_NAME));
423
424         firstChildBuilder
425                 .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID))
426                 .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME))
427                 .withChild(
428                         mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(
429                                 firstGrandChildBuilder.build()).build());
430
431
432         secondChildBuilder
433                 .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID))
434                 .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME))
435                 .withChild(
436                         mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(
437                                 firstGrandChildBuilder.build()).build());
438
439         childrenBuilder.withChild(firstChildBuilder.build());
440         childrenBuilder.withChild(secondChildBuilder.build());
441
442         return familyContainerBuilder.withChild(childrenBuilder.build()).build();
443     }
444
445 }

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