From 73a97a3fa5f635ca54803b5969572df8632b6516 Mon Sep 17 00:00:00 2001 From: Jakub Toth Date: Thu, 26 May 2016 10:25:57 +0200 Subject: [PATCH 1/1] Bug 5528 - Handlers *make handlers immutable *DOMMountPointServiceHandler *SchemaContextHandler *TransactionChainHandler *common interface for all handlers *fix dependencies of these changes Change-Id: I4f3a78103036d88a5129f084bd088cd51c5b549c Signed-off-by: Jakub Toth --- .../restconf/RestConnectorProvider.java | 64 +++++++++++++++++-- .../DOMMountPointServiceHandler.java} | 25 +++++--- .../restconf/handlers/Handler.java | 26 ++++++++ .../SchemaContextHandler.java} | 9 +-- .../SchemaContextListenerHandler.java} | 17 +---- .../handlers/TransactionChainHandler.java | 36 +++++++++++ .../api/DOMMountPointServiceHandler.java | 35 ---------- .../impl/Draft11ServicesWrapperImpl.java | 4 +- .../impl/RestconfModulesServiceImpl.java | 15 ++--- .../impl/RestconfOperationsServiceImpl.java | 4 +- .../impl/RestconfSchemaServiceImpl.java | 8 +-- .../impl/RestconfStreamsServiceImpl.java | 4 +- .../rest/RestConnectorProviderTest.java | 18 +++++- .../context/SchemaContextHandlerTest.java | 13 ++-- .../services/RestconfSchemaServiceTest.java | 40 ++++++------ .../services/RestconfStreamsServiceTest.java | 18 +++--- .../validation/RestconfValidationTest.java | 1 + 17 files changed, 211 insertions(+), 126 deletions(-) rename restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/{rest/handlers/impl/DOMMountPointServiceHandlerImpl.java => handlers/DOMMountPointServiceHandler.java} (50%) create mode 100644 restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/Handler.java rename restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/{common/handlers/impl/SchemaContextHandlerImpl.java => handlers/SchemaContextHandler.java} (73%) rename restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/{common/handlers/api/SchemaContextHandler.java => handlers/SchemaContextListenerHandler.java} (56%) create mode 100644 restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/TransactionChainHandler.java delete mode 100644 restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/handlers/api/DOMMountPointServiceHandler.java diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/RestConnectorProvider.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/RestConnectorProvider.java index ce6b2d2ecb..9ed9fbff8c 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/RestConnectorProvider.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/RestConnectorProvider.java @@ -10,18 +10,25 @@ package org.opendaylight.restconf; import com.google.common.base.Preconditions; import java.util.Collection; import java.util.Collections; +import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; +import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; +import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; +import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; import org.opendaylight.controller.sal.core.api.Provider; import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.netconf.sal.rest.api.RestConnector; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; -import org.opendaylight.restconf.common.handlers.impl.SchemaContextHandlerImpl; -import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler; -import org.opendaylight.restconf.rest.handlers.impl.DOMMountPointServiceHandlerImpl; +import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException; +import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.SchemaContextHandler; +import org.opendaylight.restconf.handlers.TransactionChainHandler; import org.opendaylight.restconf.rest.services.impl.Draft11ServicesWrapperImpl; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Provider for restconf draft11. @@ -29,20 +36,60 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; */ public class RestConnectorProvider implements Provider, RestConnector, AutoCloseable { + private static final Logger LOG = LoggerFactory.getLogger(RestConnectorProvider.class); + + private final TransactionChainListener transactionListener = new TransactionChainListener() { + @Override + public void onTransactionChainFailed(final TransactionChain chain, + final AsyncTransaction transaction, final Throwable cause) { + LOG.warn("TransactionChain({}) {} FAILED!", chain, transaction.getIdentifier(), cause); + chain.close(); + resetTransactionChainForAdapaters(chain); + throw new RestconfDocumentedException("TransactionChain(" + chain + ") not committed correctly", cause); + } + + @Override + public void onTransactionChainSuccessful(final TransactionChain chain) { + LOG.trace("TransactionChain({}) {} SUCCESSFUL", chain); + } + }; + private ListenerRegistration listenerRegistration; + private DOMDataBroker dataBroker; + private DOMTransactionChain transactionChain; @Override public void onSessionInitiated(final ProviderSession session) { final SchemaService schemaService = Preconditions.checkNotNull(session.getService(SchemaService.class)); - final DOMMountPointServiceHandler domMountPointServiceHandler = new DOMMountPointServiceHandlerImpl(); - final SchemaContextHandler schemaCtxHandler = new SchemaContextHandlerImpl(); - domMountPointServiceHandler.setDOMMountPointService(session.getService(DOMMountPointService.class)); + final Draft11ServicesWrapperImpl wrapperServices = Draft11ServicesWrapperImpl.getInstance(); + + final SchemaContextHandler schemaCtxHandler = new SchemaContextHandler(); this.listenerRegistration = schemaService.registerSchemaContextListener(schemaCtxHandler); + final DOMMountPointServiceHandler domMountPointServiceHandler = new DOMMountPointServiceHandler( + session.getService(DOMMountPointService.class)); + + this.dataBroker = session.getService(DOMDataBroker.class); + this.transactionChain = this.dataBroker.createTransactionChain(this.transactionListener); + final TransactionChainHandler transactionChainHandler = new TransactionChainHandler(this.transactionChain); + wrapperServices.setHandlers(schemaCtxHandler, domMountPointServiceHandler); } + /** + * After {@link TransactionChain} failed, this is creating new transaction + * with listener. + * + * @param chain + * - old {@link TransactionChain} + */ + private void resetTransactionChainForAdapaters(final TransactionChain chain) { + LOG.trace("Resetting TransactionChain({}) to {}", chain, this.transactionChain); + this.transactionChain = Preconditions.checkNotNull(this.dataBroker) + .createTransactionChain(this.transactionListener); + } + @Override public Collection getProviderFunctionality() { return Collections.emptySet(); @@ -53,5 +100,8 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose if (this.listenerRegistration != null) { this.listenerRegistration.close(); } + if (this.transactionChain != null) { + this.transactionChain.close(); + } } } diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/handlers/impl/DOMMountPointServiceHandlerImpl.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/DOMMountPointServiceHandler.java similarity index 50% rename from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/handlers/impl/DOMMountPointServiceHandlerImpl.java rename to restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/DOMMountPointServiceHandler.java index 9fccaf0f1e..26d109fc3f 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/handlers/impl/DOMMountPointServiceHandlerImpl.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/DOMMountPointServiceHandler.java @@ -5,28 +5,33 @@ * 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.rest.handlers.impl; +package org.opendaylight.restconf.handlers; +import com.google.common.base.Preconditions; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler; /** * Implementation of {@link DOMMountPointServiceHandler} * */ -public class DOMMountPointServiceHandlerImpl implements DOMMountPointServiceHandler { +public class DOMMountPointServiceHandler implements Handler { - private DOMMountPointService domMountPointService; + private final DOMMountPointService domMountPointService; - @Override - public DOMMountPointService getDOMMountPointService() { - return this.domMountPointService; + /** + * Prepare mount point service for Restconf services + * + * @param domMountPointService + * - mount point service + */ + public DOMMountPointServiceHandler(final DOMMountPointService domMountPointService) { + Preconditions.checkNotNull(domMountPointService); + this.domMountPointService = domMountPointService; } @Override - public void setDOMMountPointService(final DOMMountPointService domMountPointService) { - this.domMountPointService = domMountPointService; - + public DOMMountPointService get() { + return this.domMountPointService; } } diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/Handler.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/Handler.java new file mode 100644 index 0000000000..69c2276e13 --- /dev/null +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/Handler.java @@ -0,0 +1,26 @@ +/* + * 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.handlers; + +import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; + +/** + * Handler for handling object prepared by provider for Restconf services + * + * @param + * - specific type go object for handling it + */ +interface Handler { + + /** + * Get prepared object + * + * @return {@link DOMTransactionChain} + */ + T get(); +} diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/common/handlers/impl/SchemaContextHandlerImpl.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/SchemaContextHandler.java similarity index 73% rename from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/common/handlers/impl/SchemaContextHandlerImpl.java rename to restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/SchemaContextHandler.java index 01533425a0..ed55429081 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/common/handlers/impl/SchemaContextHandlerImpl.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/SchemaContextHandler.java @@ -5,27 +5,28 @@ * 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.common.handlers.impl; +package org.opendaylight.restconf.handlers; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; +import com.google.common.base.Preconditions; import org.opendaylight.yangtools.yang.model.api.SchemaContext; /** * Implementation of {@link SchemaContextHandler} * */ -public class SchemaContextHandlerImpl implements SchemaContextHandler { +public class SchemaContextHandler implements SchemaContextListenerHandler { private SchemaContext context; @Override public void onGlobalContextUpdated(final SchemaContext context) { + Preconditions.checkNotNull(context); this.context = null; this.context = context; } @Override - public SchemaContext getSchemaContext() { + public SchemaContext get() { return this.context; } } diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/common/handlers/api/SchemaContextHandler.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/SchemaContextListenerHandler.java similarity index 56% rename from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/common/handlers/api/SchemaContextHandler.java rename to restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/SchemaContextListenerHandler.java index db45a78c58..fa41c98204 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/common/handlers/api/SchemaContextHandler.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/SchemaContextListenerHandler.java @@ -5,24 +5,11 @@ * 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.common.handlers.api; +package org.opendaylight.restconf.handlers; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; -/** - * Handling schema context: - *
    - *
  • Retention - *
  • Update - *
- */ -public interface SchemaContextHandler extends SchemaContextListener { +interface SchemaContextListenerHandler extends Handler, SchemaContextListener { - /** - * Get the {@link SchemaContext}. - * - * @return {@link SchemaContext} - */ - SchemaContext getSchemaContext(); } diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/TransactionChainHandler.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/TransactionChainHandler.java new file mode 100644 index 0000000000..450a8ed2b6 --- /dev/null +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/TransactionChainHandler.java @@ -0,0 +1,36 @@ +/* + * 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.handlers; + +import com.google.common.base.Preconditions; +import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; + + +/** + * Implementation of {@link TransactionChainHandler} + * + */ +public class TransactionChainHandler implements Handler { + + private final DOMTransactionChain transactionChain; + + /** + * Prepare transaction chain service for Restconf services + * + * @param transactionChain + */ + public TransactionChainHandler(final DOMTransactionChain transactionChain) { + Preconditions.checkNotNull(transactionChain); + this.transactionChain = transactionChain; + } + + @Override + public DOMTransactionChain get() { + return this.transactionChain; + } +} diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/handlers/api/DOMMountPointServiceHandler.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/handlers/api/DOMMountPointServiceHandler.java deleted file mode 100644 index b332fd1e3e..0000000000 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/handlers/api/DOMMountPointServiceHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.rest.handlers.api; - -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; - -/** - * Handling dom mount point service: - *
    - *
  • Retention - *
  • Set - *
- */ -public interface DOMMountPointServiceHandler { - - /** - * Get the {@link DOMMountPointService} - * - * @return {@link DOMMountPointService} - */ - DOMMountPointService getDOMMountPointService(); - - /** - * Set {@link DOMMountPointService} - * - * @param domMountPointService - * - {@link DOMMountPointService} - */ - void setDOMMountPointService(DOMMountPointService domMountPointService); -} diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/Draft11ServicesWrapperImpl.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/Draft11ServicesWrapperImpl.java index dba808b66a..39acd298bc 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/Draft11ServicesWrapperImpl.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/Draft11ServicesWrapperImpl.java @@ -10,8 +10,8 @@ package org.opendaylight.restconf.rest.services.impl; import javax.ws.rs.core.UriInfo; import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext; import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; -import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.SchemaContextHandler; import org.opendaylight.restconf.rest.services.api.Draft11ServicesWrapper; import org.opendaylight.restconf.rest.services.api.RestconfModulesService; import org.opendaylight.restconf.rest.services.api.RestconfOperationsService; diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceImpl.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceImpl.java index c526195853..afefd6d457 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceImpl.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceImpl.java @@ -19,9 +19,9 @@ import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException; import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag; import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType; import org.opendaylight.restconf.Draft11; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; import org.opendaylight.restconf.common.references.SchemaContextRef; -import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.SchemaContextHandler; import org.opendaylight.restconf.rest.services.api.RestconfModulesService; import org.opendaylight.restconf.utils.RestconfConstants; import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeUtil; @@ -66,7 +66,7 @@ public class RestconfModulesServiceImpl implements RestconfModulesService { @Override public NormalizedNodeContext getModules(final UriInfo uriInfo) { - final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.getSchemaContext()); + final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get()); return getModules(schemaContextRef.getModules(), schemaContextRef, null); } @@ -79,10 +79,10 @@ public class RestconfModulesServiceImpl implements RestconfModulesService { LOG.debug(errMsg + " for " + identifier); throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); } - final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.getSchemaContext()); + final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get()); final InstanceIdentifierContext mountPointIdentifier = ParserIdentifier.toInstanceIdentifier(identifier, schemaContextRef.get()); - final DOMMountPointService domMointPointService = this.domMountPointServiceHandler.getDOMMountPointService(); + final DOMMountPointService domMointPointService = this.domMountPointServiceHandler.get(); final DOMMountPoint mountPoint = domMointPointService .getMountPoint(mountPointIdentifier.getInstanceIdentifier()).get(); return getModules(mountPoint.getSchemaContext().getModules(), schemaContextRef, mountPoint); @@ -92,15 +92,14 @@ public class RestconfModulesServiceImpl implements RestconfModulesService { @Override public NormalizedNodeContext getModule(final String identifier, final UriInfo uriInfo) { Preconditions.checkNotNull(identifier); - final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.getSchemaContext()); + final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get()); final QName moduleQname = ParserIdentifier.makeQNameFromIdentifier(identifier); Module module = null; DOMMountPoint mountPoint = null; if (identifier.contains(RestconfConstants.MOUNT)) { final InstanceIdentifierContext point = ParserIdentifier.toInstanceIdentifier(identifier, schemaContextRef.get()); - final DOMMountPointService domMointPointService = this.domMountPointServiceHandler - .getDOMMountPointService(); + final DOMMountPointService domMointPointService = this.domMountPointServiceHandler.get(); mountPoint = domMointPointService.getMountPoint(point.getInstanceIdentifier()).get(); module = schemaContextRef.findModuleInMountPointByQName(mountPoint, moduleQname); } else { diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfOperationsServiceImpl.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfOperationsServiceImpl.java index f269e9a0cb..fec4c3f659 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfOperationsServiceImpl.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfOperationsServiceImpl.java @@ -10,8 +10,8 @@ package org.opendaylight.restconf.rest.services.impl; import javax.ws.rs.core.UriInfo; import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext; import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; -import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.SchemaContextHandler; import org.opendaylight.restconf.rest.services.api.RestconfOperationsService; import org.opendaylight.yangtools.yang.model.api.SchemaContext; diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfSchemaServiceImpl.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfSchemaServiceImpl.java index f5682d7b77..6313244561 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfSchemaServiceImpl.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfSchemaServiceImpl.java @@ -8,9 +8,9 @@ package org.opendaylight.restconf.rest.services.impl; import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; import org.opendaylight.restconf.common.references.SchemaContextRef; -import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.SchemaContextHandler; import org.opendaylight.restconf.rest.services.api.RestconfSchemaService; import org.opendaylight.restconf.utils.parser.ParserIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -41,8 +41,8 @@ public class RestconfSchemaServiceImpl implements RestconfSchemaService { @Override public SchemaExportContext getSchema(final String identifier) { - final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.getSchemaContext()); + final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get()); return ParserIdentifier.toSchemaExportContextFromIdentifier(schemaContextRef.get(), identifier, - this.domMountPointServiceHandler.getDOMMountPointService()); + this.domMountPointServiceHandler.get()); } } diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfStreamsServiceImpl.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfStreamsServiceImpl.java index 1fb85aae8c..1346e50142 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfStreamsServiceImpl.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfStreamsServiceImpl.java @@ -14,8 +14,8 @@ import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext; import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext; import org.opendaylight.netconf.sal.streams.listeners.Notificator; import org.opendaylight.restconf.Draft11; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; import org.opendaylight.restconf.common.references.SchemaContextRef; +import org.opendaylight.restconf.handlers.SchemaContextHandler; import org.opendaylight.restconf.rest.services.api.RestconfStreamsService; import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeUtil; import org.opendaylight.restconf.utils.schema.context.RestconfSchemaUtil; @@ -52,7 +52,7 @@ public class RestconfStreamsServiceImpl implements RestconfStreamsService { @Override public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) { - final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.getSchemaContext()); + final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get()); final Set availableStreams = Notificator.getStreamNames(); final DataSchemaNode streamListSchemaNode = RestconfSchemaUtil.getRestconfSchemaNode( diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/RestConnectorProviderTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/RestConnectorProviderTest.java index d2ce0adefa..623e2c8bd0 100644 --- a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/RestConnectorProviderTest.java +++ b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/RestConnectorProviderTest.java @@ -19,11 +19,13 @@ import org.junit.rules.ExpectedException; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; +import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.restconf.RestConnectorProvider; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; +import org.opendaylight.restconf.handlers.SchemaContextHandler; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; @@ -68,6 +70,10 @@ public class RestConnectorProviderTest { // prepare conditions when(this.mockSession.getService(SchemaService.class)).thenReturn(this.mockSchemaService); when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(this.mockMountPointService); + final DOMDataBroker mockDataBroker = Mockito.mock(DOMDataBroker.class); + when(this.mockSession.getService(DOMDataBroker.class)).thenReturn(mockDataBroker); + final DOMTransactionChain mockTransactionChain = Mockito.mock(DOMTransactionChain.class); + when(mockDataBroker.createTransactionChain(Mockito.any())).thenReturn(mockTransactionChain); // test this.connectorProvider.onSessionInitiated(this.mockSession); @@ -90,6 +96,12 @@ public class RestConnectorProviderTest { // prepare conditions when(this.mockSession.getService(SchemaService.class)).thenReturn(this.mockSchemaService); when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(null); + final DOMDataBroker mockDataBroker = Mockito.mock(DOMDataBroker.class); + when(this.mockSession.getService(DOMDataBroker.class)).thenReturn(mockDataBroker); + final DOMTransactionChain mockTransactionChain = Mockito.mock(DOMTransactionChain.class); + when(mockDataBroker.createTransactionChain(Mockito.any())).thenReturn(mockTransactionChain); + final DOMMountPointService mockDomMountPoint = Mockito.mock(DOMMountPointService.class); + when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(mockDomMountPoint); // test this.connectorProvider.onSessionInitiated(this.mockSession); @@ -146,6 +158,10 @@ public class RestConnectorProviderTest { when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(this.mockMountPointService); when(this.mockSchemaService.registerSchemaContextListener(Mockito.any(SchemaContextHandler.class))) .thenReturn(this.mockRegistration); + final DOMDataBroker mockDataBroker = Mockito.mock(DOMDataBroker.class); + when(this.mockSession.getService(DOMDataBroker.class)).thenReturn(mockDataBroker); + final DOMTransactionChain mockTransactionChain = Mockito.mock(DOMTransactionChain.class); + when(mockDataBroker.createTransactionChain(Mockito.any())).thenReturn(mockTransactionChain); // register this.connectorProvider.onSessionInitiated(this.mockSession); diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/schema/context/SchemaContextHandlerTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/schema/context/SchemaContextHandlerTest.java index 78d84abd8e..6107d67d1e 100644 --- a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/schema/context/SchemaContextHandlerTest.java +++ b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/schema/context/SchemaContextHandlerTest.java @@ -13,8 +13,7 @@ import static org.junit.Assert.assertNotNull; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; -import org.opendaylight.restconf.common.handlers.impl.SchemaContextHandlerImpl; +import org.opendaylight.restconf.handlers.SchemaContextHandler; import org.opendaylight.yangtools.yang.model.api.SchemaContext; /** @@ -30,14 +29,14 @@ public class SchemaContextHandlerTest { @Before public void setup() throws Exception { - this.schemaContextHandler = new SchemaContextHandlerImpl(); + this.schemaContextHandler = new SchemaContextHandler(); this.schemaContext = TestRestconfUtils.loadSchemaContext(PATH_FOR_ACTUAL_SCHEMA_CONTEXT); this.schemaContextHandler.onGlobalContextUpdated(this.schemaContext); } /** - * Testing init of {@link SchemaContextHandlerImpl} + * Testing init of {@link SchemaContextHandler} */ @Test public void schemaContextHandlerImplInitTest() { @@ -53,7 +52,7 @@ public class SchemaContextHandlerTest { @Test public void getSchemaContextTest() { assertEquals("SchemaContextHandler should has reference to actual SchemaContext", - this.schemaContext, this.schemaContextHandler.getSchemaContext()); + this.schemaContext, this.schemaContextHandler.get()); } /** @@ -69,8 +68,8 @@ public class SchemaContextHandlerTest { this.schemaContextHandler.onGlobalContextUpdated(newSchemaContext); assertNotEquals("SchemaContextHandler should not has reference to old SchemaContext", - this.schemaContext, this.schemaContextHandler.getSchemaContext()); + this.schemaContext, this.schemaContextHandler.get()); assertEquals("SchemaContextHandler should has reference to new SchemaContext", - newSchemaContext, this.schemaContextHandler.getSchemaContext()); + newSchemaContext, this.schemaContextHandler.get()); } } diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/services/RestconfSchemaServiceTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/services/RestconfSchemaServiceTest.java index 2ffb5a0ff4..712e89f83a 100644 --- a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/services/RestconfSchemaServiceTest.java +++ b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/services/RestconfSchemaServiceTest.java @@ -29,8 +29,8 @@ import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext; import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException; import org.opendaylight.netconf.sal.restconf.impl.RestconfError; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; -import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler; +import org.opendaylight.restconf.handlers.SchemaContextHandler; import org.opendaylight.restconf.rest.services.api.RestconfSchemaService; import org.opendaylight.restconf.rest.services.impl.RestconfSchemaServiceImpl; import org.opendaylight.restconf.utils.RestconfConstants; @@ -99,7 +99,7 @@ public class RestconfSchemaServiceTest { this.mountPointService = new DOMMountPointServiceImpl(); ((DOMMountPointServiceImpl) this.mountPointService).registerMountPoint(this.mountPoint); ((DOMMountPointServiceImpl) this.mountPointService).registerMountPoint(this.mountPointWithNullSchemaContext); - when(this.mockMountPointHandler.getDOMMountPointService()).thenReturn(this.mountPointService); + when(this.mockMountPointHandler.get()).thenReturn(this.mountPointService); this.schemaService = new RestconfSchemaServiceImpl(this.mockContextHandler, this.mockMountPointHandler); } @@ -118,7 +118,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaTest() { // prepare conditions - return not-mount point schema context - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext); + when(this.mockContextHandler.get()).thenReturn(this.schemaContext); // make test final SchemaExportContext exportContext = this.schemaService.getSchema(TEST_MODULE); @@ -142,7 +142,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaForNotExistingModuleTest() { // prepare conditions - return not-mount point schema context - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext); + when(this.mockContextHandler.get()).thenReturn(this.schemaContext); // make test final SchemaExportContext exportContext = this.schemaService.getSchema(NOT_EXISTING_MODULE); @@ -158,7 +158,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaMountPointTest() { // prepare conditions - return schema context with mount points - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints); + when(this.mockContextHandler.get()).thenReturn(this.schemaContextWithMountPoints); // make test final SchemaExportContext exportContext = this.schemaService.getSchema(MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT); @@ -182,7 +182,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaForNotExistingModuleMountPointTest() { // prepare conditions - return schema context with mount points - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints); + when(this.mockContextHandler.get()).thenReturn(this.schemaContextWithMountPoints); // make test final SchemaExportContext exportContext = this.schemaService.getSchema(MOUNT_POINT + NOT_EXISTING_MODULE); @@ -198,7 +198,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWithNullSchemaContextTest() { // prepare conditions - returned schema context is null - when(this.mockContextHandler.getSchemaContext()).thenReturn(null); + when(this.mockContextHandler.get()).thenReturn(null); // make test this.thrown.expect(NullPointerException.class); @@ -212,7 +212,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWithNullSchemaContextMountPointTest() { // prepare conditions - returned schema context for mount points is null - when(this.mockContextHandler.getSchemaContext()).thenReturn(null); + when(this.mockContextHandler.get()).thenReturn(null); // make test this.thrown.expect(NullPointerException.class); @@ -226,7 +226,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaNullSchemaContextBehindMountPointTest() { // prepare conditions - return correct schema context for mount points (this is not null) - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints); + when(this.mockContextHandler.get()).thenReturn(this.schemaContextWithMountPoints); // make test - call service on mount point with null schema context this.thrown.expect(NullPointerException.class); @@ -241,7 +241,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWithNullIdentifierTest() { // prepare conditions - return correct schema context - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext); + when(this.mockContextHandler.get()).thenReturn(this.schemaContext); // make test this.thrown.expect(NullPointerException.class); @@ -255,7 +255,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWithEmptyIdentifierTest() { // prepare conditions - return correct schema context - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext); + when(this.mockContextHandler.get()).thenReturn(this.schemaContext); // make test and verify try { @@ -276,7 +276,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWithEmptyIdentifierMountPointTest() { // prepare conditions - return correct schema context with mount points - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints); + when(this.mockContextHandler.get()).thenReturn(this.schemaContextWithMountPoints); // make test and verify try { @@ -296,7 +296,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWithNotParsableIdentifierTest() { // prepare conditions - return correct schema context without mount points - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext); + when(this.mockContextHandler.get()).thenReturn(this.schemaContext); // make test and verify try { @@ -317,7 +317,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWithNotParsableIdentifierMountPointTest() { // prepare conditions - return correct schema context with mount points - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints); + when(this.mockContextHandler.get()).thenReturn(this.schemaContextWithMountPoints); // make test and verify try { @@ -339,7 +339,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWrongIdentifierTest() { // prepare conditions - return correct schema context without mount points - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext); + when(this.mockContextHandler.get()).thenReturn(this.schemaContext); // make test and verify try { @@ -362,7 +362,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWrongIdentifierMountPointTest() { // prepare conditions - return correct schema context with mount points - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints); + when(this.mockContextHandler.get()).thenReturn(this.schemaContextWithMountPoints); // make test and verify try { @@ -383,7 +383,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWithoutRevisionTest() { // prepare conditions - return correct schema context without mount points - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext); + when(this.mockContextHandler.get()).thenReturn(this.schemaContext); // make test and verify try { @@ -404,7 +404,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaWithoutRevisionMountPointTest() { // prepare conditions - return correct schema context with mount points - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints); + when(this.mockContextHandler.get()).thenReturn(this.schemaContextWithMountPoints); // make test and verify try { @@ -424,7 +424,7 @@ public class RestconfSchemaServiceTest { @Test public void getSchemaContextWithNotExistingMountPointTest() { // prepare conditions - return schema context with mount points - when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints); + when(this.mockContextHandler.get()).thenReturn(this.schemaContextWithMountPoints); // make test this.thrown.expect(IllegalArgumentException.class); diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/services/RestconfStreamsServiceTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/services/RestconfStreamsServiceTest.java index d4754e849d..85859000d8 100644 --- a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/services/RestconfStreamsServiceTest.java +++ b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/impl/services/RestconfStreamsServiceTest.java @@ -38,7 +38,7 @@ import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException; import org.opendaylight.netconf.sal.restconf.impl.RestconfError; import org.opendaylight.netconf.sal.streams.listeners.Notificator; import org.opendaylight.restconf.Draft11; -import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler; +import org.opendaylight.restconf.handlers.SchemaContextHandler; import org.opendaylight.restconf.rest.services.api.RestconfStreamsService; import org.opendaylight.restconf.rest.services.impl.RestconfStreamsServiceImpl; import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeConstants; @@ -108,7 +108,7 @@ public class RestconfStreamsServiceTest { @Test public void getAvailableStreamsTest() throws Exception { // prepare conditions - get correct Restconf module - when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext); + when(this.contextHandler.get()).thenReturn(this.mockSchemaContext); when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision())) .thenReturn(getTestingRestconfModule("ietf-restconf")); @@ -128,7 +128,7 @@ public class RestconfStreamsServiceTest { @Test public void getAvailableStreamsNullSchemaContextNegativeTest() { // prepare conditions - returned SchemaContext is null - when(this.contextHandler.getSchemaContext()).thenReturn(null); + when(this.contextHandler.get()).thenReturn(null); // make test this.thrown.expect(NullPointerException.class); @@ -142,7 +142,7 @@ public class RestconfStreamsServiceTest { @Test public void getAvailableStreamsMissingRestconfModuleNegativeTest() { // prepare conditions - get null Restconf module - when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext); + when(this.contextHandler.get()).thenReturn(this.mockSchemaContext); when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision())).thenReturn(null); @@ -159,7 +159,7 @@ public class RestconfStreamsServiceTest { @Test public void getAvailableStreamsMissingListStreamNegativeTest() { // prepare conditions - get Restconf module with missing list stream - when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext); + when(this.contextHandler.get()).thenReturn(this.mockSchemaContext); when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision())) .thenReturn(getTestingRestconfModule("restconf-module-with-missing-list-stream")); @@ -186,7 +186,7 @@ public class RestconfStreamsServiceTest { @Test public void getAvailableStreamsMissingContainerStreamsNegativeTest() { // prepare conditions - get Restconf module with missing container streams - when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext); + when(this.contextHandler.get()).thenReturn(this.mockSchemaContext); when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision())) .thenReturn(getTestingRestconfModule("restconf-module-with-missing-container-streams")); @@ -212,7 +212,7 @@ public class RestconfStreamsServiceTest { @Test public void getAvailableStreamsIllegalListStreamNegativeTest() { // prepare conditions - get Restconf module with illegal list stream - when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext); + when(this.contextHandler.get()).thenReturn(this.mockSchemaContext); when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision())) .thenReturn(getTestingRestconfModule("restconf-module-with-illegal-list-stream")); @@ -229,7 +229,7 @@ public class RestconfStreamsServiceTest { @Test public void getAvailableStreamsIllegalContainerStreamsNegativeTest() { // prepare conditions - get Restconf module with illegal container streams - when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext); + when(this.contextHandler.get()).thenReturn(this.mockSchemaContext); when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision())) .thenReturn(getTestingRestconfModule("restconf-module-with-illegal-container-streams")); @@ -246,7 +246,7 @@ public class RestconfStreamsServiceTest { @Test public void getAvailableStreamsIllegalLeafDescriptionNegativeTest() { // prepare conditions - get Restconf module with illegal leaf description in list stream - when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext); + when(this.contextHandler.get()).thenReturn(this.mockSchemaContext); when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision())) .thenReturn(getTestingRestconfModule("restconf-module-with-illegal-leaf-description")); diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/validation/RestconfValidationTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/validation/RestconfValidationTest.java index d6c5dc2927..8f8933f65f 100644 --- a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/validation/RestconfValidationTest.java +++ b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/validation/RestconfValidationTest.java @@ -21,6 +21,7 @@ import java.util.List; import org.junit.Test; import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException; import org.opendaylight.netconf.sal.restconf.impl.RestconfError; +import org.opendaylight.restconf.utils.validation.RestconfValidation; /** * Unit test for {@link RestconfValidation} -- 2.36.6