Sync Common folder
[transportpce.git] / renderer / src / test / java / org / opendaylight / transportpce / renderer / provisiondevice / DeviceRendererServiceImplSetupTest.java
index dfb78bf2a437f6ef2081ac4c4c5b22d12cf6dc86..584c336effbd7a8a2cc1dc5e7a8b057538b9580a 100644 (file)
@@ -10,20 +10,30 @@ package org.opendaylight.transportpce.renderer.provisiondevice;
 
 import java.util.ArrayList;
 import java.util.List;
+
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.opendaylight.controller.md.sal.binding.api.MountPoint;
 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
+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.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;
+import org.opendaylight.transportpce.common.mapping.PortMappingVersion22;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
 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.OpenRoadmInterfaceFactory;
 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
 import org.opendaylight.transportpce.renderer.stub.MountPointServiceStub;
@@ -42,20 +52,39 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
     private CrossConnect crossConnect;
     private PortMapping portMapping;
     private OpenRoadmInterfaces openRoadmInterfaces;
+    private MappingUtils mappingUtils;
+    private OpenRoadmInterfacesImpl121 openRoadmInterfacesImpl121;
+    private OpenRoadmInterfacesImpl22 openRoadmInterfacesImpl22;
+    private PortMappingVersion22 portMappingVersion22;
+    private PortMappingVersion121 portMappingVersion121;
+    private CrossConnectImpl121 crossConnectImpl121;
+    private CrossConnectImpl22 crossConnectImpl22;
 
 
     private void setMountPoint(MountPoint mountPoint) {
         MountPointService mountPointService = new MountPointServiceStub(mountPoint);
         this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
-        this.openRoadmInterfaces = new OpenRoadmInterfacesImpl(this.deviceTransactionManager);
+        this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager);
+        this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl22(deviceTransactionManager);
+        this.mappingUtils = new MappingUtilsImpl(getDataBroker());
+        this.mappingUtils = Mockito.spy(this.mappingUtils);
+        this.openRoadmInterfaces = new OpenRoadmInterfacesImpl(deviceTransactionManager, mappingUtils,
+                openRoadmInterfacesImpl121, openRoadmInterfacesImpl22);
         this.openRoadmInterfaces = Mockito.spy(this.openRoadmInterfaces);
-        this.portMapping = new PortMappingImpl(this.getDataBroker(), this.deviceTransactionManager,
-                this.openRoadmInterfaces);
+        this.portMappingVersion22 =
+                new PortMappingVersion22(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
+        this.portMappingVersion121 =
+                new PortMappingVersion121(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
+        this.portMapping = new PortMappingImpl(getDataBroker(), this.portMappingVersion22, this.mappingUtils,
+                this.portMappingVersion121);
         this.portMapping = Mockito.spy(this.portMapping);
-        OpenRoadmInterfaceFactory openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(this.portMapping,
-            this.openRoadmInterfaces);
-        this.crossConnect = new CrossConnectImpl(this.deviceTransactionManager);
+        this.crossConnectImpl121 = new CrossConnectImpl121(deviceTransactionManager);
+        this.crossConnectImpl22 = new CrossConnectImpl22(deviceTransactionManager);
+        this.crossConnect = new CrossConnectImpl(deviceTransactionManager, this.mappingUtils, this.crossConnectImpl121,
+                this.crossConnectImpl22);
         this.crossConnect = Mockito.spy(this.crossConnect);
+        OpenRoadmInterfaceFactory openRoadmInterfaceFactory =
+                new OpenRoadmInterfaceFactory(this.portMapping, this.openRoadmInterfaces);
         this.deviceRendererService = new DeviceRendererServiceImpl(this.getDataBroker(),
         this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect,
             portMapping);
@@ -101,6 +130,8 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
         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");
         Mockito.doReturn(java.util.Optional.empty()).when(this.crossConnect).postCrossConnect(nodeId, 20L, srcTP,
             dstTp);
         ServicePathOutput servicePathOutput = deviceRendererService.setupServicePath(servicePathInput,
@@ -142,7 +173,8 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
                 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");
                 for (ServicePathDirection servicePathDirection : ServicePathDirection.values()) {
                     ServicePathOutput servicePathOutput = deviceRendererService.setupServicePath(servicePathInput,
                             servicePathDirection);
@@ -173,7 +205,8 @@ public class DeviceRendererServiceImplSetupTest extends AbstractTest {
         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");
         for (ServicePathDirection servicePathDirection : ServicePathDirection.values()) {
             ServicePathOutput servicePathOutput = deviceRendererService.setupServicePath(servicePathInput,
                     servicePathDirection);