2 * Copyright (c) 2021 PANTHEON.tech s.r.o. 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.rests.services.impl;
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;
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;
34 @RunWith(MockitoJUnitRunner.StrictStubs.class)
35 public class Netconf799Test extends AbstractInstanceIdentifierTest {
36 private static final QName OUTPUT_QNAME = QName.create(CONT_QNAME, "output");
39 private DOMDataBroker dataBroker;
41 private DOMActionService actionService;
43 private DOMMountPointService mountPointService;
45 private RestconfStreamsSubscriptionService restconfStreamSubService;
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());
53 final var dataService = new RestconfDataServiceImpl(
54 () -> DatabindContext.ofModel(IID_SCHEMA), dataBroker, mountPointService, restconfStreamSubService,
55 actionService, new StreamsConfiguration(0, 1, 0, false));
57 final var response = dataService.postDataJSON("instance-identifier-module:cont/cont1/reset",
60 "instance-identifier-module:input": {
64 assertEquals(204, response.getStatus());
65 assertNull(response.getEntity());