Use DOMMountPointServiceHandler non-statically
[netconf.git] / restconf / restconf-nb-rfc8040 / src / test / java / org / opendaylight / restconf / nb / rfc8040 / services / simple / impl / RestconfOperationsServiceTest.java
index 88bae0c00a710ac043a26df7d1fc4ce07784dbbb..70ac7888449677e76e4f9b28618b4402d0cb17f1 100644 (file)
@@ -8,27 +8,23 @@
 package org.opendaylight.restconf.nb.rfc8040.services.simple.impl;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.Futures;
 import java.net.URI;
 import java.util.Set;
 import javax.ws.rs.core.UriInfo;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
-import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 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.handlers.TransactionChainHandler;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -54,21 +50,13 @@ public class RestconfOperationsServiceTest {
     @Before
     public void init() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.schemaContext = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules"));
+        this.schemaContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules"));
+        this.schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext);
 
-        final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
-        final DOMTransactionChain domTx = Mockito.mock(DOMTransactionChain.class);
-        Mockito.when(txHandler.get()).thenReturn(domTx);
-        final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
-        Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
-        Mockito.when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
-        this.schemaContextHandler = new SchemaContextHandler(txHandler);
-        this.schemaContextHandler.onGlobalContextUpdated(this.schemaContext);
+        this.domMountPointServiceHandler = DOMMountPointServiceHandler.newInstance(this.domMountPointService);
 
-        this.domMountPointServiceHandler = new DOMMountPointServiceHandler(this.domMountPointService);
-
-        final QNameModule module1 = QNameModule.create(new URI("module:1"), null);
-        final QNameModule module2 = QNameModule.create(new URI("module:2"), null);
+        final QNameModule module1 = QNameModule.create(URI.create("module:1"));
+        final QNameModule module2 = QNameModule.create(URI.create("module:2"));
 
         this.listOfRpcsNames = ImmutableSet.of(QName.create(module1, "dummy-rpc1-module1"),
                 QName.create(module1, "dummy-rpc2-module1"), QName.create(module2, "dummy-rpc1-module2"),
@@ -87,7 +75,7 @@ public class RestconfOperationsServiceTest {
         assertEquals(4, data.getValue().size());
 
         for (final DataContainerChild<? extends PathArgument, ?> child : data.getValue()) {
-            assertNull(child.getValue());
+            assertEquals(Empty.getInstance(), child.getValue());
 
             final QName qname = child.getNodeType().withoutRevision();
             assertTrue(this.listOfRpcsNames.contains(qname));