import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
import java.net.URI;
import java.time.Clock;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
+import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMActionException;
import org.opendaylight.mdsal.dom.api.DOMActionResult;
import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteOperations;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.common.context.WriterParameters;
import org.opendaylight.restconf.nb.rfc8040.rests.utils.ReadDataTransactionUtil;
import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfDataServiceConstant;
import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfDataServiceConstant.PostPutQueryParameters.Insert;
-import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfInvokeOperationsUtil;
import org.opendaylight.restconf.nb.rfc8040.streams.Configuration;
import org.opendaylight.restconf.nb.rfc8040.streams.listeners.NotificationListenerAdapter;
import org.opendaylight.restconf.nb.rfc8040.utils.mapping.RestconfMappingNodeUtil;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
final DOMActionResult response;
final EffectiveModelContext schemaContextRef;
if (mountPoint != null) {
- response = RestconfInvokeOperationsUtil.invokeAction((ContainerNode) data, schemaPath, yangIIdContext,
- mountPoint);
+ response = invokeAction((ContainerNode) data, schemaPath, yangIIdContext, mountPoint);
schemaContextRef = modelContext(mountPoint);
} else {
- response = RestconfInvokeOperationsUtil.invokeAction((ContainerNode) data, schemaPath, yangIIdContext,
- actionService);
- schemaContextRef = this.schemaContextHandler.get();
+ response = invokeAction((ContainerNode) data, schemaPath, yangIIdContext, actionService);
+ schemaContextRef = schemaContextHandler.get();
}
- final DOMActionResult result = RestconfInvokeOperationsUtil.checkActionResponse(response);
+ final DOMActionResult result = checkActionResponse(response);
ActionDefinition resultNodeSchema = null;
ContainerNode resultData = null;
.build();
}
+
+ /**
+ * Invoking Action via mount point.
+ *
+ * @param mountPoint mount point
+ * @param data input data
+ * @param schemaPath schema path of data
+ * @return {@link DOMActionResult}
+ */
+ private static DOMActionResult invokeAction(final ContainerNode data,
+ final Absolute schemaPath, final YangInstanceIdentifier yangIId, final DOMMountPoint mountPoint) {
+ return invokeAction(data, schemaPath, yangIId, mountPoint.getService(DOMActionService.class)
+ .orElseThrow(() -> new RestconfDocumentedException("DomAction service is missing.")));
+ }
+
+ /**
+ * Invoke Action via ActionServiceHandler.
+ *
+ * @param data input data
+ * @param yangIId invocation context
+ * @param schemaPath schema path of data
+ * @param actionService action service to invoke action
+ * @return {@link DOMActionResult}
+ */
+ // FIXME: NETCONF-718: we should be returning a future here
+ private static DOMActionResult invokeAction(final ContainerNode data, final Absolute schemaPath,
+ final YangInstanceIdentifier yangIId, final DOMActionService actionService) {
+ return RestconfInvokeOperationsServiceImpl.checkedGet(Futures.catching(actionService.invokeAction(
+ schemaPath, new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, yangIId.getParent()), data),
+ DOMActionException.class,
+ cause -> new SimpleDOMActionResult(ImmutableList.of(RpcResultBuilder.newError(
+ RpcError.ErrorType.RPC, "operation-failed", cause.getMessage()))),
+ MoreExecutors.directExecutor()));
+ }
+
+ /**
+ * Check the validity of the result.
+ *
+ * @param response response of Action
+ * @return {@link DOMActionResult} result
+ */
+ private static DOMActionResult checkActionResponse(final DOMActionResult response) {
+ if (response == null) {
+ return null;
+ }
+
+ try {
+ if (response.getErrors().isEmpty()) {
+ return response;
+ }
+ LOG.debug("InvokeAction Error Message {}", response.getErrors());
+ throw new RestconfDocumentedException("InvokeAction Error Message ", null, response.getErrors());
+ } catch (final CancellationException e) {
+ final String errMsg = "The Action Operation was cancelled while executing.";
+ LOG.debug("Cancel Execution: {}", errMsg, e);
+ throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION, e);
+ }
+ }
+
/**
* Valid input data with {@link SchemaNode}.
*
import static java.util.Objects.requireNonNull;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
import java.util.Optional;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
import javax.ws.rs.Path;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMRpcException;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfInvokeOperationsService;
-import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfInvokeOperationsUtil;
import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
+import org.opendaylight.yangtools.yang.common.YangConstants;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Implementation of {@link RestconfInvokeOperationsService}.
*/
@Path("/")
public class RestconfInvokeOperationsServiceImpl implements RestconfInvokeOperationsService {
+ private static final Logger LOG = LoggerFactory.getLogger(RestconfInvokeOperationsServiceImpl.class);
+
+ // FIXME: at some point we do not want to have this here
private static final XMLNamespace SAL_REMOTE_NAMESPACE =
XMLNamespace.of("urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote");
@Override
public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
final UriInfo uriInfo) {
- final EffectiveModelContext refSchemaCtx = this.schemaContextHandler.get();
final QName schemaPath = payload.getInstanceIdentifierContext().getSchemaNode().getQName();
final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint();
final XMLNamespace namespace = payload.getInstanceIdentifierContext().getSchemaNode().getQName().getNamespace();
final DOMRpcResult response;
final EffectiveModelContext schemaContextRef;
if (mountPoint == null) {
+ schemaContextRef = schemaContextHandler.get();
+ // FIXME: this really should be a normal RPC invocation service which has its own interface with JAX-RS
if (SAL_REMOTE_NAMESPACE.equals(namespace)) {
if (identifier.contains(RestconfStreamsConstants.CREATE_DATA_SUBSCRIPTION)) {
- response = CreateStreamUtil.createDataChangeNotifiStream(payload, refSchemaCtx);
+ response = CreateStreamUtil.createDataChangeNotifiStream(payload, schemaContextRef);
} else {
throw new RestconfDocumentedException("Not supported operation", ErrorType.RPC,
ErrorTag.OPERATION_NOT_SUPPORTED);
}
} else {
- response = RestconfInvokeOperationsUtil.invokeRpc(payload.getData(), schemaPath, this.rpcService);
+ response = invokeRpc(payload.getData(), schemaPath, rpcService);
}
- schemaContextRef = this.schemaContextHandler.get();
} else {
- response = RestconfInvokeOperationsUtil.invokeRpc(payload.getData(), schemaPath, mountPoint);
+ response = invokeRpc(payload.getData(), schemaPath, mountPoint);
schemaContextRef = modelContext(mountPoint);
}
- final DOMRpcResult result = RestconfInvokeOperationsUtil.checkResponse(response);
+ final DOMRpcResult result = checkResponse(response);
RpcDefinition resultNodeSchema = null;
NormalizedNode resultData = null;
}
}
+ /**
+ * Invoking rpc via mount point.
+ *
+ * @param mountPoint mount point
+ * @param data input data
+ * @param rpc RPC type
+ * @return {@link DOMRpcResult}
+ */
+ // FIXME: NETCONF-718: we should be returning a future here
+ @VisibleForTesting
+ static DOMRpcResult invokeRpc(final NormalizedNode data, final QName rpc, final DOMMountPoint mountPoint) {
+ return invokeRpc(data, rpc, mountPoint.getService(DOMRpcService.class).orElseThrow(() -> {
+ final String errmsg = "RPC service is missing.";
+ LOG.debug(errmsg);
+ return new RestconfDocumentedException(errmsg);
+ }));
+ }
+
+ /**
+ * Invoke rpc.
+ *
+ * @param data input data
+ * @param rpc RPC type
+ * @param rpcService rpc service to invoke rpc
+ * @return {@link DOMRpcResult}
+ */
+ // FIXME: NETCONF-718: we should be returning a future here
+ @VisibleForTesting
+ static DOMRpcResult invokeRpc(final NormalizedNode data, final QName rpc, final DOMRpcService rpcService) {
+ return checkedGet(Futures.catching(
+ rpcService.invokeRpc(rpc, nonnullInput(rpc, data)), DOMRpcException.class,
+ cause -> new DefaultDOMRpcResult(ImmutableList.of(RpcResultBuilder.newError(
+ RpcError.ErrorType.RPC, "operation-failed", cause.getMessage()))),
+ MoreExecutors.directExecutor()));
+ }
+
+ private static @NonNull NormalizedNode nonnullInput(final QName type, final NormalizedNode input) {
+ return input != null ? input
+ : ImmutableNodes.containerNode(YangConstants.operationInputQName(type.getModule()));
+ }
+
+ /**
+ * Check the validity of the result.
+ *
+ * @param response response of rpc
+ * @return {@link DOMRpcResult} result
+ */
+ @VisibleForTesting
+ static DOMRpcResult checkResponse(final DOMRpcResult response) {
+ if (response == null) {
+ return null;
+ }
+ try {
+ if (response.getErrors().isEmpty()) {
+ return response;
+ }
+ LOG.debug("RpcError message {}", response.getErrors());
+ throw new RestconfDocumentedException("RPCerror message ", null, response.getErrors());
+ } catch (final CancellationException e) {
+ final String errMsg = "The operation was cancelled while executing.";
+ LOG.debug("Cancel RpcExecution: {}", errMsg, e);
+ throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION, e);
+ }
+ }
+
+ @Deprecated
+ static <T> T checkedGet(final ListenableFuture<T> future) {
+ try {
+ return future.get();
+ } catch (InterruptedException e) {
+ throw new RestconfDocumentedException("Interrupted while waiting for result of invocation", e);
+ } catch (ExecutionException e) {
+ Throwables.throwIfInstanceOf(e.getCause(), RestconfDocumentedException.class);
+ throw new RestconfDocumentedException("Invocation failed", e);
+ }
+ }
+
private static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) {
return mountPoint.getService(DOMSchemaService.class)
.flatMap(svc -> Optional.ofNullable(svc.getGlobalContext()))
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.restconf.nb.rfc8040.rests.utils;
-
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableList;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.DOMActionException;
-import org.opendaylight.mdsal.dom.api.DOMActionResult;
-import org.opendaylight.mdsal.dom.api.DOMActionService;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMMountPoint;
-import org.opendaylight.mdsal.dom.api.DOMRpcException;
-import org.opendaylight.mdsal.dom.api.DOMRpcResult;
-import org.opendaylight.mdsal.dom.api.DOMRpcService;
-import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
-import org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult;
-import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.yangtools.yang.common.ErrorTag;
-import org.opendaylight.yangtools.yang.common.ErrorType;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.common.YangConstants;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Util class for rpc.
- */
-public final class RestconfInvokeOperationsUtil {
- private static final Logger LOG = LoggerFactory.getLogger(RestconfInvokeOperationsUtil.class);
-
- private RestconfInvokeOperationsUtil() {
- // Hidden on purpose
- }
-
- /**
- * Invoking rpc via mount point.
- *
- * @param mountPoint mount point
- * @param data input data
- * @param rpc RPC type
- * @return {@link DOMRpcResult}
- */
- // FIXME: NETCONF-718: we should be returning a future here
- public static DOMRpcResult invokeRpc(final NormalizedNode data, final QName rpc, final DOMMountPoint mountPoint) {
- return invokeRpc(data, rpc, mountPoint.getService(DOMRpcService.class).orElseThrow(() -> {
- final String errmsg = "RPC service is missing.";
- LOG.debug(errmsg);
- return new RestconfDocumentedException(errmsg);
- }));
- }
-
- /**
- * Invoke rpc.
- *
- * @param data input data
- * @param rpc RPC type
- * @param rpcService rpc service to invoke rpc
- * @return {@link DOMRpcResult}
- */
- // FIXME: NETCONF-718: we should be returning a future here
- public static DOMRpcResult invokeRpc(final NormalizedNode data, final QName rpc, final DOMRpcService rpcService) {
- return checkedGet(Futures.catching(
- rpcService.invokeRpc(rpc, nonnullInput(rpc, data)), DOMRpcException.class,
- cause -> new DefaultDOMRpcResult(ImmutableList.of(RpcResultBuilder.newError(
- RpcError.ErrorType.RPC, "operation-failed", cause.getMessage()))),
- MoreExecutors.directExecutor()));
- }
-
- private static @NonNull NormalizedNode nonnullInput(final QName type, final NormalizedNode input) {
- return input != null ? input
- : ImmutableNodes.containerNode(YangConstants.operationInputQName(type.getModule()));
- }
-
- /**
- * Check the validity of the result.
- *
- * @param response response of rpc
- * @return {@link DOMRpcResult} result
- */
- public static DOMRpcResult checkResponse(final DOMRpcResult response) {
- if (response == null) {
- return null;
- }
- try {
- if (response.getErrors().isEmpty()) {
- return response;
- }
- LOG.debug("RpcError message {}", response.getErrors());
- throw new RestconfDocumentedException("RPCerror message ", null, response.getErrors());
- } catch (final CancellationException e) {
- final String errMsg = "The operation was cancelled while executing.";
- LOG.debug("Cancel RpcExecution: {}", errMsg, e);
- throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION, e);
- }
- }
-
- /**
- * Invoking Action via mount point.
- *
- * @param mountPoint mount point
- * @param data input data
- * @param schemaPath schema path of data
- * @return {@link DOMActionResult}
- */
- public static DOMActionResult invokeAction(final ContainerNode data,
- final Absolute schemaPath, final YangInstanceIdentifier yangIId, final DOMMountPoint mountPoint) {
- return invokeAction(data, schemaPath, yangIId, mountPoint.getService(DOMActionService.class)
- .orElseThrow(() -> new RestconfDocumentedException("DomAction service is missing.")));
- }
-
- /**
- * Invoke Action via ActionServiceHandler.
- *
- * @param data input data
- * @param yangIId invocation context
- * @param schemaPath schema path of data
- * @param actionService action service to invoke action
- * @return {@link DOMActionResult}
- */
- // FIXME: NETCONF-718: we should be returning a future here
- public static DOMActionResult invokeAction(final ContainerNode data, final Absolute schemaPath,
- final YangInstanceIdentifier yangIId, final DOMActionService actionService) {
- return checkedGet(Futures.catching(actionService.invokeAction(
- schemaPath, new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, yangIId.getParent()), data),
- DOMActionException.class,
- cause -> new SimpleDOMActionResult(ImmutableList.of(RpcResultBuilder.newError(
- RpcError.ErrorType.RPC, "operation-failed", cause.getMessage()))),
- MoreExecutors.directExecutor()));
- }
-
- @Deprecated
- private static <T> T checkedGet(final ListenableFuture<T> future) {
- try {
- return future.get();
- } catch (InterruptedException e) {
- throw new RestconfDocumentedException("Interrupted while waiting for result of invocation", e);
- } catch (ExecutionException e) {
- final Throwable cause = e.getCause();
- Throwables.throwIfInstanceOf(cause, RestconfDocumentedException.class);
- throw new RestconfDocumentedException("Invocation failed", e);
- }
- }
-
- /**
- * Check the validity of the result.
- *
- * @param response
- * response of Action
- * @return {@link DOMActionResult} result
- */
- public static DOMActionResult checkActionResponse(final DOMActionResult response) {
- if (response != null) {
- try {
- if (response.getErrors().isEmpty()) {
- return response;
- }
- LOG.debug("InvokeAction Error Message {}", response.getErrors());
- throw new RestconfDocumentedException("InvokeAction Error Message ", null, response.getErrors());
- } catch (final CancellationException e) {
- final String errMsg = "The Action Operation was cancelled while executing.";
- LOG.debug("Cancel Execution: {}", errMsg, e);
- throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION, e);
- }
- }
- return null;
- }
-}
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
-import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfInvokeOperationsUtil;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
public void invokeRpcTest() {
final DOMRpcResult mockResult = new DefaultDOMRpcResult(OUTPUT, List.of());
doReturn(immediateFluentFuture(mockResult)).when(rpcService).invokeRpc(RPC, INPUT);
- final DOMRpcResult rpcResult = RestconfInvokeOperationsUtil.invokeRpc(INPUT, RPC, rpcService);
+ final DOMRpcResult rpcResult = RestconfInvokeOperationsServiceImpl.invokeRpc(INPUT, RPC, rpcService);
assertTrue(rpcResult.getErrors().isEmpty());
assertEquals(OUTPUT, rpcResult.getResult());
}
final DOMRpcException exception = new DOMRpcImplementationNotAvailableException(
"No implementation of RPC " + errorRpc + " available.");
doReturn(immediateFailedFluentFuture(exception)).when(rpcService).invokeRpc(errorRpc, INPUT);
- final DOMRpcResult rpcResult = RestconfInvokeOperationsUtil.invokeRpc(INPUT, errorRpc, rpcService);
+ final DOMRpcResult rpcResult = RestconfInvokeOperationsServiceImpl.invokeRpc(INPUT, errorRpc, rpcService);
assertNull(rpcResult.getResult());
final Collection<? extends RpcError> errorList = rpcResult.getErrors();
assertEquals(1, errorList.size());
assertEquals("operation-failed", actual.getTag());
assertEquals(RpcError.ErrorType.RPC, actual.getErrorType());
- assertThrows(RestconfDocumentedException.class, () -> RestconfInvokeOperationsUtil.checkResponse(rpcResult));
+ assertThrows(RestconfDocumentedException.class,
+ () -> RestconfInvokeOperationsServiceImpl.checkResponse(rpcResult));
}
@Test
doReturn(Optional.ofNullable(rpcService)).when(mountPoint).getService(DOMRpcService.class);
final DOMRpcResult mockResult = new DefaultDOMRpcResult(OUTPUT, List.of());
doReturn(immediateFluentFuture(mockResult)).when(rpcService).invokeRpc(RPC, INPUT);
- final DOMRpcResult rpcResult = RestconfInvokeOperationsUtil.invokeRpc(INPUT, RPC, mountPoint);
+ final DOMRpcResult rpcResult = RestconfInvokeOperationsServiceImpl.invokeRpc(INPUT, RPC, mountPoint);
assertTrue(rpcResult.getErrors().isEmpty());
assertEquals(OUTPUT, rpcResult.getResult());
}
public void invokeRpcMissingMountPointServiceTest() {
doReturn(Optional.empty()).when(mountPoint).getService(DOMRpcService.class);
assertThrows(RestconfDocumentedException.class,
- () -> RestconfInvokeOperationsUtil.invokeRpc(INPUT, RPC, mountPoint));
+ () -> RestconfInvokeOperationsServiceImpl.invokeRpc(INPUT, RPC, mountPoint));
}
@Test
public void checkResponseTest() {
final DOMRpcResult mockResult = new DefaultDOMRpcResult(OUTPUT, List.of());
doReturn(immediateFluentFuture(mockResult)).when(rpcService).invokeRpc(RPC, INPUT);
- final DOMRpcResult rpcResult = RestconfInvokeOperationsUtil.invokeRpc(INPUT, RPC, rpcService);
+ final DOMRpcResult rpcResult = RestconfInvokeOperationsServiceImpl.invokeRpc(INPUT, RPC, rpcService);
assertTrue(rpcResult.getErrors().isEmpty());
assertEquals(OUTPUT, rpcResult.getResult());
- assertNotNull(RestconfInvokeOperationsUtil.checkResponse(rpcResult));
+ assertNotNull(RestconfInvokeOperationsServiceImpl.checkResponse(rpcResult));
}
private NormalizedNodeContext prepNNC(final NormalizedNode result) {