import org.opendaylight.aaa.web.WebContextSecurer;
import org.opendaylight.aaa.web.WebServer;
import org.opendaylight.aaa.web.servlet.ServletSupport;
-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.DOMNotificationService;
-import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.MdsalRestconfServer;
public JaxRsNorthbound(@Reference final WebServer webServer, @Reference final WebContextSecurer webContextSecurer,
@Reference final ServletSupport servletSupport,
@Reference final CustomFilterAdapterConfiguration filterAdapterConfiguration,
- @Reference final DOMActionService actionService, @Reference final DOMDataBroker dataBroker,
- @Reference final DOMMountPointService mountPointService,
- @Reference final DOMNotificationService notificationService, @Reference final DOMRpcService rpcService,
- @Reference final DOMSchemaService schemaService, @Reference final DatabindProvider databindProvider,
- @Reference final MdsalRestconfServer server, @Reference final RestconfStreamServletFactory servletFactory)
- throws ServletException {
+ @Reference final DOMMountPointService mountPointService, @Reference final DOMSchemaService schemaService,
+ @Reference final DatabindProvider databindProvider, @Reference final MdsalRestconfServer server,
+ @Reference final RestconfStreamServletFactory servletFactory) throws ServletException {
final var restconfBuilder = WebContext.builder()
.name("RFC8040 RESTCONF")
.contextPath("/" + URLConstants.BASE_PATH)
.addServlet(ServletDetails.builder()
.addUrlPattern("/*")
.servlet(servletSupport.createHttpServletBuilder(
- new RestconfApplication(databindProvider, server, mountPointService, dataBroker, actionService,
- notificationService, schemaService))
+ new RestconfApplication(databindProvider, server, mountPointService, schemaService))
.build())
.asyncSupported(true)
.build())
import java.util.Set;
import javax.ws.rs.core.Application;
-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.DOMNotificationService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyWriter;
private final Set<Object> singletons;
RestconfApplication(final DatabindProvider databindProvider, final MdsalRestconfServer server,
- final DOMMountPointService mountPointService, final DOMDataBroker dataBroker,
- final DOMActionService actionService, final DOMNotificationService notificationService,
- final DOMSchemaService domSchemaService) {
+ final DOMMountPointService mountPointService, final DOMSchemaService domSchemaService) {
singletons = Set.of(
new RestconfDocumentedExceptionMapper(databindProvider),
- new RestconfDataServiceImpl(databindProvider, server, actionService),
+ new RestconfDataServiceImpl(databindProvider, server),
new RestconfImpl(server),
new RestconfSchemaServiceImpl(domSchemaService, mountPointService));
}
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Maps;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.Comparator;
import java.util.List;
import java.util.Map.Entry;
+import java.util.concurrent.CancellationException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.jdt.annotation.NonNull;
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.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfFuture;
+import org.opendaylight.restconf.common.errors.SettableRestconfFuture;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
import org.opendaylight.restconf.nb.rfc8040.databind.OperationInputBody;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
private final @NonNull DatabindProvider databindProvider;
private final @NonNull DOMDataBroker dataBroker;
private final @Nullable DOMRpcService rpcService;
+ private final @Nullable DOMActionService actionService;
@SuppressWarnings("unused")
private volatile RestconfStrategy localStrategy;
@Activate
public MdsalRestconfServer(@Reference final DatabindProvider databindProvider,
@Reference final DOMDataBroker dataBroker, @Reference final DOMRpcService rpcService,
+ @Reference final DOMActionService actionService,
@Reference final DOMMountPointService mountPointService,
@Reference final List<RpcImplementation> localRpcs) {
this.databindProvider = requireNonNull(databindProvider);
this.dataBroker = requireNonNull(dataBroker);
this.rpcService = requireNonNull(rpcService);
+ this.actionService = requireNonNull(actionService);
this.mountPointService = requireNonNull(mountPointService);
this.localRpcs = Maps.uniqueIndex(localRpcs, RpcImplementation::qname);
}
public MdsalRestconfServer(final DatabindProvider databindProvider, final DOMDataBroker dataBroker,
- final DOMRpcService rpcService, final DOMMountPointService mountPointService,
- final RpcImplementation... localRpcs) {
- this(databindProvider, dataBroker, rpcService, mountPointService, List.of(localRpcs));
+ final DOMRpcService rpcService, final DOMActionService actionService,
+ final DOMMountPointService mountPointService, final RpcImplementation... localRpcs) {
+ this(databindProvider, dataBroker, rpcService, actionService, mountPointService, List.of(localRpcs));
+ }
+
+ RestconfFuture<DOMActionResult> dataInvokePOST(final InstanceIdentifierContext reqPath,
+ final OperationInputBody body) {
+ final var yangIIdContext = reqPath.getInstanceIdentifier();
+ final var inference = reqPath.inference();
+ final ContainerNode input;
+ try {
+ input = body.toContainerNode(inference);
+ } catch (IOException e) {
+ LOG.debug("Error reading input", e);
+ return RestconfFuture.failed(new RestconfDocumentedException("Error parsing input: " + e.getMessage(),
+ ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE, e));
+ }
+
+ final var mountPoint = reqPath.getMountPoint();
+ final var schemaPath = inference.toSchemaInferenceStack().toSchemaNodeIdentifier();
+ return mountPoint != null ? dataInvokePOST(input, schemaPath, yangIIdContext, mountPoint)
+ : dataInvokePOST(input, schemaPath, yangIIdContext, actionService);
+ }
+
+ /**
+ * 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}
+ */
+ private static RestconfFuture<DOMActionResult> dataInvokePOST(final ContainerNode data, final Absolute schemaPath,
+ final YangInstanceIdentifier yangIId, final DOMActionService actionService) {
+ final var ret = new SettableRestconfFuture<DOMActionResult>();
+
+ Futures.addCallback(actionService.invokeAction(schemaPath,
+ new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, yangIId.getParent()), data),
+ new FutureCallback<DOMActionResult>() {
+ @Override
+ public void onSuccess(final DOMActionResult result) {
+ final var errors = result.getErrors();
+ LOG.debug("InvokeAction Error Message {}", errors);
+ if (errors.isEmpty()) {
+ ret.set(result);
+ } else {
+ ret.setFailure(new RestconfDocumentedException("InvokeAction Error Message ", null, errors));
+ }
+ }
+
+ @Override
+ public void onFailure(final Throwable cause) {
+ if (cause instanceof DOMActionException) {
+ ret.set(new SimpleDOMActionResult(List.of(RpcResultBuilder.newError(
+ ErrorType.RPC, ErrorTag.OPERATION_FAILED, cause.getMessage()))));
+ } else if (cause instanceof RestconfDocumentedException e) {
+ ret.setFailure(e);
+ } else if (cause instanceof CancellationException) {
+ ret.setFailure(new RestconfDocumentedException("Action cancelled while executing",
+ ErrorType.RPC, ErrorTag.PARTIAL_OPERATION, cause));
+ } else {
+ ret.setFailure(new RestconfDocumentedException("Invocation failed", cause));
+ }
+ }
+ }, MoreExecutors.directExecutor());
+
+ return ret;
+ }
+
+ /**
+ * Invoking Action via mount point.
+ *
+ * @param mountPoint mount point
+ * @param data input data
+ * @param schemaPath schema path of data
+ * @return {@link DOMActionResult}
+ */
+ private static RestconfFuture<DOMActionResult> dataInvokePOST(final ContainerNode data,
+ final Absolute schemaPath, final YangInstanceIdentifier yangIId, final DOMMountPoint mountPoint) {
+ final var actionService = mountPoint.getService(DOMActionService.class);
+ return actionService.isPresent() ? dataInvokePOST(data, schemaPath, yangIId, actionService.orElseThrow())
+ : RestconfFuture.failed(new RestconfDocumentedException("DOMActionService is missing."));
}
@Override
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.MoreExecutors;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
-import java.util.concurrent.CancellationException;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.Encoded;
import javax.ws.rs.core.UriInfo;
import org.eclipse.jdt.annotation.NonNull;
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.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
-import org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.common.errors.RestconfFuture;
-import org.opendaylight.restconf.common.errors.SettableRestconfFuture;
import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.restconf.common.patch.PatchStatusContext;
import org.opendaylight.restconf.common.patch.PatchStatusEntity;
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.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm:ss");
private final DatabindProvider databindProvider;
- private final DOMActionService actionService;
private final MdsalRestconfServer server;
- public RestconfDataServiceImpl(final DatabindProvider databindProvider, final MdsalRestconfServer server,
- final DOMActionService actionService) {
+ public RestconfDataServiceImpl(final DatabindProvider databindProvider, final MdsalRestconfServer server) {
this.databindProvider = requireNonNull(databindProvider);
this.server = requireNonNull(server);
- this.actionService = requireNonNull(actionService);
}
/**
*/
private void invokeAction(final InstanceIdentifierContext reqPath, final OperationInputBody body,
final AsyncResponse ar) {
- final var yangIIdContext = reqPath.getInstanceIdentifier();
- final ContainerNode input;
- try {
- input = body.toContainerNode(reqPath.inference());
- } catch (IOException e) {
- LOG.debug("Error reading input", e);
- throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL,
- ErrorTag.MALFORMED_MESSAGE, e);
- }
-
- final var mountPoint = reqPath.getMountPoint();
- final var inference = reqPath.inference();
- final var schemaPath = inference.toSchemaInferenceStack().toSchemaNodeIdentifier();
- final var response = mountPoint != null ? invokeAction(input, schemaPath, yangIIdContext, mountPoint)
- : invokeAction(input, schemaPath, yangIIdContext, actionService);
-
- response.addCallback(new JaxRsRestconfCallback<>(ar) {
+ server.dataInvokePOST(reqPath, body).addCallback(new JaxRsRestconfCallback<>(ar) {
@Override
Response transform(final DOMActionResult result) {
final var output = result.getOutput().orElse(null);
return output == null || output.isEmpty() ? Response.status(Status.NO_CONTENT).build()
- : Response.status(Status.OK).entity(new NormalizedNodePayload(inference, output)).build();
+ : Response.status(Status.OK).entity(new NormalizedNodePayload(reqPath.inference(), output)).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 RestconfFuture<DOMActionResult> invokeAction(final ContainerNode data,
- final Absolute schemaPath, final YangInstanceIdentifier yangIId, final DOMMountPoint mountPoint) {
- final var actionService = mountPoint.getService(DOMActionService.class);
- return actionService.isPresent() ? invokeAction(data, schemaPath, yangIId, actionService.orElseThrow())
- : RestconfFuture.failed(new RestconfDocumentedException("DOMActionService 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}
- */
- private static RestconfFuture<DOMActionResult> invokeAction(final ContainerNode data, final Absolute schemaPath,
- final YangInstanceIdentifier yangIId, final DOMActionService actionService) {
- final var ret = new SettableRestconfFuture<DOMActionResult>();
-
- Futures.addCallback(actionService.invokeAction(schemaPath,
- new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, yangIId.getParent()), data),
- new FutureCallback<DOMActionResult>() {
- @Override
- public void onSuccess(final DOMActionResult result) {
- final var errors = result.getErrors();
- LOG.debug("InvokeAction Error Message {}", errors);
- if (errors.isEmpty()) {
- ret.set(result);
- } else {
- ret.setFailure(new RestconfDocumentedException("InvokeAction Error Message ", null, errors));
- }
- }
-
- @Override
- public void onFailure(final Throwable cause) {
- if (cause instanceof DOMActionException) {
- ret.set(new SimpleDOMActionResult(List.of(RpcResultBuilder.newError(
- ErrorType.RPC, ErrorTag.OPERATION_FAILED, cause.getMessage()))));
- } else if (cause instanceof RestconfDocumentedException e) {
- ret.setFailure(e);
- } else if (cause instanceof CancellationException) {
- ret.setFailure(new RestconfDocumentedException("Action cancelled while executing",
- ErrorType.RPC, ErrorTag.PARTIAL_OPERATION, cause));
- } else {
- ret.setFailure(new RestconfDocumentedException("Invocation failed", cause));
- }
- }
- }, MoreExecutors.directExecutor());
-
- return ret;
- }
}
*/
@NonNullByDefault
public interface RestconfServer {
- /**
- * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
- * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
- *
- * @return A {@code yang-library-version} element
- */
- // FIXME: this is a simple coning-variadic return, similar to how OperationsContent is handled use a common
- // construct for both cases
- // FIXME: RestconfFuture if we transition to being used by restconf-client implementation
- NormalizedNodePayload yangLibraryVersionGET();
-
/**
* Return the set of supported RPCs supported by {@link #operationsPOST(URI, String, OperationInputBody)}.
*
// and hence it is a path right now
// FIXME: use ApiPath instead of String
RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, String operation, OperationInputBody body);
+
+ /**
+ * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
+ * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
+ *
+ * @return A {@code yang-library-version} element
+ */
+ // FIXME: this is a simple coning-variadic return, similar to how OperationsContent is handled use a common
+ // construct for both cases
+ // FIXME: RestconfFuture if we transition to being used by restconf-client implementation
+ NormalizedNodePayload yangLibraryVersionGET();
}
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
private NetconfDataTreeService netconfService;
@Mock
private DOMRpcService rpcService;
+ @Mock
+ private DOMActionService actionService;
private MdsalRestconfServer server;
@Before
public void before() {
- server = new MdsalRestconfServer(DATABIND_PROVIDER, dataBroker, rpcService, mountPointService);
+ server = new MdsalRestconfServer(DATABIND_PROVIDER, dataBroker, rpcService, actionService, mountPointService);
doReturn(Optional.of(rpcService)).when(mountPoint).getService(DOMRpcService.class);
}
final DatabindProvider databindProvider = () -> DatabindContext.ofModel(IID_SCHEMA);
final var dataService = new RestconfDataServiceImpl(databindProvider,
- new MdsalRestconfServer(databindProvider, dataBroker, rpcService, mountPointService), actionService);
+ new MdsalRestconfServer(databindProvider, dataBroker, rpcService, actionService, mountPointService));
doReturn(true).when(asyncResponse).resume(captor.capture());
dataService.postDataJSON("instance-identifier-module:cont/cont1/reset",
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;
@Mock
private DOMRpcService rpcService;
@Mock
+ private DOMActionService actionService;
+ @Mock
private DOMMountPointService mountPointService;
private MdsalRestconfServer server;
@BeforeEach
void beforeEach() {
- server = new MdsalRestconfServer(() -> DATABIND, dataBroker, rpcService, mountPointService);
+ server = new MdsalRestconfServer(() -> DATABIND, dataBroker, rpcService, actionService, mountPointService);
}
@Test
final DatabindProvider databindProvider = () -> DatabindContext.ofModel(JUKEBOX_SCHEMA);
dataService = new RestconfDataServiceImpl(databindProvider,
- new MdsalRestconfServer(databindProvider, dataBroker, rpcService, mountPointService), actionService);
+ new MdsalRestconfServer(databindProvider, dataBroker, rpcService, actionService, mountPointService));
doReturn(Optional.of(mountPoint)).when(mountPointService)
.getMountPoint(any(YangInstanceIdentifier.class));
doReturn(Optional.of(FixedDOMSchemaService.of(JUKEBOX_SCHEMA))).when(mountPoint)
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;
@Mock
private DOMRpcService rpcService;
@Mock
+ private DOMActionService actionService;
+ @Mock
private DOMMountPointService mountPointService;
@Test
void testLibraryVersion() {
final var context = DatabindContext.ofModel(YangParserTestUtils.parseYangResourceDirectory("/restconf/impl"));
final var restconfImpl = new RestconfImpl(new MdsalRestconfServer(() -> context, dataBroker, rpcService,
- mountPointService));
+ actionService, mountPointService));
final var libraryVersion = assertInstanceOf(LeafNode.class, restconfImpl.yangLibraryVersionGET().data());
assertEquals("2019-01-04", libraryVersion.body());
}
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.yang.gen.v1.module._1.rev140101.Module1Data;
import org.opendaylight.yang.gen.v1.module._2.rev140102.Module2Data;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@ExtendWith(MockitoExtension.class)
class RestconfOperationsGetTest {
<dummy-rpc2-module2 xmlns="module:2"/>
</operations>""";
- private static final EffectiveModelContext SCHEMA = BindingRuntimeHelpers.createRuntimeContext(
- Module1Data.class, Module2Data.class, NetworkTopology.class).getEffectiveModelContext();
+ private static final DatabindContext DATABIND = DatabindContext.ofModel(BindingRuntimeHelpers.createRuntimeContext(
+ Module1Data.class, Module2Data.class, NetworkTopology.class).getEffectiveModelContext());
@Mock
private DOMMountPointService mountPointService;
private DOMDataBroker dataBroker;
@Mock
private DOMRpcService rpcService;
+ @Mock
+ private DOMActionService actionService;
private RestconfImpl restconf;
@BeforeEach
void beforeEach() {
restconf = new RestconfImpl(
- new MdsalRestconfServer(() -> DatabindContext.ofModel(SCHEMA), dataBroker, rpcService, mountPointService));
+ new MdsalRestconfServer(() -> DATABIND, dataBroker, rpcService, actionService, mountPointService));
}
@Test
}
private void mockMountPoint() {
- doReturn(SCHEMA).when(schemaService).getGlobalContext();
+ doReturn(DATABIND.modelContext()).when(schemaService).getGlobalContext();
doReturn(Optional.of(schemaService)).when(mountPoint).getService(DOMSchemaService.class);
doReturn(Optional.of(mountPoint)).when(mountPointService).getMountPoint(any());
}
import org.mockito.ArgumentCaptor;
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.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
@Mock
private DOMRpcService rpcService;
@Mock
+ private DOMActionService actionService;
+ @Mock
private DOMMountPoint mountPoint;
@Mock
private DOMMountPointService mountPointService;
@BeforeEach
void beforeEach() {
- server = new MdsalRestconfServer(() -> CONTEXT, dataBroker, rpcService, mountPointService);
+ server = new MdsalRestconfServer(() -> CONTEXT, dataBroker, rpcService, actionService, mountPointService);
restconf = new RestconfImpl(server);
}