Use DOMMountPointServiceHandler non-statically
[netconf.git] / restconf / restconf-nb-rfc8040 / src / test / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / impl / JSONRestconfServiceRfc8040ImplTest.java
index c8821e8e7b842040e22b2fa051c051791941687d..b6a81801f3f0c61a29bf65ff749aa7c415c8da29 100644 (file)
@@ -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;
@@ -128,9 +127,6 @@ public class JSONRestconfServiceRfc8040ImplTest {
     @Mock
     private DOMMountPointService mockMountPointService;
 
-    @Mock
-    private SchemaContextHandler mockSchemaContextHandler;
-
     @Mock
     private DOMDataBroker mockDOMDataBroker;
 
@@ -142,10 +138,11 @@ public class JSONRestconfServiceRfc8040ImplTest {
 
     private JSONRestconfServiceRfc8040Impl service;
 
+    private final SchemaContextHandler schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext);
+
     @BeforeClass
     public static void init() throws IOException, ReactorException {
         schemaContext = TestUtils.loadSchemaContext("/full-versions/yangs");
-        SchemaContextHandler.setSchemaContext(schemaContext);
     }
 
     @SuppressWarnings("resource")
@@ -177,25 +174,19 @@ public class JSONRestconfServiceRfc8040ImplTest {
 
         doReturn(mockTxChain).when(mockDOMDataBroker).createTransactionChain(any());
 
-        doReturn(schemaContext).when(mockSchemaContextHandler).get();
-
         final TransactionChainHandler txChainHandler = new TransactionChainHandler(mockDOMDataBroker);
 
         final DOMMountPointServiceHandler mountPointServiceHandler =
-                new DOMMountPointServiceHandler(mockMountPointService);
+                DOMMountPointServiceHandler.newInstance(mockMountPointService);
 
         final DOMNotificationService mockNotificationService = mock(DOMNotificationService.class);
-        ServicesWrapperImpl.getInstance().setHandlers(mockSchemaContextHandler, mountPointServiceHandler,
+        ServicesWrapperImpl.getInstance().setHandlers(schemaContextHandler, mountPointServiceHandler,
                 txChainHandler, new DOMDataBrokerHandler(mockDOMDataBroker),
                 new RpcServiceHandler(mockRpcService),
                 new NotificationServiceHandler(mockNotificationService), domSchemaService);
 
-        service = new JSONRestconfServiceRfc8040Impl(ServicesWrapperImpl.getInstance(), mountPointServiceHandler);
-
-        new RestConnectorProvider<>(mockDOMDataBroker, domSchemaService, mockRpcService, mockNotificationService,
-                mockMountPointService, txChainHandler, null).start();
-
-        SchemaContextHandler.setSchemaContext(schemaContext);
+        service = new JSONRestconfServiceRfc8040Impl(ServicesWrapperImpl.getInstance(), mountPointServiceHandler,
+                schemaContextHandler);
     }
 
     private static String loadData(final String path) throws IOException {