Get rid of netconf operation filters
[controller.git] / opendaylight / netconf / config-netconf-connector / src / test / java / org / opendaylight / controller / netconf / confignetconfconnector / NetconfMappingTest.java
index 72d62efe84c21cfcf47e1c0d7ac8eb60bdbc97a7..41d91819a695c7fab1d92c996f76add8afa8e26d 100644 (file)
@@ -42,6 +42,8 @@ import org.junit.Test;
 import org.junit.matchers.JUnitMatchers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
 import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
@@ -72,6 +74,8 @@ import org.opendaylight.controller.netconf.confignetconfconnector.operations.get
 import org.opendaylight.controller.netconf.confignetconfconnector.operations.runtimerpc.RuntimeRpc;
 import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider;
 import org.opendaylight.controller.netconf.impl.mapping.operations.DefaultCloseSession;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouterImpl;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshot;
 import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.controller.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
@@ -112,6 +116,8 @@ public class NetconfMappingTest extends AbstractConfigTest {
     YangStoreSnapshot yangStoreSnapshot;
     @Mock
     NetconfOperationRouter netconfOperationRouter;
+    @Mock
+    NetconfOperationServiceSnapshot netconfOperationServiceSnapshot;
 
     private TransactionProvider transactionProvider;
 
@@ -120,6 +126,7 @@ public class NetconfMappingTest extends AbstractConfigTest {
         MockitoAnnotations.initMocks(this);
         doReturn(getMbes()).when(this.yangStoreSnapshot).getModuleMXBeanEntryMap();
         doReturn(getModules()).when(this.yangStoreSnapshot).getModules();
+        doNothing().when(netconfOperationServiceSnapshot).close();
 
         this.factory = new NetconfTestImplModuleFactory();
         this.factory2 = new DepTestImplModuleFactory();
@@ -130,7 +137,7 @@ public class NetconfMappingTest extends AbstractConfigTest {
         transactionProvider = new TransactionProvider(this.configRegistryClient, NETCONF_SESSION_ID);
     }
 
-    private ObjectName createModule(final String instanceName) throws InstanceAlreadyExistsException, InstanceNotFoundException, URISyntaxException {
+    private ObjectName createModule(final String instanceName) throws InstanceAlreadyExistsException, InstanceNotFoundException, URISyntaxException, ValidationException, ConflictingVersionException {
         final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
 
         final ObjectName on = transaction.createModule(this.factory.getImplementationName(), instanceName);
@@ -305,10 +312,10 @@ public class NetconfMappingTest extends AbstractConfigTest {
         assertEquals(expectedResult, responseFromCandidate);
 
         edit("netconfMessages/editConfig_none.xml");
-        doNothing().when(netconfOperationRouter).close();
         closeSession();
-        verify(netconfOperationRouter).close();
+        verify(netconfOperationServiceSnapshot).close();
         verifyNoMoreInteractions(netconfOperationRouter);
+        verifyNoMoreInteractions(netconfOperationServiceSnapshot);
     }
 
     private void checkBigDecimal(Element response) {
@@ -322,7 +329,7 @@ public class NetconfMappingTest extends AbstractConfigTest {
 
     private void closeSession() throws NetconfDocumentedException, ParserConfigurationException, SAXException,
             IOException {
-        DefaultCloseSession closeOp = new DefaultCloseSession(NETCONF_SESSION_ID);
+        DefaultCloseSession closeOp = new DefaultCloseSession(NETCONF_SESSION_ID, netconfOperationServiceSnapshot);
         executeOp(closeOp, "netconfMessages/closeSession.xml");
     }
 
@@ -665,7 +672,7 @@ public class NetconfMappingTest extends AbstractConfigTest {
 
         Preconditions.checkState(priority != HandlingPriority.CANNOT_HANDLE);
 
-        final Document response = op.handle(request, netconfOperationRouter);
+        final Document response = op.handle(request, NetconfOperationRouterImpl.EXECUTION_TERMINATION_POINT);
         logger.debug("Got response\n{}", XmlUtil.toString(response));
         return response.getDocumentElement();
     }