Move action invocation to MdsalRestconfServer
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / impl / RestconfImplTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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.rests.services.impl;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
12
13 import org.junit.jupiter.api.Test;
14 import org.junit.jupiter.api.extension.ExtendWith;
15 import org.mockito.Mock;
16 import org.mockito.junit.jupiter.MockitoExtension;
17 import org.opendaylight.mdsal.dom.api.DOMActionService;
18 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
19 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
20 import org.opendaylight.mdsal.dom.api.DOMRpcService;
21 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
22 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
23 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
24
25 @ExtendWith(MockitoExtension.class)
26 class RestconfImplTest {
27     @Mock
28     private DOMDataBroker dataBroker;
29     @Mock
30     private DOMRpcService rpcService;
31     @Mock
32     private DOMActionService actionService;
33     @Mock
34     private DOMMountPointService mountPointService;
35
36     @Test
37     void testLibraryVersion() {
38         final var context = DatabindContext.ofModel(YangParserTestUtils.parseYangResourceDirectory("/restconf/impl"));
39         final var restconfImpl = new RestconfImpl(new MdsalRestconfServer(() -> context, dataBroker, rpcService,
40             actionService, mountPointService));
41         final var libraryVersion = assertInstanceOf(LeafNode.class, restconfImpl.yangLibraryVersionGET().data());
42         assertEquals("2019-01-04", libraryVersion.body());
43     }
44 }