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;
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;
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));
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);
}
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
.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)
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 {