BUG-6647 Increase code coverage and clean up II
[bgpcep.git] / pcep / tunnel-provider / src / test / java / org / opendaylight / controller / config / yang / pcep / tunnel / provider / PCEPTunnelTopologyProviderModuleTest.java
index 8db4dee6e5eed56173229bb697a938e6389cb980..b316753f73e2049d87fa0e3f917ebce0a98f2c70 100644 (file)
@@ -9,9 +9,11 @@ package org.opendaylight.controller.config.yang.pcep.tunnel.provider;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
+import io.netty.channel.nio.NioEventLoopGroup;
+import java.util.Arrays;
 import java.util.List;
 import javax.management.ObjectName;
+import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.jmx.CommitStatus;
@@ -19,14 +21,19 @@ import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.impl.PCEPSessionProposalFactoryImplModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.spi.SimplePCEPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.stateful02.cfg.Stateful02PCEPSessionProposalFactoryModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleMXBean;
 import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleTest;
-import org.opendaylight.controller.config.yang.pcep.topology.provider.Stateful02TopologySessionListenerModuleFactory;
+import org.opendaylight.controller.config.yang.pcep.topology.provider.Stateful07TopologySessionListenerModuleFactory;
 import org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerTest;
+import org.opendaylight.protocol.pcep.PCEPDispatcher;
+import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
+import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
+import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
+import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
+import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
+import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
+import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
 
 public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSchedulerTest {
@@ -36,6 +43,21 @@ public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSch
 
     private static final TopologyId TOPOLOGY_ID = new TopologyId("pcep-topology");
 
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+
+        SimplePCEPExtensionProviderContext extContext = new SimplePCEPExtensionProviderContext();
+        setupMockService(PCEPExtensionProviderContext.class, extContext);
+        BasePCEPSessionProposalFactory proposalFactory = new BasePCEPSessionProposalFactory(120, 30,
+                Arrays.asList(new PCEPStatefulCapability(true, true, true, true, true, true, true)));
+        setupMockService(PCEPSessionProposalFactory.class, proposalFactory);
+        NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup();
+        setupMockService(PCEPDispatcher.class, new PCEPDispatcherImpl(extContext.getMessageHandlerRegistry(),
+                new DefaultPCEPSessionNegotiatorFactory(proposalFactory, 5), eventLoopGroup, eventLoopGroup));
+    }
+
     @Test
     public void testValidationExceptionTopologyIdNotSet() throws Exception {
         try {
@@ -50,7 +72,7 @@ public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSch
     public void testCreateBean() throws Exception {
         final CommitStatus status = createInstance();
         assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 19, 0, 0);
+        assertStatus(status, 14, 0, 0);
     }
 
     @Test
@@ -60,7 +82,7 @@ public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSch
         assertBeanCount(1, FACTORY_NAME);
         final CommitStatus status = transaction.commit();
         assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 0, 19);
+        assertStatus(status, 0, 0, 14);
     }
 
     @Test
@@ -73,7 +95,7 @@ public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSch
         mxBean.setTopologyId(new TopologyId("new-pcep-topology"));
         final CommitStatus status = transaction.commit();
         assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 1, 18);
+        assertStatus(status, 0, 1, 13);
     }
 
     private CommitStatus createInstance(final TopologyId topologyId) throws Exception {
@@ -90,8 +112,9 @@ public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSch
             throws Exception {
         final ObjectName objectName = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
         final ObjectName asyncDataBrokerON = createAsyncDataBrokerInstance(transaction);
+        final ObjectName dataBrokerON = createCompatibleDataBrokerInstance(transaction);
         final ObjectName notificationBrokerON = createNotificationBrokerInstance(transaction);
-        final ObjectName bindingBrokerON = createBindingBrokerImpl(transaction, createCompatibleDataBrokerInstance(transaction), notificationBrokerON);
+        final ObjectName bindingBrokerON = createBindingBrokerImpl(transaction, dataBrokerON, notificationBrokerON);
         final ObjectName schedulerON = createInstructionSchedulerModuleInstance(transaction, asyncDataBrokerON, bindingBrokerON,
                 notificationBrokerON);
         final ObjectName sourceTopology = PCEPTopologyProviderModuleTest.createPCEPTopologyProviderModuleInstance(transaction,
@@ -99,7 +122,7 @@ public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSch
 
         final PCEPTunnelTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(objectName,
                 PCEPTunnelTopologyProviderModuleMXBean.class);
-        mxBean.setDataProvider(createDataBrokerInstance(transaction));
+        mxBean.setDataProvider(asyncDataBrokerON);
         mxBean.setRpcRegistry(bindingBrokerON);
         mxBean.setScheduler(schedulerON);
         mxBean.setTopologyId(topologyId);
@@ -113,11 +136,8 @@ public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSch
         moduleFactories.add(new PCEPTunnelTopologyProviderModuleFactory());
         moduleFactories.add(new PCEPTopologyProviderModuleFactory());
         moduleFactories.add(new PCEPDispatcherImplModuleFactory());
-        moduleFactories.add(new PCEPSessionProposalFactoryImplModuleFactory());
         moduleFactories.add(new NettyThreadgroupModuleFactory());
-        moduleFactories.add(new SimplePCEPExtensionProviderContextModuleFactory());
-        moduleFactories.add(new Stateful02TopologySessionListenerModuleFactory());
-        moduleFactories.add(new Stateful02PCEPSessionProposalFactoryModuleFactory());
+        moduleFactories.add(new Stateful07TopologySessionListenerModuleFactory());
         return moduleFactories;
     }
 
@@ -126,6 +146,13 @@ public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSch
         final List<String> paths = super.getYangModelsPaths();
         paths.add("/META-INF/yang/network-topology@2013-10-21.yang");
         paths.add("/META-INF/yang/network-topology-pcep.yang");
+        paths.add("/META-INF/yang/network-topology-pcep-programming.yang");
+        paths.add("/META-INF/yang/network-topology-programming.yang");
+        paths.add("/META-INF/yang/topology-tunnel.yang");
+        paths.add("/META-INF/yang/topology-tunnel-pcep.yang");
+        paths.add("/META-INF/yang/topology-tunnel-pcep-programming.yang");
+        paths.add("/META-INF/yang/topology-tunnel-p2p.yang");
+        paths.add("/META-INF/yang/topology-tunnel-programming.yang");
         paths.add("/META-INF/yang/odl-network-topology.yang");
         paths.add("/META-INF/yang/yang-ext.yang");
         paths.add("/META-INF/yang/pcep-types.yang");