9d55779305e7e4f1ef42cf2dc852e100ac8987a0
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / server / spi / AbstractNormalizedNodeWriterTest.java
1 /*
2  * Copyright (c) 2024 PANTHEON.tech, s.r.o. 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.server.spi;
9
10 import org.opendaylight.yangtools.yang.common.QName;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
14 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
18 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
19
20 abstract class AbstractNormalizedNodeWriterTest {
21     static final NodeIdentifier CONTAINER_NID = NodeIdentifier.create(QName.create("namespace", "container"));
22     static final NodeIdentifier KEY_FIELD_NID = NodeIdentifier.create(QName.create("namespace", "key-field"));
23     static final NodeIdentifier LIST_NID = NodeIdentifier.create(QName.create("namespace", "list"));
24     static final NodeIdentifier LEAF_SET_NID = NodeIdentifier.create(QName.create("namespace", "leaf-set"));
25
26     // FIXME: make these proper constants
27     final String leafSetEntryNodeValue = "leaf-set-value";
28     final String keyLeafNodeValue = "key-value";
29
30     final NodeIdentifierWithPredicates mapEntryNodeIdentifier = NodeIdentifierWithPredicates.of(
31         QName.create("namespace", "list-entry"), KEY_FIELD_NID.getNodeType(), keyLeafNodeValue);
32     final NodeWithValue<String> leafSetEntryNodeIdentifier = new NodeWithValue<>(
33         QName.create("namespace", "leaf-set-entry"), leafSetEntryNodeValue);
34
35     final LeafNode<String> keyLeafNodeData = ImmutableNodes.leafNode(KEY_FIELD_NID, keyLeafNodeValue);
36     final LeafSetEntryNode<String> leafSetEntryNodeData = ImmutableNodes.<String>newLeafSetEntryBuilder()
37         .withNodeIdentifier(leafSetEntryNodeIdentifier)
38         .withValue(leafSetEntryNodeValue)
39         .build();
40     final SystemLeafSetNode<String> leafSetNodeData = ImmutableNodes.<String>newSystemLeafSetBuilder()
41         .withNodeIdentifier(LEAF_SET_NID)
42         .withChild(leafSetEntryNodeData)
43         .build();
44     final ContainerNode containerNodeData = ImmutableNodes.newContainerBuilder()
45         .withNodeIdentifier(CONTAINER_NID)
46         .withChild(leafSetNodeData)
47         .build();
48 }