Bump versions 9.0.4-SNAPSHOT
[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 package org.opendaylight.controller.md.cluster.datastore.model;
9
10 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
11
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
18 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
19
20 public final class PeopleModel {
21     public static final QName BASE_QNAME = QName.create(
22             "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people", "2014-03-13", "people");
23
24     public static final QName PEOPLE_QNAME = QName.create(BASE_QNAME, "people");
25     public static final QName PERSON_QNAME = QName.create(PEOPLE_QNAME, "person");
26     public static final QName PERSON_NAME_QNAME = QName.create(PERSON_QNAME, "name");
27     public static final QName PERSON_AGE_QNAME = QName.create(PERSON_QNAME, "age");
28
29     public static final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(BASE_QNAME);
30     public static final YangInstanceIdentifier PERSON_LIST_PATH = BASE_PATH.node(PERSON_QNAME);
31
32     private PeopleModel() {
33         // Hidden on purpose
34     }
35
36     public static ContainerNode create() {
37         return ImmutableNodes.newContainerBuilder()
38             .withNodeIdentifier(new NodeIdentifier(BASE_QNAME))
39             .withChild(ImmutableNodes.newSystemMapBuilder()
40                 .withNodeIdentifier(new NodeIdentifier(PERSON_QNAME))
41                 // Create an entry for the person jack
42                 .withChild(mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jack")
43                     .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jack"))
44                     .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 100L))
45                     .build())
46                 // Create an entry for the person jill
47                 .withChild(mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jill")
48                     .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jill"))
49                     .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 200L))
50                     .build())
51                 .build())
52             .build();
53     }
54
55     public static ContainerNode emptyContainer() {
56         return ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(BASE_QNAME)).build();
57     }
58
59     public static SystemMapNode newPersonMapNode() {
60         return ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(PERSON_QNAME)).build();
61     }
62
63     public static MapEntryNode newPersonEntry(final String name) {
64         return mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, name)
65             .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, name))
66             .build();
67     }
68
69     public static YangInstanceIdentifier newPersonPath(final String name) {
70         return YangInstanceIdentifier.builder(PERSON_LIST_PATH)
71             .nodeWithKey(PERSON_QNAME, PERSON_NAME_QNAME, name)
72             .build();
73     }
74 }