Split Restconf implementations (draft02 and RFC) - Prepare modules
[netconf.git] / restconf / restconf-nb-bierman02 / src / test / java / org / opendaylight / restconf / restful / 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.restful.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.MapEntryNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
18 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
19 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
20
21 class TestData {
22
23     final YangInstanceIdentifier path;
24     final YangInstanceIdentifier path2;
25     final YangInstanceIdentifier path3;
26     final MapEntryNode data;
27     final MapEntryNode data2;
28     final ContainerNode data3;
29     final ContainerNode data4;
30     final MapNode listData;
31     final MapNode listData2;
32     final UnkeyedListEntryNode unkeyedListEntryNode;
33     final LeafNode contentLeaf;
34     final LeafNode contentLeaf2;
35     final MapEntryNode checkData;
36     final SchemaPath rpc;
37     final SchemaPath errorRpc;
38     final ContainerNode input;
39     final ContainerNode output;
40
41     TestData() {
42         final QName base = QName.create("ns", "2016-02-28", "base");
43         final QName listQname = QName.create(base, "list");
44         final QName listKeyQName = QName.create(base, "list-key");
45         final YangInstanceIdentifier.NodeIdentifierWithPredicates nodeWithKey =
46                 new YangInstanceIdentifier.NodeIdentifierWithPredicates(listQname, listKeyQName, "keyValue");
47         final YangInstanceIdentifier.NodeIdentifierWithPredicates nodeWithKey2 =
48                 new YangInstanceIdentifier.NodeIdentifierWithPredicates(listQname, listKeyQName, "keyValue2");
49         final LeafNode<Object> content = Builders.leafBuilder()
50                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "leaf-content")))
51                 .withValue("content")
52                 .build();
53         final LeafNode<Object> content2 = Builders.leafBuilder()
54                 .withNodeIdentifier(
55                         new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "leaf-content-different")))
56                 .withValue("content-different")
57                 .build();
58         final DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> dataContainer =
59                 Builders.leafBuilder()
60                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "identifier")))
61                 .withValue("id")
62                 .build();
63         unkeyedListEntryNode = Builders.unkeyedListEntryBuilder()
64                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "list")))
65                 .withChild(dataContainer)
66                 .build();
67         data = Builders.mapEntryBuilder()
68                 .withNodeIdentifier(nodeWithKey)
69                 .withChild(content)
70                 .build();
71         data2 = Builders.mapEntryBuilder()
72                 .withNodeIdentifier(nodeWithKey)
73                 .withChild(content2)
74                 .build();
75         checkData = Builders.mapEntryBuilder()
76                 .withNodeIdentifier(nodeWithKey)
77                 .withChild(content2)
78                 .withChild(content)
79                 .build();
80         listData = Builders.mapBuilder()
81                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "list")))
82                 .withChild(data)
83                 .build();
84         listData2 = Builders.mapBuilder()
85                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "list")))
86                 .withChild(data)
87                 .withChild(data2)
88                 .build();
89         path = YangInstanceIdentifier.builder()
90                 .node(QName.create(base, "cont"))
91                 .node(listQname)
92                 .node(nodeWithKey)
93                 .build();
94         path2 = YangInstanceIdentifier.builder()
95                 .node(QName.create(base, "cont"))
96                 .node(listQname)
97                 .node(nodeWithKey2)
98                 .build();
99         path3 = YangInstanceIdentifier.builder()
100                 .node(QName.create(base, "cont"))
101                 .node(listQname)
102                 .build();
103         contentLeaf = Builders.leafBuilder()
104                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "content")))
105                 .withValue("test")
106                 .build();
107         contentLeaf2 = Builders.leafBuilder()
108                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "content2")))
109                 .withValue("test2")
110                 .build();
111         data3 = Builders.containerBuilder()
112                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "container")))
113                 .withChild(contentLeaf)
114                 .build();
115         data4 = Builders.containerBuilder()
116                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "container2")))
117                 .withChild(contentLeaf2)
118                 .build();
119
120
121         final QName rpcQname = QName.create("ns", "2015-02-28", "test-rpc");
122         final QName errorRpcQname = QName.create(rpcQname, "error-rpc");
123         rpc = SchemaPath.create(true, rpcQname);
124         errorRpc = SchemaPath.create(true, errorRpcQname);
125         final LeafNode contentLeafNode = Builders.leafBuilder()
126                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "content")))
127                 .withValue("test")
128                 .build();
129         input = Builders.containerBuilder()
130                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "input")))
131                 .withChild(contentLeafNode)
132                 .build();
133         final LeafNode resultLeafNode = Builders.leafBuilder()
134                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "content")))
135                 .withValue("operation result")
136                 .build();
137         output = Builders.containerBuilder()
138                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "output")))
139                 .withChild(resultLeafNode)
140                 .build();
141     }
142 }