*/
package org.opendaylight.restconf.nb.rfc8040.rests.services.impl;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
-import org.junit.Test;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
-import org.opendaylight.restconf.nb.rfc8040.TestUtils;
-import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
-import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMMountPointService;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class RestconfImplTest {
+@ExtendWith(MockitoExtension.class)
+class RestconfImplTest {
+ @Mock
+ private DOMDataBroker dataBroker;
+ @Mock
+ private DOMRpcService rpcService;
+ @Mock
+ private DOMActionService actionService;
+ @Mock
+ private DOMMountPointService mountPointService;
+
@Test
- public void restImplTest() throws Exception {
- final SchemaContextHandler schemaContextHandler = TestUtils.newSchemaContextHandler(
- YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/impl")));
- final RestconfImpl restconfImpl = new RestconfImpl(schemaContextHandler);
- final NormalizedNodePayload libraryVersion = restconfImpl.getLibraryVersion();
- final LeafNode<?> value = (LeafNode<?>) libraryVersion.getData();
- assertEquals(IetfYangLibrary.REVISION.toString(), value.body());
+ void testLibraryVersion() {
+ final var context = DatabindContext.ofModel(YangParserTestUtils.parseYangResourceDirectory("/restconf/impl"));
+ final var restconfImpl = new RestconfImpl(new MdsalRestconfServer(() -> context, dataBroker, rpcService,
+ actionService, mountPointService));
+ final var libraryVersion = assertInstanceOf(LeafNode.class, restconfImpl.yangLibraryVersionGET().data());
+ assertEquals("2019-01-04", libraryVersion.body());
}
}