X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Frestconf-nb%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fserver%2Fspi%2FAbstractNormalizedNodeWriterTest.java;fp=restconf%2Frestconf-nb%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fserver%2Fspi%2FAbstractNormalizedNodeWriterTest.java;h=9d55779305e7e4f1ef42cf2dc852e100ac8987a0;hb=9e7c58b162d9c508843e14fc583d001f370eab2f;hp=0000000000000000000000000000000000000000;hpb=70dec274cda4c497e27b610140bc0100940e4ee2;p=netconf.git diff --git a/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/server/spi/AbstractNormalizedNodeWriterTest.java b/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/server/spi/AbstractNormalizedNodeWriterTest.java new file mode 100644 index 0000000000..9d55779305 --- /dev/null +++ b/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/server/spi/AbstractNormalizedNodeWriterTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.restconf.server.spi; + +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode; +import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes; + +abstract class AbstractNormalizedNodeWriterTest { + static final NodeIdentifier CONTAINER_NID = NodeIdentifier.create(QName.create("namespace", "container")); + static final NodeIdentifier KEY_FIELD_NID = NodeIdentifier.create(QName.create("namespace", "key-field")); + static final NodeIdentifier LIST_NID = NodeIdentifier.create(QName.create("namespace", "list")); + static final NodeIdentifier LEAF_SET_NID = NodeIdentifier.create(QName.create("namespace", "leaf-set")); + + // FIXME: make these proper constants + final String leafSetEntryNodeValue = "leaf-set-value"; + final String keyLeafNodeValue = "key-value"; + + final NodeIdentifierWithPredicates mapEntryNodeIdentifier = NodeIdentifierWithPredicates.of( + QName.create("namespace", "list-entry"), KEY_FIELD_NID.getNodeType(), keyLeafNodeValue); + final NodeWithValue leafSetEntryNodeIdentifier = new NodeWithValue<>( + QName.create("namespace", "leaf-set-entry"), leafSetEntryNodeValue); + + final LeafNode keyLeafNodeData = ImmutableNodes.leafNode(KEY_FIELD_NID, keyLeafNodeValue); + final LeafSetEntryNode leafSetEntryNodeData = ImmutableNodes.newLeafSetEntryBuilder() + .withNodeIdentifier(leafSetEntryNodeIdentifier) + .withValue(leafSetEntryNodeValue) + .build(); + final SystemLeafSetNode leafSetNodeData = ImmutableNodes.newSystemLeafSetBuilder() + .withNodeIdentifier(LEAF_SET_NID) + .withChild(leafSetEntryNodeData) + .build(); + final ContainerNode containerNodeData = ImmutableNodes.newContainerBuilder() + .withNodeIdentifier(CONTAINER_NID) + .withChild(leafSetNodeData) + .build(); +}