Merge "Fix allowable Unix ports range 1024 - 65535"
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / datastore / util / TestModel.java
1 /*
2  *
3  *  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  *  This program and the accompanying materials are made available under the
6  *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  *  and is available at http://www.eclipse.org/legal/epl-v10.html
8  *
9  */
10
11 package org.opendaylight.controller.cluster.datastore.util;
12
13 import com.google.common.collect.ImmutableSet;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
18 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
19 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
20 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
21 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
22 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
23 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
24 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
25 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
26 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
27 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
28 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
29 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
30 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
31 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
32 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
33 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
34 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
35 import org.opendaylight.yangtools.yang.model.api.Module;
36 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
37 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
38
39 import java.io.InputStream;
40 import java.util.ArrayList;
41 import java.util.HashMap;
42 import java.util.HashSet;
43 import java.util.List;
44 import java.util.Map;
45 import java.util.Set;
46
47 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
48 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
49 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
50
51 public class TestModel {
52
53   public static final QName TEST_QNAME = QName.create(
54       "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test",
55       "2014-03-13", "test");
56
57   public static final QName AUG_NAME_QNAME = QName.create(
58       "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
59       "2014-03-13", "name");
60
61   public static final QName AUG_CONT_QNAME = QName.create(
62       "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
63       "2014-03-13", "cont");
64
65
66   public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc");
67   public static final QName POINTER_QNAME = QName.create(TEST_QNAME, "pointer");
68   public static final QName SOME_BINARY_DATE_QNAME = QName.create(TEST_QNAME, "some-binary-data");
69   public static final QName SOME_REF_QNAME = QName.create(TEST_QNAME,
70       "some-ref");
71   public static final QName MYIDENTITY_QNAME = QName.create(TEST_QNAME,
72       "myidentity");
73   public static final QName SWITCH_FEATURES_QNAME = QName.create(TEST_QNAME,
74       "switch-features");
75
76   public static final QName AUGMENTED_LIST_QNAME = QName.create(TEST_QNAME,
77       "augmented-list");
78
79   public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME,
80       "outer-list");
81   public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME,
82       "inner-list");
83   public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME,
84       "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   private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
89   private static final String DATASTORE_AUG_YANG =
90       "/odl-datastore-augmentation.yang";
91   private static final String DATASTORE_TEST_NOTIFICATION_YANG =
92       "/odl-datastore-test-notification.yang";
93
94
95   public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier
96       .of(TEST_QNAME);
97   public static final YangInstanceIdentifier DESC_PATH = YangInstanceIdentifier
98       .builder(TEST_PATH).node(DESC_QNAME).build();
99   public static final YangInstanceIdentifier OUTER_LIST_PATH =
100       YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
101   public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
102   public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
103
104   private static final Integer ONE_ID = 1;
105   private static final Integer TWO_ID = 2;
106   private static final String TWO_ONE_NAME = "one";
107   private static final String TWO_TWO_NAME = "two";
108   private static final String DESC = "Hello there";
109   private static final Long LONG_ID = 1L;
110   private static final Boolean ENABLED = false;
111   private static final Short SHORT_ID = 1;
112   private static final Byte BYTE_ID = 1;
113   // Family specific constants
114   public static final QName FAMILY_QNAME =
115       QName
116           .create(
117               "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test",
118               "2014-04-17", "family");
119   public static final QName CHILDREN_QNAME = QName.create(FAMILY_QNAME,
120       "children");
121   public static final QName GRAND_CHILDREN_QNAME = QName.create(FAMILY_QNAME,
122       "grand-children");
123   public static final QName CHILD_NUMBER_QNAME = QName.create(FAMILY_QNAME,
124       "child-number");
125   public static final QName CHILD_NAME_QNAME = QName.create(FAMILY_QNAME,
126       "child-name");
127   public static final QName GRAND_CHILD_NUMBER_QNAME = QName.create(
128       FAMILY_QNAME, "grand-child-number");
129   public static final QName GRAND_CHILD_NAME_QNAME = QName.create(FAMILY_QNAME,
130       "grand-child-name");
131
132   public static final YangInstanceIdentifier FAMILY_PATH =
133       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   // first child
153   private static final YangInstanceIdentifier CHILDREN_1_PATH =
154       YangInstanceIdentifier.builder(CHILDREN_PATH)
155           .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID) //
156           .build();
157   private static final YangInstanceIdentifier CHILDREN_1_NAME_PATH =
158       YangInstanceIdentifier.builder(CHILDREN_PATH)
159           .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, FIRST_CHILD_NAME) //
160           .build();
161
162   private static final YangInstanceIdentifier CHILDREN_2_PATH =
163       YangInstanceIdentifier.builder(CHILDREN_PATH)
164           .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID) //
165           .build();
166   private static final YangInstanceIdentifier CHILDREN_2_NAME_PATH =
167       YangInstanceIdentifier.builder(CHILDREN_PATH)
168           .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, SECOND_CHILD_NAME) //
169           .build();
170
171
172   private static final YangInstanceIdentifier GRAND_CHILD_1_PATH =
173       YangInstanceIdentifier
174           .builder(CHILDREN_1_PATH)
175           .node(GRAND_CHILDREN_QNAME)
176           //
177           .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
178               FIRST_GRAND_CHILD_ID) //
179           .build();
180
181   private static final YangInstanceIdentifier GRAND_CHILD_1_NAME_PATH =
182       YangInstanceIdentifier
183           .builder(CHILDREN_1_PATH)
184           .node(GRAND_CHILDREN_QNAME)
185           //
186           .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME,
187               FIRST_GRAND_CHILD_NAME) //
188           .build();
189
190   private static final YangInstanceIdentifier GRAND_CHILD_2_PATH =
191       YangInstanceIdentifier
192           .builder(CHILDREN_2_PATH)
193           .node(GRAND_CHILDREN_QNAME)
194           //
195           .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
196               SECOND_GRAND_CHILD_ID) //
197           .build();
198
199   private static final YangInstanceIdentifier GRAND_CHILD_2_NAME_PATH =
200       YangInstanceIdentifier
201           .builder(CHILDREN_2_PATH)
202           .node(GRAND_CHILDREN_QNAME)
203           //
204           .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME,
205               SECOND_GRAND_CHILD_NAME) //
206           .build();
207
208   private static final YangInstanceIdentifier DESC_PATH_ID =
209       YangInstanceIdentifier.builder(DESC_PATH).build();
210   private static final YangInstanceIdentifier OUTER_LIST_1_PATH =
211       YangInstanceIdentifier.builder(OUTER_LIST_PATH)
212           .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, ONE_ID) //
213           .build();
214
215   private static final YangInstanceIdentifier OUTER_LIST_2_PATH =
216       YangInstanceIdentifier.builder(OUTER_LIST_PATH)
217           .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
218           .build();
219
220   private static final YangInstanceIdentifier TWO_TWO_PATH =
221       YangInstanceIdentifier.builder(OUTER_LIST_2_PATH).node(INNER_LIST_QNAME) //
222           .nodeWithKey(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME) //
223           .build();
224
225   private static final YangInstanceIdentifier TWO_TWO_VALUE_PATH =
226       YangInstanceIdentifier.builder(TWO_TWO_PATH).node(VALUE_QNAME) //
227           .build();
228
229   private static final MapEntryNode BAR_NODE = mapEntryBuilder(
230       OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
231       .withChild(mapNodeBuilder(INNER_LIST_QNAME) //
232           .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) //
233           .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) //
234           .build()) //
235       .build();
236
237   public static final InputStream getDatastoreTestInputStream() {
238     return getInputStream(DATASTORE_TEST_YANG);
239   }
240
241   public static final InputStream getDatastoreAugInputStream() {
242     return getInputStream(DATASTORE_AUG_YANG);
243   }
244
245   public static final InputStream getDatastoreTestNotificationInputStream() {
246     return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG);
247   }
248
249   private static InputStream getInputStream(final String resourceName) {
250     return TestModel.class.getResourceAsStream(resourceName);
251   }
252
253   public static SchemaContext createTestContext() {
254     List<InputStream> inputStreams = new ArrayList<>();
255     inputStreams.add(getDatastoreTestInputStream());
256     inputStreams.add(getDatastoreAugInputStream());
257     inputStreams.add(getDatastoreTestNotificationInputStream());
258
259     YangParserImpl parser = new YangParserImpl();
260     Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
261     return parser.resolveSchemaContext(modules);
262   }
263
264   /**
265    * Returns a test document
266    * <p/>
267    *
268    * <pre>
269    * test
270    *     outer-list
271    *          id 1
272    *     outer-list
273    *          id 2
274    *          inner-list
275    *                  name "one"
276    *          inner-list
277    *                  name "two"
278    *
279    * </pre>
280    *
281    * @return
282    */
283   public static NormalizedNode<?, ?> createDocumentOne(
284       SchemaContext schemaContext) {
285     return ImmutableContainerNodeBuilder
286         .create()
287         .withNodeIdentifier(
288             new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName()))
289         .withChild(createTestContainer()).build();
290
291   }
292
293   public static DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> createBaseTestContainerBuilder() {
294       // Create a list of shoes
295       // This is to test leaf list entry
296       final LeafSetEntryNode<Object> nike =
297               ImmutableLeafSetEntryNodeBuilder
298                       .create()
299                       .withNodeIdentifier(
300                               new YangInstanceIdentifier.NodeWithValue(QName.create(
301                                       TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
302
303       final LeafSetEntryNode<Object> puma =
304               ImmutableLeafSetEntryNodeBuilder
305                       .create()
306                       .withNodeIdentifier(
307                               new YangInstanceIdentifier.NodeWithValue(QName.create(
308                                       TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
309
310       final LeafSetNode<Object> shoes =
311               ImmutableLeafSetNodeBuilder
312                       .create()
313                       .withNodeIdentifier(
314                               new YangInstanceIdentifier.NodeIdentifier(QName.create(
315                                       TEST_QNAME, "shoe"))).withChild(nike).withChild(puma)
316                       .build();
317
318
319       // Test a leaf-list where each entry contains an identity
320       final LeafSetEntryNode<Object> cap1 =
321               ImmutableLeafSetEntryNodeBuilder
322                       .create()
323                       .withNodeIdentifier(
324                               new YangInstanceIdentifier.NodeWithValue(QName.create(
325                                       TEST_QNAME, "capability"), DESC_QNAME))
326                       .withValue(DESC_QNAME).build();
327
328       final LeafSetNode<Object> capabilities =
329               ImmutableLeafSetNodeBuilder
330                       .create()
331                       .withNodeIdentifier(
332                               new YangInstanceIdentifier.NodeIdentifier(QName.create(
333                                       TEST_QNAME, "capability"))).withChild(cap1).build();
334
335       ContainerNode switchFeatures =
336               ImmutableContainerNodeBuilder
337                       .create()
338                       .withNodeIdentifier(
339                               new YangInstanceIdentifier.NodeIdentifier(SWITCH_FEATURES_QNAME))
340                       .withChild(capabilities).build();
341
342       // Create a leaf list with numbers
343       final LeafSetEntryNode<Object> five =
344               ImmutableLeafSetEntryNodeBuilder
345                       .create()
346                       .withNodeIdentifier(
347                               (new YangInstanceIdentifier.NodeWithValue(QName.create(
348                                       TEST_QNAME, "number"), 5))).withValue(5).build();
349       final LeafSetEntryNode<Object> fifteen =
350               ImmutableLeafSetEntryNodeBuilder
351                       .create()
352                       .withNodeIdentifier(
353                               (new YangInstanceIdentifier.NodeWithValue(QName.create(
354                                       TEST_QNAME, "number"), 15))).withValue(15).build();
355       final LeafSetNode<Object> numbers =
356               ImmutableLeafSetNodeBuilder
357                       .create()
358                       .withNodeIdentifier(
359                               new YangInstanceIdentifier.NodeIdentifier(QName.create(
360                                       TEST_QNAME, "number"))).withChild(five).withChild(fifteen)
361                       .build();
362
363
364       // Create augmentations
365       MapEntryNode mapEntry = createAugmentedListEntry(1, "First Test");
366
367       // Create a bits leaf
368       NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>>
369               myBits = Builders.leafBuilder().withNodeIdentifier(
370               new YangInstanceIdentifier.NodeIdentifier(
371                       QName.create(TEST_QNAME, "my-bits"))).withValue(
372               ImmutableSet.of("foo", "bar"));
373
374       // Create unkey list entry
375       UnkeyedListEntryNode binaryDataKey =
376           Builders.unkeyedListEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).
377               withChild(ImmutableNodes.leafNode(SOME_BINARY_DATE_QNAME, DESC)).build();
378
379       Map<QName, Object> keyValues = new HashMap<>();
380       keyValues.put(CHILDREN_QNAME, FIRST_CHILD_NAME);
381
382
383       // Create the document
384       return ImmutableContainerNodeBuilder
385               .create()
386               .withNodeIdentifier(
387                   new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
388               .withChild(myBits.build())
389               .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC))
390               .withChild(ImmutableNodes.leafNode(POINTER_QNAME, ENABLED))
391               .withChild(ImmutableNodes.leafNode(POINTER_QNAME, SHORT_ID))
392               .withChild(ImmutableNodes.leafNode(POINTER_QNAME, BYTE_ID))
393               .withChild(
394                   ImmutableNodes.leafNode(SOME_REF_QNAME, GRAND_CHILD_1_PATH))
395               .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME))
396                .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(OUTER_LIST_QNAME))
397                    .withChild(binaryDataKey).build())
398                .withChild(Builders.orderedMapBuilder()
399                    .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(mapEntry).build())
400                .withChild(Builders.choiceBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
401                    .withChild(ImmutableNodes.leafNode(DESC_QNAME, LONG_ID)).build())
402                       // .withChild(augmentationNode)
403               .withChild(shoes)
404               .withChild(numbers)
405               .withChild(switchFeatures)
406               .withChild(
407                   mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(mapEntry).build())
408               .withChild(
409                   mapNodeBuilder(OUTER_LIST_QNAME)
410                       .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
411                       .withChild(BAR_NODE).build()
412               );
413   }
414
415   public static ContainerNode createTestContainer() {
416       return createBaseTestContainerBuilder().build();
417   }
418
419   public static MapEntryNode createAugmentedListEntry(int id, String name) {
420
421     Set<QName> childAugmentations = new HashSet<>();
422     childAugmentations.add(AUG_CONT_QNAME);
423
424     ContainerNode augCont =
425         ImmutableContainerNodeBuilder
426             .create()
427             .withNodeIdentifier(
428                 new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME))
429             .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)).build();
430
431
432     final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier =
433         new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
434
435     final AugmentationNode augmentationNode =
436         Builders.augmentationBuilder()
437             .withNodeIdentifier(augmentationIdentifier).withChild(augCont)
438             .build();
439
440     return ImmutableMapEntryNodeBuilder
441         .create()
442         .withNodeIdentifier(
443             new YangInstanceIdentifier.NodeIdentifierWithPredicates(
444                 AUGMENTED_LIST_QNAME, ID_QNAME, id))
445         .withChild(ImmutableNodes.leafNode(ID_QNAME, id))
446         .withChild(augmentationNode).build();
447   }
448
449
450   public static ContainerNode createFamily() {
451     final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> familyContainerBuilder =
452         ImmutableContainerNodeBuilder.create().withNodeIdentifier(
453             new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME));
454
455     final CollectionNodeBuilder<MapEntryNode, MapNode> childrenBuilder =
456         mapNodeBuilder(CHILDREN_QNAME);
457
458     final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> firstChildBuilder =
459         mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID);
460     final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> secondChildBuilder =
461         mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID);
462
463     final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> firstGrandChildBuilder =
464         mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
465             FIRST_GRAND_CHILD_ID);
466     final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> secondGrandChildBuilder =
467         mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
468             SECOND_GRAND_CHILD_ID);
469
470     firstGrandChildBuilder
471         .withChild(
472             ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME,
473                 FIRST_GRAND_CHILD_ID)).withChild(
474             ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME,
475                 FIRST_GRAND_CHILD_NAME));
476
477     secondGrandChildBuilder.withChild(
478         ImmutableNodes
479             .leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID))
480         .withChild(
481             ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME,
482                 SECOND_GRAND_CHILD_NAME));
483
484     firstChildBuilder
485         .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID))
486         .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME))
487         .withChild(
488             mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(
489                 firstGrandChildBuilder.build()).build());
490
491
492     secondChildBuilder
493         .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID))
494         .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME))
495         .withChild(
496             mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(
497                 firstGrandChildBuilder.build()).build());
498
499     childrenBuilder.withChild(firstChildBuilder.build());
500     childrenBuilder.withChild(secondChildBuilder.build());
501
502     return familyContainerBuilder.withChild(childrenBuilder.build()).build();
503   }
504
505 }

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