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

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