2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. 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.databind;
10 import static org.junit.Assert.assertEquals;
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;
23 abstract class AbstractOperationInputBodyTest extends AbstractInstanceIdentifierTest {
24 private static final NodeIdentifier INPUT_NID = new NodeIdentifier(QName.create(CONT_QNAME, "input"));
26 private static Inference RESET_INFERENCE;
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();
36 public final void moduleSubContainerDataPostActionTest() throws Exception {
37 final var body = moduleSubContainerDataPostActionBody();
39 assertEquals(Builders.containerBuilder()
40 .withNodeIdentifier(INPUT_NID)
41 .withChild(ImmutableNodes.leafNode(DELAY_QNAME, Uint32.valueOf(600)))
42 .build(), body.toContainerNode(RESET_INFERENCE));
45 abstract OperationInputBody moduleSubContainerDataPostActionBody();
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));
54 abstract OperationInputBody testEmptyBody();