Update Renderer Module
[transportpce.git] / renderer / src / test / java / org / opendaylight / transportpce / renderer / provisiondevice / DeviceRendererServiceImplSetupTest.java
index 584c336effbd7a8a2cc1dc5e7a8b057538b9580a..7c3242b30362bba38ee303fbbc23c3e03b2b2d2c 100644 (file)
@@ -23,8 +23,9 @@ import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl121;
 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl22;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
+import org.opendaylight.transportpce.common.fixedflex.FixedFlexImpl;
+import org.opendaylight.transportpce.common.fixedflex.FixedFlexInterface;
 import org.opendaylight.transportpce.common.mapping.MappingUtils;
-import org.opendaylight.transportpce.common.mapping.MappingUtilsImpl;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.mapping.PortMappingImpl;
 import org.opendaylight.transportpce.common.mapping.PortMappingVersion121;
@@ -34,6 +35,8 @@ import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfa
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl121;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl22;
+import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterface121;
+import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterface22;
 import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
 import org.opendaylight.transportpce.renderer.stub.MountPointServiceStub;
@@ -66,27 +69,37 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
         this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
         this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager);
         this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl22(deviceTransactionManager);
-        this.mappingUtils = new MappingUtilsImpl(getDataBroker());
-        this.mappingUtils = Mockito.spy(this.mappingUtils);
+        this.mappingUtils = Mockito.spy(MappingUtils.class);
+
+        Mockito.doReturn(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1).when(mappingUtils)
+            .getOpenRoadmVersion(Mockito.anyString());
+
         this.openRoadmInterfaces = new OpenRoadmInterfacesImpl(deviceTransactionManager, mappingUtils,
-                openRoadmInterfacesImpl121, openRoadmInterfacesImpl22);
+            openRoadmInterfacesImpl121, openRoadmInterfacesImpl22);
         this.openRoadmInterfaces = Mockito.spy(this.openRoadmInterfaces);
         this.portMappingVersion22 =
-                new PortMappingVersion22(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
+            new PortMappingVersion22(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
         this.portMappingVersion121 =
-                new PortMappingVersion121(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
+            new PortMappingVersion121(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
         this.portMapping = new PortMappingImpl(getDataBroker(), this.portMappingVersion22, this.mappingUtils,
-                this.portMappingVersion121);
+            this.portMappingVersion121);
         this.portMapping = Mockito.spy(this.portMapping);
         this.crossConnectImpl121 = new CrossConnectImpl121(deviceTransactionManager);
         this.crossConnectImpl22 = new CrossConnectImpl22(deviceTransactionManager);
         this.crossConnect = new CrossConnectImpl(deviceTransactionManager, this.mappingUtils, this.crossConnectImpl121,
-                this.crossConnectImpl22);
+            this.crossConnectImpl22);
         this.crossConnect = Mockito.spy(this.crossConnect);
-        OpenRoadmInterfaceFactory openRoadmInterfaceFactory =
-                new OpenRoadmInterfaceFactory(this.portMapping, this.openRoadmInterfaces);
+
+
+        FixedFlexInterface fixedFlexInterface = new FixedFlexImpl();
+        OpenRoadmInterface121 openRoadmInterface121 = new OpenRoadmInterface121(portMapping,openRoadmInterfaces);
+        OpenRoadmInterface22 openRoadmInterface22 = new OpenRoadmInterface22(portMapping,openRoadmInterfaces,
+            fixedFlexInterface);
+        OpenRoadmInterfaceFactory openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(this.mappingUtils,
+            openRoadmInterface121,openRoadmInterface22);
+
         this.deviceRendererService = new DeviceRendererServiceImpl(this.getDataBroker(),
-        this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect,
+            this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect,
             portMapping);
     }
 
@@ -107,14 +120,14 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
     public void testSetupServicemptyPorts() {
         setMountPoint(MountPointUtils.getMountPoint(new ArrayList<>(), getDataBroker()));
         String nodeId = "node1";
-        String srcTP = OpenRoadmInterfacesImpl.TTP_TOKEN;
-        String dstTp = OpenRoadmInterfacesImpl.PP_TOKEN;
+        String srcTP = StringConstants.TTP_TOKEN;
+        String dstTp = StringConstants.PP_TOKEN;
         List<Nodes> nodes = new ArrayList<>();
         nodes.add(ServiceImplementationDataUtils.createNode(nodeId, srcTP, dstTp));
         ServicePathInput servicePathInput = ServiceImplementationDataUtils.buildServicePathInputs(nodes);
         for (ServicePathDirection servicePathDirection : ServicePathDirection.values()) {
             ServicePathOutput servicePathOutput = deviceRendererService.setupServicePath(servicePathInput,
-                    servicePathDirection);
+                servicePathDirection);
             Assert.assertFalse(servicePathOutput.isSuccess());
         }
     }
@@ -123,19 +136,19 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
     public void testSetupServiceCannotCrossConnect() {
         setMountPoint(MountPointUtils.getMountPoint(new ArrayList<>(), getDataBroker()));
         String nodeId = "node1";
-        String srcTP = OpenRoadmInterfacesImpl.TTP_TOKEN;
-        String dstTp = OpenRoadmInterfacesImpl.PP_TOKEN;
+        String srcTP = StringConstants.TTP_TOKEN;
+        String dstTp = StringConstants.PP_TOKEN;
         MountPointUtils.writeMapping(nodeId, srcTP, this.deviceTransactionManager);
         MountPointUtils.writeMapping(nodeId, dstTp, this.deviceTransactionManager);
         List<Nodes> nodes = new ArrayList<>();
         nodes.add(ServiceImplementationDataUtils.createNode(nodeId, srcTP, dstTp));
         ServicePathInput servicePathInput = ServiceImplementationDataUtils.buildServicePathInputs(nodes);
         Mockito.doReturn(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1).when(this.mappingUtils)
-                .getOpenRoadmVersion("node1");
+            .getOpenRoadmVersion("node1");
         Mockito.doReturn(java.util.Optional.empty()).when(this.crossConnect).postCrossConnect(nodeId, 20L, srcTP,
             dstTp);
         ServicePathOutput servicePathOutput = deviceRendererService.setupServicePath(servicePathInput,
-                    ServicePathDirection.A_TO_Z);
+            ServicePathDirection.A_TO_Z);
         Assert.assertFalse(servicePathOutput.isSuccess());
     }
 
@@ -145,10 +158,10 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
         Mockito.doNothing().when(this.openRoadmInterfaces).postEquipmentState(Mockito.anyString(),
             Mockito.anyString(), Mockito.anyBoolean());
         String [] interfaceTokens = {
-            OpenRoadmInterfacesImpl.NETWORK_TOKEN,
-            OpenRoadmInterfacesImpl.CLIENT_TOKEN,
-            OpenRoadmInterfacesImpl.TTP_TOKEN,
-            OpenRoadmInterfacesImpl.PP_TOKEN
+            StringConstants.NETWORK_TOKEN,
+            StringConstants.CLIENT_TOKEN,
+            StringConstants.TTP_TOKEN,
+            StringConstants.PP_TOKEN
         };
 
         String nodeId = "node1";
@@ -161,12 +174,12 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
                 MountPointUtils.writeMapping(nodeId, dstTp, this.deviceTransactionManager);
 
                 boolean connectingUsingCrossConnect = true;
-                if (OpenRoadmInterfacesImpl.NETWORK_TOKEN.equals(srcToken)
-                        || OpenRoadmInterfacesImpl.CLIENT_TOKEN.equals(srcToken)) {
+                if (StringConstants.NETWORK_TOKEN.equals(srcToken)
+                    || StringConstants.CLIENT_TOKEN.equals(srcToken)) {
                     connectingUsingCrossConnect = false;
                 }
-                if (OpenRoadmInterfacesImpl.NETWORK_TOKEN.equals(dstToken)
-                        || OpenRoadmInterfacesImpl.CLIENT_TOKEN.equals(dstToken)) {
+                if (StringConstants.NETWORK_TOKEN.equals(dstToken)
+                    || StringConstants.CLIENT_TOKEN.equals(dstToken)) {
                     connectingUsingCrossConnect = false;
                 }
 
@@ -174,10 +187,10 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
                 nodes.add(ServiceImplementationDataUtils.createNode(nodeId, srcTP, dstTp));
                 ServicePathInput servicePathInput = ServiceImplementationDataUtils.buildServicePathInputs(nodes);
                 Mockito.doReturn(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1).when(this.mappingUtils)
-                        .getOpenRoadmVersion("node1");
+                    .getOpenRoadmVersion("node1");
                 for (ServicePathDirection servicePathDirection : ServicePathDirection.values()) {
                     ServicePathOutput servicePathOutput = deviceRendererService.setupServicePath(servicePathInput,
-                            servicePathDirection);
+                        servicePathDirection);
                     Assert.assertTrue(servicePathOutput.isSuccess());
                     String expectedResult = "Roadm-connection successfully created for nodes: ";
                     if (connectingUsingCrossConnect) {
@@ -206,10 +219,10 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
         nodes.add(ServiceImplementationDataUtils.createNode(nodeId, srcTP, dstTp));
         ServicePathInput servicePathInput = ServiceImplementationDataUtils.buildServicePathInputs(nodes);
         Mockito.doReturn(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1).when(this.mappingUtils)
-                .getOpenRoadmVersion("node1");
+            .getOpenRoadmVersion("node1");
         for (ServicePathDirection servicePathDirection : ServicePathDirection.values()) {
             ServicePathOutput servicePathOutput = deviceRendererService.setupServicePath(servicePathInput,
-                    servicePathDirection);
+                servicePathDirection);
             Assert.assertTrue(servicePathOutput.isSuccess());
             String expectedResult = "Roadm-connection successfully created for nodes: ";
             expectedResult = expectedResult + nodeId;
@@ -218,4 +231,4 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
             Assert.assertEquals(nodeId, servicePathOutput.getNodeInterface().get(0).getNodeId());
         }
     }
-}
+}
\ No newline at end of file