Initial support for multiple-shards
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / md / cluster / datastore / model / PeopleModel.java
1 /*
2  * Copyright (c) 2014 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.md.cluster.datastore.model;
10
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
17 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
18 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
19 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
20
21 public class PeopleModel {
22     public static final QName BASE_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people", "2014-03-13",
23         "people");
24
25     public static final QName PEOPLE_QNAME = QName.create(BASE_QNAME, "people");
26     public static final QName PERSON_QNAME = QName.create(PEOPLE_QNAME, "person");
27     public static final QName PERSON_NAME_QNAME = QName.create(PERSON_QNAME, "name");
28     public static final QName PERSON_AGE_QNAME = QName.create(PERSON_QNAME, "age");
29
30
31     public static NormalizedNode create(){
32
33         // Create a list builder
34         CollectionNodeBuilder<MapEntryNode, MapNode> cars =
35             ImmutableMapNodeBuilder.create().withNodeIdentifier(
36                 new InstanceIdentifier.NodeIdentifier(
37                     QName.create(PEOPLE_QNAME, "person")));
38
39         // Create an entry for the person jack
40         MapEntryNode jack =
41             ImmutableNodes.mapEntryBuilder(PEOPLE_QNAME, PERSON_NAME_QNAME, "jack")
42                 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jack"))
43                 .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 100))
44                 .build();
45
46         // Create an entry for the person jill
47         MapEntryNode jill =
48             ImmutableNodes.mapEntryBuilder(PEOPLE_QNAME, PERSON_NAME_QNAME, "jill")
49                 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jill"))
50                 .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 200))
51                 .build();
52
53         cars.withChild(jack);
54         cars.withChild(jill);
55
56         return ImmutableContainerNodeBuilder.create()
57             .withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(BASE_QNAME))
58             .withChild(cars.build())
59             .build();
60
61     }
62
63     public static NormalizedNode emptyContainer(){
64         return ImmutableContainerNodeBuilder.create()
65             .withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(BASE_QNAME))
66             .build();
67     }
68
69 }