2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.restconf.nb.rfc8040.rests.utils;
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;
25 final class TestData {
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;
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");
56 // FIXME: ${DEITY}, this is fugly. All these are essentially constants for ReadDataTransactionUtilTest!
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")))
66 final LeafNode<Object> content2 = Builders.leafBuilder()
67 .withNodeIdentifier(new NodeIdentifier(QName.create(base, "leaf-content-different")))
68 .withValue("content-different")
70 final DataContainerChild dataContainer = Builders.leafBuilder()
71 .withNodeIdentifier(new NodeIdentifier(QName.create(listQname, "identifier")))
74 data = Builders.mapEntryBuilder()
75 .withNodeIdentifier(nodeWithKey)
78 data2 = Builders.mapEntryBuilder()
79 .withNodeIdentifier(nodeWithKey)
82 checkData = Builders.mapEntryBuilder()
83 .withNodeIdentifier(nodeWithKey)
87 listData = Builders.mapBuilder()
88 .withNodeIdentifier(new NodeIdentifier(QName.create(listQname, "list")))
91 listData2 = Builders.mapBuilder()
92 .withNodeIdentifier(new NodeIdentifier(QName.create(listQname, "list")))
96 path = YangInstanceIdentifier.builder()
97 .node(QName.create(base, "cont"))
101 path2 = YangInstanceIdentifier.builder()
102 .node(QName.create(base, "cont"))
106 path3 = YangInstanceIdentifier.builder()
107 .node(QName.create(base, "cont"))
110 contentLeaf = Builders.leafBuilder()
111 .withNodeIdentifier(new NodeIdentifier(QName.create(base, "content")))
114 contentLeaf2 = Builders.leafBuilder()
115 .withNodeIdentifier(new NodeIdentifier(QName.create(base, "content2")))
118 data3 = Builders.containerBuilder()
119 .withNodeIdentifier(new NodeIdentifier(QName.create(base, "container")))
120 .withChild(contentLeaf)
122 data4 = Builders.containerBuilder()
123 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(base, "container2")))
124 .withChild(contentLeaf2)
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();
132 leafSetNode2 = Builders.<String>leafSetBuilder().withNodeIdentifier(new NodeIdentifier(
133 leafListQname)).withChildValue("three").build();
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();
142 orderedMapNode1 = Builders.orderedMapBuilder()
143 .withNodeIdentifier(new NodeIdentifier(listQname)).withChild(data).build();
145 orderedMapNode2 = Builders.orderedMapBuilder()
146 .withNodeIdentifier(new NodeIdentifier(listQname)).withChild(data)
147 .withChild(data2).build();
149 unkeyedListEntryNode1 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(
150 new NodeIdentifier(listQname)).withChild(content).build();
151 unkeyedListNode1 = Builders.unkeyedListBuilder().withNodeIdentifier(
152 new NodeIdentifier(listQname)).withChild(unkeyedListEntryNode1).build();
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();