Move simple QueryParams tests
[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.YangInstanceIdentifier.NodeIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
14 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
16 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
18 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
19 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
20 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
21 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
22 import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
23 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
24
25 final class TestData {
26
27     final YangInstanceIdentifier path;
28     final YangInstanceIdentifier path2;
29     final YangInstanceIdentifier path3;
30     final MapEntryNode data;
31     final MapEntryNode data2;
32     final ContainerNode data3;
33     final ContainerNode data4;
34     final MapNode listData;
35     final MapNode listData2;
36     final UserMapNode orderedMapNode1;
37     final UserMapNode orderedMapNode2;
38     final LeafNode<?> contentLeaf;
39     final LeafNode<?> contentLeaf2;
40     final MapEntryNode checkData;
41     final LeafSetNode<String> leafSetNode1;
42     final LeafSetNode<String> leafSetNode2;
43     final LeafSetNode<String> orderedLeafSetNode1;
44     final LeafSetNode<String> orderedLeafSetNode2;
45     final YangInstanceIdentifier leafSetNodePath;
46     final UnkeyedListNode unkeyedListNode1;
47     final UnkeyedListNode unkeyedListNode2;
48     final UnkeyedListEntryNode unkeyedListEntryNode1;
49     final UnkeyedListEntryNode unkeyedListEntryNode2;
50
51     final QName base = QName.create("ns", "2016-02-28", "base");
52     final QName listKeyQName = QName.create(base, "list-key");
53     final QName leafListQname = QName.create(base, "leaf-list");
54     final QName listQname = QName.create(base, "list");
55
56     // FIXME: ${DEITY}, this is fugly. All these are essentially constants for ReadDataTransactionUtilTest!
57     TestData() {
58         final NodeIdentifierWithPredicates nodeWithKey =
59                 NodeIdentifierWithPredicates.of(listQname, listKeyQName, "keyValue");
60         final NodeIdentifierWithPredicates nodeWithKey2 =
61                 NodeIdentifierWithPredicates.of(listQname, listKeyQName, "keyValue2");
62         final LeafNode<Object> content = Builders.leafBuilder()
63                 .withNodeIdentifier(new NodeIdentifier(QName.create(base, "leaf-content")))
64                 .withValue("content")
65                 .build();
66         final LeafNode<Object> content2 = Builders.leafBuilder()
67                 .withNodeIdentifier(new NodeIdentifier(QName.create(base, "leaf-content-different")))
68                 .withValue("content-different")
69                 .build();
70         final DataContainerChild dataContainer = Builders.leafBuilder()
71                 .withNodeIdentifier(new NodeIdentifier(QName.create(listQname, "identifier")))
72                 .withValue("id")
73                 .build();
74         data = Builders.mapEntryBuilder()
75                 .withNodeIdentifier(nodeWithKey)
76                 .withChild(content)
77                 .build();
78         data2 = Builders.mapEntryBuilder()
79                 .withNodeIdentifier(nodeWithKey)
80                 .withChild(content2)
81                 .build();
82         checkData = Builders.mapEntryBuilder()
83                 .withNodeIdentifier(nodeWithKey)
84                 .withChild(content2)
85                 .withChild(content)
86                 .build();
87         listData = Builders.mapBuilder()
88                 .withNodeIdentifier(new NodeIdentifier(QName.create(listQname, "list")))
89                 .withChild(data)
90                 .build();
91         listData2 = Builders.mapBuilder()
92                 .withNodeIdentifier(new NodeIdentifier(QName.create(listQname, "list")))
93                 .withChild(data)
94                 .withChild(data2)
95                 .build();
96         path = YangInstanceIdentifier.builder()
97                 .node(QName.create(base, "cont"))
98                 .node(listQname)
99                 .node(nodeWithKey)
100                 .build();
101         path2 = YangInstanceIdentifier.builder()
102                 .node(QName.create(base, "cont"))
103                 .node(listQname)
104                 .node(nodeWithKey2)
105                 .build();
106         path3 = YangInstanceIdentifier.builder()
107                 .node(QName.create(base, "cont"))
108                 .node(listQname)
109                 .build();
110         contentLeaf = Builders.leafBuilder()
111                 .withNodeIdentifier(new NodeIdentifier(QName.create(base, "content")))
112                 .withValue("test")
113                 .build();
114         contentLeaf2 = Builders.leafBuilder()
115                 .withNodeIdentifier(new NodeIdentifier(QName.create(base, "content2")))
116                 .withValue("test2")
117                 .build();
118         data3 = Builders.containerBuilder()
119                 .withNodeIdentifier(new NodeIdentifier(QName.create(base, "container")))
120                 .withChild(contentLeaf)
121                 .build();
122         data4 = Builders.containerBuilder()
123                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "container2")))
124                 .withChild(contentLeaf2)
125                 .build();
126
127         leafSetNodePath = YangInstanceIdentifier.builder().node(QName.create(base, "cont"))
128                 .node(leafListQname).build();
129         leafSetNode1 = Builders.<String>leafSetBuilder().withNodeIdentifier(new NodeIdentifier(
130                 leafListQname)).withChildValue("one").withChildValue("two").build();
131
132         leafSetNode2 = Builders.<String>leafSetBuilder().withNodeIdentifier(new NodeIdentifier(
133                 leafListQname)).withChildValue("three").build();
134
135         orderedLeafSetNode1 = Builders.<String>orderedLeafSetBuilder().withNodeIdentifier(
136                 new NodeIdentifier(leafListQname)).withChildValue("one")
137                 .withChildValue("two").build();
138         orderedLeafSetNode2 = Builders.<String>orderedLeafSetBuilder().withNodeIdentifier(
139                 new NodeIdentifier(leafListQname)).withChildValue("three")
140                 .withChildValue("four").build();
141
142         orderedMapNode1 = Builders.orderedMapBuilder()
143                 .withNodeIdentifier(new NodeIdentifier(listQname)).withChild(data).build();
144
145         orderedMapNode2 = Builders.orderedMapBuilder()
146                 .withNodeIdentifier(new NodeIdentifier(listQname)).withChild(data)
147                 .withChild(data2).build();
148
149         unkeyedListEntryNode1 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(
150                 new NodeIdentifier(listQname)).withChild(content).build();
151         unkeyedListNode1 = Builders.unkeyedListBuilder().withNodeIdentifier(
152                 new NodeIdentifier(listQname)).withChild(unkeyedListEntryNode1).build();
153
154         unkeyedListEntryNode2 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(
155                 new YangInstanceIdentifier.NodeIdentifier(listQname)).withChild(content2).build();
156         unkeyedListNode2 = Builders.unkeyedListBuilder().withNodeIdentifier(
157                 new YangInstanceIdentifier.NodeIdentifier(listQname)).withChild(unkeyedListEntryNode2).build();
158     }
159 }