Integrate MRI projects for Neon
[netconf.git] / restconf / restconf-nb-rfc8040 / src / test / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / impl / JSONRestconfServiceRfc8040ImplTest.java
index b6a81801f3f0c61a29bf65ff749aa7c415c8da29..0fe0e08f84f06b370775a39371f3cb0948b20e53 100644 (file)
@@ -12,16 +12,17 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isNull;
-import static org.mockito.Matchers.notNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.ArgumentMatchers.notNull;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
 import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.io.Resources;
 import com.google.common.util.concurrent.Futures;
 import java.io.FileNotFoundException;
@@ -58,7 +59,7 @@ import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl;
+import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapper;
 import org.opendaylight.yangtools.yang.common.OperationFailedException;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -150,6 +151,8 @@ public class JSONRestconfServiceRfc8040ImplTest {
     public void setup() throws Exception {
         MockitoAnnotations.initMocks(this);
 
+        doReturn(ImmutableClassToInstanceMap.of()).when(domSchemaService).getExtensions();
+
         doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadOnlyTx).read(
                 eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class));
 
@@ -180,12 +183,12 @@ public class JSONRestconfServiceRfc8040ImplTest {
                 DOMMountPointServiceHandler.newInstance(mockMountPointService);
 
         final DOMNotificationService mockNotificationService = mock(DOMNotificationService.class);
-        ServicesWrapperImpl.getInstance().setHandlers(schemaContextHandler, mountPointServiceHandler,
-                txChainHandler, new DOMDataBrokerHandler(mockDOMDataBroker),
-                new RpcServiceHandler(mockRpcService),
-                new NotificationServiceHandler(mockNotificationService), domSchemaService);
+        final ServicesWrapper servicesWrapper = ServicesWrapper.newInstance(schemaContextHandler,
+                mountPointServiceHandler, txChainHandler, new DOMDataBrokerHandler(mockDOMDataBroker),
+                new RpcServiceHandler(mockRpcService), new NotificationServiceHandler(mockNotificationService),
+                domSchemaService);
 
-        service = new JSONRestconfServiceRfc8040Impl(ServicesWrapperImpl.getInstance(), mountPointServiceHandler,
+        service = new JSONRestconfServiceRfc8040Impl(servicesWrapper, mountPointServiceHandler,
                 schemaContextHandler);
     }
 
@@ -491,16 +494,15 @@ public class JSONRestconfServiceRfc8040ImplTest {
         final SchemaPath path = SchemaPath.create(true, CANCEL_TOAST_QNAME);
 
         final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode<?, ?>)null);
-        doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path),
-                any(NormalizedNode.class));
+        doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path), isNull());
 
         final String uriPath = "toaster:cancel-toast";
 
-        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.<String>absent());
+        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.absent());
 
         assertEquals("Output present", false, output.isPresent());
 
-        verify(mockRpcService).invokeRpc(eq(path), isNull(NormalizedNode.class));
+        verify(mockRpcService).invokeRpc(eq(path), isNull());
     }
 
     @Test
@@ -511,18 +513,17 @@ public class JSONRestconfServiceRfc8040ImplTest {
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_OUTPUT_QNAME))
                 .withChild(ImmutableNodes.leafNode(TEXT_OUT_QNAME, "foo")).build();
         final DOMRpcResult expResult = new DefaultDOMRpcResult(outputNode);
-        doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path),
-                any(NormalizedNode.class));
+        doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path), isNull());
 
         final String uriPath = "toaster:testOutput";
 
-        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.<String>absent());
+        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.absent());
 
         assertEquals("Output present", true, output.isPresent());
         assertNotNull("Returned null response", output.get());
         assertThat("Missing \"textOut\"", output.get(), containsString("\"textOut\":\"foo\""));
 
-        verify(mockRpcService).invokeRpc(eq(path), isNull(NormalizedNode.class));
+        verify(mockRpcService).invokeRpc(eq(path), isNull());
     }
 
     @Test(expected = OperationFailedException.class)
@@ -533,7 +534,7 @@ public class JSONRestconfServiceRfc8040ImplTest {
 
         final String uriPath = "toaster:cancel-toast";
 
-        this.service.invokeRpc(uriPath, Optional.<String>absent());
+        this.service.invokeRpc(uriPath, Optional.absent());
     }
 
     void testGet(final LogicalDatastoreType datastoreType) throws OperationFailedException {