Remove AbstractNormalizedNodeBodyReader
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / databind / AbstractOperationInputBodyTest.java
1 /*
2  * Copyright (c) 2023 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.nb.rfc8040.databind;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.junit.BeforeClass;
13 import org.junit.Test;
14 import org.opendaylight.restconf.nb.rfc8040.AbstractInstanceIdentifierTest;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.Uint32;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
18 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
19 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
20 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
21 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
22
23 abstract class AbstractOperationInputBodyTest extends AbstractInstanceIdentifierTest {
24     private static final NodeIdentifier INPUT_NID = new NodeIdentifier(QName.create(CONT_QNAME, "input"));
25
26     private static Inference RESET_INFERENCE;
27
28     @BeforeClass
29     public static final void setupInference() {
30         final var stack = SchemaInferenceStack.ofDataTreePath(IID_SCHEMA, CONT_QNAME, CONT1_QNAME);
31         stack.enterSchemaTree(RESET_QNAME);
32         RESET_INFERENCE = stack.toInference();
33     }
34
35     @Test
36     public final void moduleSubContainerDataPostActionTest() throws Exception {
37         final var body = moduleSubContainerDataPostActionBody();
38
39         assertEquals(Builders.containerBuilder()
40             .withNodeIdentifier(INPUT_NID)
41             .withChild(ImmutableNodes.leafNode(DELAY_QNAME, Uint32.valueOf(600)))
42             .build(), body.toContainerNode(RESET_INFERENCE));
43     }
44
45     abstract OperationInputBody moduleSubContainerDataPostActionBody();
46
47     @Test
48     public final void testEmpty() throws Exception {
49         final var body = testEmptyBody();
50         assertEquals(Builders.containerBuilder().withNodeIdentifier(INPUT_NID).build(),
51             body.toContainerNode(RESET_INFERENCE));
52     }
53
54     abstract OperationInputBody testEmptyBody();
55 }