Remove AbstractNormalizedNodeBodyReader
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / impl / Netconf799Test.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech s.r.o. 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.rests.services.impl;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNull;
12 import static org.mockito.ArgumentMatchers.any;
13 import static org.mockito.ArgumentMatchers.eq;
14 import static org.mockito.Mockito.doReturn;
15
16 import com.google.common.util.concurrent.Futures;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.mockito.Mock;
20 import org.mockito.junit.MockitoJUnitRunner;
21 import org.opendaylight.mdsal.dom.api.DOMActionService;
22 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
23 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
24 import org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult;
25 import org.opendaylight.restconf.nb.rfc8040.AbstractInstanceIdentifierTest;
26 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
27 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfStreamsSubscriptionService;
28 import org.opendaylight.restconf.nb.rfc8040.streams.StreamsConfiguration;
29 import org.opendaylight.yangtools.yang.common.QName;
30 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
31 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
32 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
33
34 @RunWith(MockitoJUnitRunner.StrictStubs.class)
35 public class Netconf799Test extends AbstractInstanceIdentifierTest {
36     private static final QName OUTPUT_QNAME = QName.create(CONT_QNAME, "output");
37
38     @Mock
39     private DOMDataBroker dataBroker;
40     @Mock
41     private DOMActionService actionService;
42     @Mock
43     private DOMMountPointService mountPointService;
44     @Mock
45     private RestconfStreamsSubscriptionService restconfStreamSubService;
46
47     @Test
48     public void testInvokeAction() {
49         doReturn(Futures.immediateFuture(new SimpleDOMActionResult(
50             Builders.containerBuilder().withNodeIdentifier(NodeIdentifier.create(OUTPUT_QNAME)).build())))
51             .when(actionService).invokeAction(eq(Absolute.of(CONT_QNAME, CONT1_QNAME, RESET_QNAME)), any(), any());
52
53         final var dataService = new RestconfDataServiceImpl(
54             () -> DatabindContext.ofModel(IID_SCHEMA), dataBroker, mountPointService, restconfStreamSubService,
55             actionService, new StreamsConfiguration(0, 1, 0, false));
56
57         final var response = dataService.postDataJSON("instance-identifier-module:cont/cont1/reset",
58             stringInputStream("""
59             {
60               "instance-identifier-module:input": {
61                 "delay": 600
62               }
63             }"""), null);
64         assertEquals(204, response.getStatus());
65         assertNull(response.getEntity());
66     }
67 }