94905d21b18001c332f7fa32c756a08d2d6ddf80
[netconf.git] / restconf / restconf-nb-rfc8040 / src / test / java / org / opendaylight / restconf / nb / rfc8040 / rests / utils / TestData.java
1 /*
2  * Copyright (c) 2016 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.restconf.nb.rfc8040.rests.utils;
9
10 import org.opendaylight.yangtools.yang.common.QName;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
12 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
13 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
14 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
18 import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
19 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
20 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
21 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
22 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
23
24 class TestData {
25
26     final YangInstanceIdentifier path;
27     final YangInstanceIdentifier path2;
28     final YangInstanceIdentifier path3;
29     final MapEntryNode data;
30     final MapEntryNode data2;
31     final ContainerNode data3;
32     final ContainerNode data4;
33     final MapNode listData;
34     final MapNode listData2;
35     final OrderedMapNode orderedMapNode1;
36     final OrderedMapNode orderedMapNode2;
37     final LeafNode contentLeaf;
38     final LeafNode contentLeaf2;
39     final MapEntryNode checkData;
40     final SchemaPath rpc;
41     final SchemaPath errorRpc;
42     final ContainerNode input;
43     final ContainerNode output;
44     final LeafSetNode<String> leafSetNode1;
45     final LeafSetNode<String> leafSetNode2;
46     final LeafSetNode<String> orderedLeafSetNode1;
47     final LeafSetNode<String> orderedLeafSetNode2;
48     final YangInstanceIdentifier leafSetNodePath;
49     final UnkeyedListNode unkeyedListNode1;
50     final UnkeyedListNode unkeyedListNode2;
51     final UnkeyedListEntryNode unkeyedListEntryNode1;
52     final UnkeyedListEntryNode unkeyedListEntryNode2;
53
54     final QName base = QName.create("ns", "2016-02-28", "base");
55     final QName listKeyQName = QName.create(base, "list-key");
56     final QName leafListQname = QName.create(base, "leaf-list");
57     final QName listQname = QName.create(base, "list");
58
59     TestData() {
60         final YangInstanceIdentifier.NodeIdentifierWithPredicates nodeWithKey =
61                 new YangInstanceIdentifier.NodeIdentifierWithPredicates(listQname, listKeyQName, "keyValue");
62         final YangInstanceIdentifier.NodeIdentifierWithPredicates nodeWithKey2 =
63                 new YangInstanceIdentifier.NodeIdentifierWithPredicates(listQname, listKeyQName, "keyValue2");
64         final LeafNode<Object> content = Builders.leafBuilder()
65                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "leaf-content")))
66                 .withValue("content")
67                 .build();
68         final LeafNode<Object> content2 = Builders.leafBuilder()
69                 .withNodeIdentifier(
70                         new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "leaf-content-different")))
71                 .withValue("content-different")
72                 .build();
73         final DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> dataContainer =
74                 Builders.leafBuilder()
75                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "identifier")))
76                 .withValue("id")
77                 .build();
78         data = Builders.mapEntryBuilder()
79                 .withNodeIdentifier(nodeWithKey)
80                 .withChild(content)
81                 .build();
82         data2 = Builders.mapEntryBuilder()
83                 .withNodeIdentifier(nodeWithKey)
84                 .withChild(content2)
85                 .build();
86         checkData = Builders.mapEntryBuilder()
87                 .withNodeIdentifier(nodeWithKey)
88                 .withChild(content2)
89                 .withChild(content)
90                 .build();
91         listData = Builders.mapBuilder()
92                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "list")))
93                 .withChild(data)
94                 .build();
95         listData2 = Builders.mapBuilder()
96                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "list")))
97                 .withChild(data)
98                 .withChild(data2)
99                 .build();
100         path = YangInstanceIdentifier.builder()
101                 .node(QName.create(base, "cont"))
102                 .node(listQname)
103                 .node(nodeWithKey)
104                 .build();
105         path2 = YangInstanceIdentifier.builder()
106                 .node(QName.create(base, "cont"))
107                 .node(listQname)
108                 .node(nodeWithKey2)
109                 .build();
110         path3 = YangInstanceIdentifier.builder()
111                 .node(QName.create(base, "cont"))
112                 .node(listQname)
113                 .build();
114         contentLeaf = Builders.leafBuilder()
115                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "content")))
116                 .withValue("test")
117                 .build();
118         contentLeaf2 = Builders.leafBuilder()
119                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "content2")))
120                 .withValue("test2")
121                 .build();
122         data3 = Builders.containerBuilder()
123                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "container")))
124                 .withChild(contentLeaf)
125                 .build();
126         data4 = Builders.containerBuilder()
127                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "container2")))
128                 .withChild(contentLeaf2)
129                 .build();
130
131         leafSetNodePath = YangInstanceIdentifier.builder().node(QName.create(base, "cont"))
132                 .node(leafListQname).build();
133         leafSetNode1 = Builders.<String>leafSetBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(
134                 leafListQname)).withChildValue("one").withChildValue("two").build();
135
136         leafSetNode2 = Builders.<String>leafSetBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(
137                 leafListQname)).withChildValue("three").build();
138
139         orderedLeafSetNode1 = Builders.<String>orderedLeafSetBuilder().withNodeIdentifier(
140                 new YangInstanceIdentifier.NodeIdentifier(leafListQname)).withChildValue("one")
141                 .withChildValue("two").build();
142         orderedLeafSetNode2 = Builders.<String>orderedLeafSetBuilder().withNodeIdentifier(
143                 new YangInstanceIdentifier.NodeIdentifier(leafListQname)).withChildValue("three")
144                 .withChildValue("four").build();
145
146         orderedMapNode1 = Builders.orderedMapBuilder()
147                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(listQname)).withChild(data).build();
148
149         orderedMapNode2 = Builders.orderedMapBuilder()
150                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(listQname)).withChild(data)
151                 .withChild(data2).build();
152
153         unkeyedListEntryNode1 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(
154                 new YangInstanceIdentifier.NodeIdentifier(listQname)).withChild(content).build();
155         unkeyedListNode1 = Builders.unkeyedListBuilder().withNodeIdentifier(
156                 new YangInstanceIdentifier.NodeIdentifier(listQname)).withChild(unkeyedListEntryNode1).build();
157
158         unkeyedListEntryNode2 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(
159                 new YangInstanceIdentifier.NodeIdentifier(listQname)).withChild(content2).build();
160         unkeyedListNode2 = Builders.unkeyedListBuilder().withNodeIdentifier(
161                 new YangInstanceIdentifier.NodeIdentifier(listQname)).withChild(unkeyedListEntryNode2).build();
162
163         final QName rpcQname = QName.create("ns", "2015-02-28", "test-rpc");
164         final QName errorRpcQname = QName.create(rpcQname, "error-rpc");
165         rpc = SchemaPath.create(true, rpcQname);
166         errorRpc = SchemaPath.create(true, errorRpcQname);
167         final LeafNode contentLeafNode = Builders.leafBuilder()
168                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "content")))
169                 .withValue("test")
170                 .build();
171         input = Builders.containerBuilder()
172                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "input")))
173                 .withChild(contentLeafNode)
174                 .build();
175         final LeafNode resultLeafNode = Builders.leafBuilder()
176                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "content")))
177                 .withValue("operation result")
178                 .build();
179         output = Builders.containerBuilder()
180                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "output")))
181                 .withChild(resultLeafNode)
182                 .build();
183     }
184 }