Unit test for RestconfInvokeOperationsUtil class
[netconf.git] / restconf / sal-rest-connector / 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(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "leaf-content-different")))
55                 .withValue("content-different")
56                 .build();
57         final DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> dataContainer = Builders.leafBuilder()
58                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "identifier")))
59                 .withValue("id")
60                 .build();
61         unkeyedListEntryNode = Builders.unkeyedListEntryBuilder()
62                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "list")))
63                 .withChild(dataContainer)
64                 .build();
65         data = Builders.mapEntryBuilder()
66                 .withNodeIdentifier(nodeWithKey)
67                 .withChild(content)
68                 .build();
69         data2 = Builders.mapEntryBuilder()
70                 .withNodeIdentifier(nodeWithKey)
71                 .withChild(content2)
72                 .build();
73         checkData = Builders.mapEntryBuilder()
74                 .withNodeIdentifier(nodeWithKey)
75                 .withChild(content2)
76                 .withChild(content)
77                 .build();
78         listData = Builders.mapBuilder()
79                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "list")))
80                 .withChild(data)
81                 .build();
82         listData2 = Builders.mapBuilder()
83                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(listQname, "list")))
84                 .withChild(data)
85                 .withChild(data2)
86                 .build();
87         path = YangInstanceIdentifier.builder()
88                 .node(QName.create(base, "cont"))
89                 .node(listQname)
90                 .node(nodeWithKey)
91                 .build();
92         path2 = YangInstanceIdentifier.builder()
93                 .node(QName.create(base, "cont"))
94                 .node(listQname)
95                 .node(nodeWithKey2)
96                 .build();
97         path3 = YangInstanceIdentifier.builder()
98                 .node(QName.create(base, "cont"))
99                 .node(listQname)
100                 .build();
101         contentLeaf = Builders.leafBuilder()
102                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "content")))
103                 .withValue("test")
104                 .build();
105         contentLeaf2 = Builders.leafBuilder()
106                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "content2")))
107                 .withValue("test2")
108                 .build();
109         data3 = Builders.containerBuilder()
110                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "container")))
111                 .withChild(contentLeaf)
112                 .build();
113         data4 = Builders.containerBuilder()
114                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "container2")))
115                 .withChild(contentLeaf2)
116                 .build();
117
118
119         final QName rpcQname = QName.create("ns", "2015-02-28", "test-rpc");
120         final QName errorRpcQname = QName.create(rpcQname, "error-rpc");
121         rpc = SchemaPath.create(true, rpcQname);
122         errorRpc = SchemaPath.create(true, errorRpcQname);
123         final LeafNode contentLeafNode = Builders.leafBuilder()
124                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "content")))
125                 .withValue("test")
126                 .build();
127         input = Builders.containerBuilder()
128                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "input")))
129                 .withChild(contentLeafNode)
130                 .build();
131         final LeafNode resultLeafNode = Builders.leafBuilder()
132                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "content")))
133                 .withValue("operation result")
134                 .build();
135         output = Builders.containerBuilder()
136                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(rpcQname, "output")))
137                 .withChild(resultLeafNode)
138                 .build();
139     }
140 }