From: Tom Pantelis Date: Fri, 20 Apr 2018 13:30:32 +0000 (-0400) Subject: Use DOMMountPointServiceHandler non-statically X-Git-Tag: release/fluorine~89^2~1 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;ds=sidebyside;h=c4aa5392a3c307e87fb334520cd5692406a89ee2;p=netconf.git Use DOMMountPointServiceHandler non-statically Removed the static field in RestConnectorProvider and made the DOMMountPointServiceHandler instance static temporarily for the RestconfApplication but converts the rest of the code to reference it non-statically. The static DOMMountPointServiceHandler will be removed in a subsequent patch. Change-Id: I92e98c4f8c15a8e77bc2e0b970e74e3fe56d58a5 Signed-off-by: Tom Pantelis --- diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProvider.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProvider.java index e13a2f691e..6b21b7c9ad 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProvider.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProvider.java @@ -9,9 +9,7 @@ package org.opendaylight.restconf.nb.rfc8040; import com.google.common.base.Preconditions; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 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.DOMNotificationService; import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.mdsal.dom.api.DOMSchemaService; @@ -33,35 +31,31 @@ public class RestConnectorProvider implements Restconf private static final Logger LOG = LoggerFactory.getLogger(RestConnectorProvider.class); - @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") - private static volatile DOMMountPointServiceHandler mountPointServiceHandler; - private final DOMRpcService rpcService; private final DOMNotificationService notificationService; - private final DOMMountPointService mountPointService; private final DOMSchemaService domSchemaService; private final TransactionChainHandler transactionChainHandler; private final DOMDataBroker dataBroker; private final SchemaContextHandler schemaCtxHandler; + private final DOMMountPointServiceHandler mountPointServiceHandler; private final T wrapperServices; public RestConnectorProvider(final DOMDataBroker domDataBroker, final DOMSchemaService domSchemaService, final DOMRpcService rpcService, final DOMNotificationService notificationService, - final DOMMountPointService mountPointService, final TransactionChainHandler transactionChainHandler, - final SchemaContextHandler schemaCtxHandler, final T wrapperServices) { + final TransactionChainHandler transactionChainHandler, + final SchemaContextHandler schemaCtxHandler, final DOMMountPointServiceHandler mountPointServiceHandler, + final T wrapperServices) { this.wrapperServices = wrapperServices; this.domSchemaService = Preconditions.checkNotNull(domSchemaService); this.rpcService = Preconditions.checkNotNull(rpcService); this.notificationService = Preconditions.checkNotNull(notificationService); - this.mountPointService = Preconditions.checkNotNull(mountPointService); this.transactionChainHandler = Preconditions.checkNotNull(transactionChainHandler); this.dataBroker = Preconditions.checkNotNull(domDataBroker); this.schemaCtxHandler = Preconditions.checkNotNull(schemaCtxHandler); + this.mountPointServiceHandler = Preconditions.checkNotNull(mountPointServiceHandler); } public synchronized void start() { - mountPointServiceHandler = new DOMMountPointServiceHandler(mountPointService); - final DOMDataBrokerHandler brokerHandler = new DOMDataBrokerHandler(dataBroker); final RpcServiceHandler rpcServiceHandler = new RpcServiceHandler(rpcService); @@ -70,26 +64,13 @@ public class RestConnectorProvider implements Restconf new NotificationServiceHandler(notificationService); if (wrapperServices != null) { - wrapperServices.setHandlers(this.schemaCtxHandler, RestConnectorProvider.mountPointServiceHandler, + wrapperServices.setHandlers(this.schemaCtxHandler, mountPointServiceHandler, transactionChainHandler, brokerHandler, rpcServiceHandler, notificationServiceHandler, domSchemaService); } } - public DOMMountPointServiceHandler getMountPointServiceHandler() { - return mountPointServiceHandler; - } - - /** - * Get current {@link DOMMountPointService} from {@link DOMMountPointServiceHandler}. - * @return {@link DOMMountPointService} - */ - public static DOMMountPointService getMountPointService() { - return mountPointServiceHandler.get(); - } - @Override public void close() { - mountPointServiceHandler = null; } } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestconfApplication.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestconfApplication.java index 3c386490a4..c8c328b0d2 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestconfApplication.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestconfApplication.java @@ -11,6 +11,7 @@ import com.google.common.collect.ImmutableSet; import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; +import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.NormalizedNodeJsonBodyWriter; @@ -26,6 +27,7 @@ import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl public class RestconfApplication extends Application { private final SchemaContextHandler schemaContextHandler = SchemaContextHandler.instance(); + private final DOMMountPointServiceHandler mountPointServiceHandler = DOMMountPointServiceHandler.instance(); @Override public Set> getClasses() { @@ -40,10 +42,10 @@ public class RestconfApplication extends Application { public Set getSingletons() { final Set singletons = new HashSet<>(); singletons.add(ServicesWrapperImpl.getInstance()); - singletons.add(new JsonNormalizedNodeBodyReader(schemaContextHandler)); - singletons.add(new JsonToPatchBodyReader(schemaContextHandler)); - singletons.add(new XmlNormalizedNodeBodyReader(schemaContextHandler)); - singletons.add(new XmlToPatchBodyReader(schemaContextHandler)); + singletons.add(new JsonNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler)); + singletons.add(new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler)); + singletons.add(new XmlNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler)); + singletons.add(new XmlToPatchBodyReader(schemaContextHandler, mountPointServiceHandler)); return singletons; } } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/DOMMountPointServiceHandler.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/DOMMountPointServiceHandler.java index c95ee3f64c..e299fe0715 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/DOMMountPointServiceHandler.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/DOMMountPointServiceHandler.java @@ -14,8 +14,10 @@ import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; * Implementation of {@link DOMMountPointServiceHandler}. * */ -public class DOMMountPointServiceHandler implements Handler { - private final DOMMountPointService domMountPointService; +public final class DOMMountPointServiceHandler implements Handler { + private static final DOMMountPointServiceHandler INSTANCE = new DOMMountPointServiceHandler(); + + private DOMMountPointService domMountPointService; /** * Prepare mount point service for Restconf services. @@ -23,10 +25,24 @@ public class DOMMountPointServiceHandler implements Handler { - protected AbstractToPatchBodyReader(SchemaContextHandler schemaContextHandler) { - super(schemaContextHandler); + protected AbstractToPatchBodyReader(SchemaContextHandler schemaContextHandler, + DOMMountPointServiceHandler mountPointServiceHandler) { + super(schemaContextHandler, mountPointServiceHandler); } @Override diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonToPatchBodyReader.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonToPatchBodyReader.java index 489f8e0e32..232a9a7c03 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonToPatchBodyReader.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonToPatchBodyReader.java @@ -33,9 +33,9 @@ import org.opendaylight.restconf.common.errors.RestconfError.ErrorType; import org.opendaylight.restconf.common.patch.PatchContext; import org.opendaylight.restconf.common.patch.PatchEditOperation; import org.opendaylight.restconf.common.patch.PatchEntity; -import org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider; import org.opendaylight.restconf.nb.rfc8040.Rfc8040; import org.opendaylight.restconf.nb.rfc8040.codecs.StringModuleInstanceIdentifierCodec; +import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants; import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier; @@ -58,8 +58,9 @@ import org.slf4j.LoggerFactory; public class JsonToPatchBodyReader extends AbstractToPatchBodyReader { private static final Logger LOG = LoggerFactory.getLogger(JsonToPatchBodyReader.class); - public JsonToPatchBodyReader(SchemaContextHandler schemaContextHandler) { - super(schemaContextHandler); + public JsonToPatchBodyReader(SchemaContextHandler schemaContextHandler, + DOMMountPointServiceHandler mountPointServiceHandler) { + super(schemaContextHandler, mountPointServiceHandler); } @SuppressWarnings("checkstyle:IllegalCatch") @@ -89,7 +90,7 @@ public class JsonToPatchBodyReader extends AbstractToPatchBodyReader { try { return readFrom( ParserIdentifier.toInstanceIdentifier(uriPath, getSchemaContext(), - Optional.of(RestConnectorProvider.getMountPointService())), entityStream); + Optional.fromNullable(getMountPointService())), entityStream); } catch (final Exception e) { propagateExceptionAs(e); return null; // no-op diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlToPatchBodyReader.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlToPatchBodyReader.java index 338c605867..8364572de4 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlToPatchBodyReader.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlToPatchBodyReader.java @@ -34,6 +34,7 @@ import org.opendaylight.restconf.common.patch.PatchEditOperation; import org.opendaylight.restconf.common.patch.PatchEntity; import org.opendaylight.restconf.nb.rfc8040.Rfc8040; import org.opendaylight.restconf.nb.rfc8040.codecs.StringModuleInstanceIdentifierCodec; +import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants; import org.opendaylight.yangtools.util.xml.UntrustedXML; @@ -67,8 +68,9 @@ public class XmlToPatchBodyReader extends AbstractToPatchBodyReader { private static final Logger LOG = LoggerFactory.getLogger(XmlToPatchBodyReader.class); private static final Splitter SLASH_SPLITTER = Splitter.on('/'); - public XmlToPatchBodyReader(SchemaContextHandler schemaContextHandler) { - super(schemaContextHandler); + public XmlToPatchBodyReader(SchemaContextHandler schemaContextHandler, + DOMMountPointServiceHandler mountPointServiceHandler) { + super(schemaContextHandler, mountPointServiceHandler); } @SuppressWarnings("checkstyle:IllegalCatch") diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractIdentifierAwareJaxRsProvider.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractIdentifierAwareJaxRsProvider.java index a3398aa7b2..f516e5f1d4 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractIdentifierAwareJaxRsProvider.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractIdentifierAwareJaxRsProvider.java @@ -22,8 +22,9 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Request; import javax.ws.rs.core.UriInfo; import javax.ws.rs.ext.MessageBodyReader; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; -import org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider; +import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants; import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier; @@ -38,9 +39,12 @@ public abstract class AbstractIdentifierAwareJaxRsProvider implements Message private Request request; private final SchemaContextHandler schemaContextHandler; + private final DOMMountPointServiceHandler mountPointServiceHandler; - protected AbstractIdentifierAwareJaxRsProvider(SchemaContextHandler schemaContextHandler) { + protected AbstractIdentifierAwareJaxRsProvider(SchemaContextHandler schemaContextHandler, + DOMMountPointServiceHandler mountPointServiceHandler) { this.schemaContextHandler = schemaContextHandler; + this.mountPointServiceHandler = mountPointServiceHandler; } @Override @@ -86,7 +90,7 @@ public abstract class AbstractIdentifierAwareJaxRsProvider implements Message private InstanceIdentifierContext getInstanceIdentifierContext() { return ParserIdentifier.toInstanceIdentifier(getIdentifier(), getSchemaContext(), - Optional.of(RestConnectorProvider.getMountPointService())); + Optional.fromNullable(getMountPointService())); } protected UriInfo getUriInfo() { @@ -97,6 +101,10 @@ public abstract class AbstractIdentifierAwareJaxRsProvider implements Message return schemaContextHandler.get(); } + protected DOMMountPointService getMountPointService() { + return mountPointServiceHandler.get(); + } + protected boolean isPost() { return HttpMethod.POST.equals(this.request.getMethod()); } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractNormalizedNodeBodyReader.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractNormalizedNodeBodyReader.java index 3e2862ee71..90703bfee4 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractNormalizedNodeBodyReader.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractNormalizedNodeBodyReader.java @@ -12,6 +12,7 @@ import javax.ws.rs.core.Request; import javax.ws.rs.core.UriInfo; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.context.NormalizedNodeContext; +import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; /** @@ -22,8 +23,9 @@ import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; @Beta public abstract class AbstractNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsProvider { - protected AbstractNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler) { - super(schemaContextHandler); + protected AbstractNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler, + DOMMountPointServiceHandler mountPointServiceHandler) { + super(schemaContextHandler, mountPointServiceHandler); } public final void injectParams(final UriInfo uriInfo, final Request request) { diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040Impl.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040Impl.java index 52664062ec..5efca62de7 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040Impl.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040Impl.java @@ -195,7 +195,8 @@ public class JSONRestconfServiceRfc8040Impl implements JSONRestconfService, Auto final InputStream entityStream = new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8)); - JsonToPatchBodyReader jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler); + JsonToPatchBodyReader jsonToPatchBodyReader = + new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler); final PatchContext context = jsonToPatchBodyReader.readFrom(uriPath, entityStream); LOG.debug("Parsed YangInstanceIdentifier: {}", context.getInstanceIdentifierContext().getInstanceIdentifier()); diff --git a/restconf/restconf-nb-rfc8040/src/main/resources/org/opendaylight/blueprint/restconf-bp.xml b/restconf/restconf-nb-rfc8040/src/main/resources/org/opendaylight/blueprint/restconf-bp.xml index 943639892e..b8d27c5693 100644 --- a/restconf/restconf-nb-rfc8040/src/main/resources/org/opendaylight/blueprint/restconf-bp.xml +++ b/restconf/restconf-nb-rfc8040/src/main/resources/org/opendaylight/blueprint/restconf-bp.xml @@ -50,15 +50,20 @@ + + + + - + @@ -70,9 +75,7 @@ class="org.opendaylight.restconf.nb.rfc8040.rests.services.impl.JSONRestconfServiceRfc8040Impl" destroy-method="close"> - - - + diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProviderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProviderTest.java index 767f94e468..c02c2d26a9 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProviderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProviderTest.java @@ -24,6 +24,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler; import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl; @@ -59,8 +60,9 @@ public class RestConnectorProviderTest { final TransactionChainHandler transactionChainHandler = new TransactionChainHandler(mockDataBroker); this.connectorProvider = new RestConnectorProvider<>(mockDataBroker, domSchemaService, mockRpcService, - mockNotificationService, mockMountPointService, transactionChainHandler, + mockNotificationService, transactionChainHandler, SchemaContextHandler.newInstance(transactionChainHandler, domSchemaService), + DOMMountPointServiceHandler.newInstance(mockMountPointService), ServicesWrapperImpl.getInstance()); } diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java index aa33375b57..578bcd7e8c 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java @@ -11,11 +11,7 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import java.io.File; import java.io.InputStream; import java.net.URI; @@ -25,7 +21,6 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.errors.RestconfError; @@ -54,7 +49,7 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest { public XmlBodyReaderMountPointTest() throws Exception { super(schemaContext); - this.xmlBodyReader = new XmlNormalizedNodeBodyReader(schemaContextHandler); + this.xmlBodyReader = new XmlNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler); } @Override @@ -67,13 +62,6 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest { final Collection testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang"); testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc")); schemaContext = YangParserTestUtils.parseYangFiles(testFiles); - - final DOMMountPointService mountPointService = mock(DOMMountPointService.class); - final DOMMountPoint mountPoint = mock(DOMMountPoint.class); - - when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService); - when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint)); - when(mountPoint.getSchemaContext()).thenReturn(schemaContext); } @Test diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderMountPointTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderMountPointTest.java index 1453027ed5..4730d31c83 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderMountPointTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderMountPointTest.java @@ -11,22 +11,15 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import java.io.InputStream; import javax.ws.rs.core.MediaType; import org.junit.BeforeClass; import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.patch.PatchContext; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { @@ -37,7 +30,7 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { public JsonPatchBodyReaderMountPointTest() throws Exception { super(schemaContext); - jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler); + jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler); } @Override @@ -48,13 +41,6 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { @BeforeClass public static void initialization() { schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext); - - final DOMMountPointService mountPointService = mock(DOMMountPointService.class); - final DOMMountPoint mountPoint = mock(DOMMountPoint.class); - - when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService); - when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint)); - when(mountPoint.getSchemaContext()).thenReturn(schemaContext); } @Test diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderTest.java index 770746ce81..f84917da6f 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderTest.java @@ -11,14 +11,11 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import java.io.InputStream; import javax.ws.rs.core.MediaType; import org.junit.BeforeClass; import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.patch.PatchContext; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest; @@ -32,7 +29,7 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { public JsonPatchBodyReaderTest() throws Exception { super(schemaContext); - jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler); + jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler); } @Override @@ -43,7 +40,6 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { @BeforeClass public static void initialization() { schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext); - when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class)); } @Test diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderMountPointTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderMountPointTest.java index c638331097..cfe4915938 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderMountPointTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderMountPointTest.java @@ -10,22 +10,15 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import java.io.InputStream; import javax.ws.rs.core.MediaType; import org.junit.BeforeClass; import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.patch.PatchContext; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { @@ -36,7 +29,7 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { public XmlPatchBodyReaderMountPointTest() throws Exception { super(schemaContext); - xmlToPatchBodyReader = new XmlToPatchBodyReader(schemaContextHandler); + xmlToPatchBodyReader = new XmlToPatchBodyReader(schemaContextHandler, mountPointServiceHandler); } @Override @@ -47,13 +40,6 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { @BeforeClass public static void initialization() { schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext); - - final DOMMountPointService mountPointService = mock(DOMMountPointService.class); - final DOMMountPoint mountPoint = mock(DOMMountPoint.class); - - when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService); - when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint)); - when(mountPoint.getSchemaContext()).thenReturn(schemaContext); } @Test diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderTest.java index f98f576a95..2733f9001a 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderTest.java @@ -10,14 +10,11 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import java.io.InputStream; import javax.ws.rs.core.MediaType; import org.junit.BeforeClass; import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.patch.PatchContext; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest; @@ -31,7 +28,7 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest { public XmlPatchBodyReaderTest() throws Exception { super(schemaContext); - xmlToPatchBodyReader = new XmlToPatchBodyReader(schemaContextHandler); + xmlToPatchBodyReader = new XmlToPatchBodyReader(schemaContextHandler, mountPointServiceHandler); } @Override @@ -42,7 +39,6 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest { @BeforeClass public static void initialization() { schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext); - when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class)); } @Test diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java index a112fd0015..5f876d6706 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java @@ -9,44 +9,48 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.test; import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.lang.reflect.Field; +import com.google.common.base.Optional; import java.util.Collections; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Request; import javax.ws.rs.core.UriInfo; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.patch.PatchContext; -import org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider; import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils; import org.opendaylight.restconf.nb.rfc8040.TestUtils; import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentifierAwareJaxRsProvider; import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public abstract class AbstractBodyReaderTest { - protected static final DOMMountPointServiceHandler MOUNT_POINT_SERVICE_HANDLER = - mock(DOMMountPointServiceHandler.class); - protected final MediaType mediaType; protected final SchemaContextHandler schemaContextHandler; + protected final DOMMountPointServiceHandler mountPointServiceHandler; protected AbstractBodyReaderTest(SchemaContext schemaContext) throws NoSuchFieldException, IllegalAccessException { mediaType = getMediaType(); - final Field mountPointServiceHandlerField = - RestConnectorProvider.class.getDeclaredField("mountPointServiceHandler"); - mountPointServiceHandlerField.setAccessible(true); - mountPointServiceHandlerField.set(RestConnectorProvider.class, MOUNT_POINT_SERVICE_HANDLER); - schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext); + + final DOMMountPointService mountPointService = mock(DOMMountPointService.class); + final DOMMountPoint mountPoint = mock(DOMMountPoint.class); + doReturn(Optional.of(mountPoint)).when(mountPointService).getMountPoint(any(YangInstanceIdentifier.class)); + doReturn(schemaContext).when(mountPoint).getSchemaContext(); + + mountPointServiceHandler = DOMMountPointServiceHandler.newInstance(mountPointService); } protected abstract MediaType getMediaType(); diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/JsonBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/JsonBodyReaderTest.java index b372915132..1c3050e33e 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/JsonBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/JsonBodyReaderTest.java @@ -10,8 +10,6 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import com.google.common.collect.Sets; import java.io.File; @@ -22,7 +20,6 @@ import java.util.Collection; import javax.ws.rs.core.MediaType; import org.junit.BeforeClass; import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader; @@ -49,7 +46,7 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest { public JsonBodyReaderTest() throws Exception { super(schemaContext); - this.jsonBodyReader = new JsonNormalizedNodeBodyReader(schemaContextHandler); + this.jsonBodyReader = new JsonNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler); } @Override @@ -63,7 +60,6 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest { final Collection testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang"); testFiles.addAll(TestRestconfUtils.loadFiles("/modules")); schemaContext = YangParserTestUtils.parseYangFiles(testFiles); - when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class)); } @Test diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/XmlBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/XmlBodyReaderTest.java index ead68d4848..7f8d621cf9 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/XmlBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/XmlBodyReaderTest.java @@ -12,8 +12,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import com.google.common.collect.Sets; import java.io.File; @@ -24,7 +22,6 @@ import javax.ws.rs.core.MediaType; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.errors.RestconfError; @@ -53,7 +50,7 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest { public XmlBodyReaderTest() throws Exception { super(schemaContext); - this.xmlBodyReader = new XmlNormalizedNodeBodyReader(schemaContextHandler); + this.xmlBodyReader = new XmlNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler); } @Override @@ -67,7 +64,6 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest { testFiles.addAll(TestRestconfUtils.loadFiles("/modules")); testFiles.addAll(TestRestconfUtils.loadFiles("/foo-xml-test/yang")); schemaContext = YangParserTestUtils.parseYangFiles(testFiles); - when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class)); } @Test diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040ImplTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040ImplTest.java index 681dd4db76..b6a81801f3 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040ImplTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040ImplTest.java @@ -51,7 +51,6 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider; import org.opendaylight.restconf.nb.rfc8040.TestUtils; import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler; @@ -178,7 +177,7 @@ public class JSONRestconfServiceRfc8040ImplTest { final TransactionChainHandler txChainHandler = new TransactionChainHandler(mockDOMDataBroker); final DOMMountPointServiceHandler mountPointServiceHandler = - new DOMMountPointServiceHandler(mockMountPointService); + DOMMountPointServiceHandler.newInstance(mockMountPointService); final DOMNotificationService mockNotificationService = mock(DOMNotificationService.class); ServicesWrapperImpl.getInstance().setHandlers(schemaContextHandler, mountPointServiceHandler, @@ -188,9 +187,6 @@ public class JSONRestconfServiceRfc8040ImplTest { service = new JSONRestconfServiceRfc8040Impl(ServicesWrapperImpl.getInstance(), mountPointServiceHandler, schemaContextHandler); - - new RestConnectorProvider<>(mockDOMDataBroker, domSchemaService, mockRpcService, mockNotificationService, - mockMountPointService, txChainHandler, schemaContextHandler, null).start(); } private static String loadData(final String path) throws IOException { diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java index 37e62b0bbc..e6046caee5 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java @@ -101,8 +101,6 @@ public class RestconfDataServiceImplTest { @Mock private DOMDataWriteTransaction write; @Mock - private DOMMountPointServiceHandler mountPointServiceHandler; - @Mock private DOMMountPointService mountPointService; @Mock private DOMMountPoint mountPoint; @@ -190,8 +188,7 @@ public class RestconfDataServiceImplTest { schemaContextHandler.onGlobalContextUpdated(this.contextRef.get()); this.dataService = new RestconfDataServiceImpl(schemaContextHandler, this.transactionChainHandler, - this.mountPointServiceHandler, this.delegRestconfSubscrService); - doReturn(this.mountPointService).when(this.mountPointServiceHandler).get(); + DOMMountPointServiceHandler.newInstance(mountPointService), this.delegRestconfSubscrService); doReturn(Optional.of(this.mountPoint)).when(this.mountPointService) .getMountPoint(any(YangInstanceIdentifier.class)); doReturn(this.contextRef.get()).when(this.mountPoint).getSchemaContext(); diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceTest.java index 078f27534b..70ac788844 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceTest.java @@ -53,7 +53,7 @@ public class RestconfOperationsServiceTest { this.schemaContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules")); this.schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext); - this.domMountPointServiceHandler = new DOMMountPointServiceHandler(this.domMountPointService); + this.domMountPointServiceHandler = DOMMountPointServiceHandler.newInstance(this.domMountPointService); final QNameModule module1 = QNameModule.create(URI.create("module:1")); final QNameModule module2 = QNameModule.create(URI.create("module:2")); diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java index 80b9231159..d9b280212e 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java @@ -63,8 +63,6 @@ public class RestconfSchemaServiceTest { @Mock private SchemaContextHandler mockContextHandler; @Mock - private DOMMountPointServiceHandler mockMountPointHandler; - @Mock private DOMYangTextSourceProvider sourceProvider; // schema context with modules @@ -107,10 +105,9 @@ public class RestconfSchemaServiceTest { this.mountPointService = new DOMMountPointServiceImpl(); ((DOMMountPointServiceImpl) this.mountPointService).registerMountPoint(this.mountPoint); ((DOMMountPointServiceImpl) this.mountPointService).registerMountPoint(this.mountPointWithNullSchemaContext); - when(this.mockMountPointHandler.get()).thenReturn(this.mountPointService); - this.schemaService = new RestconfSchemaServiceImpl(this.mockContextHandler, this.mockMountPointHandler, - sourceProvider); + this.schemaService = new RestconfSchemaServiceImpl(this.mockContextHandler, + DOMMountPointServiceHandler.newInstance(mountPointService), sourceProvider); } /**