Enabled flex-grid support for 2.2.1 Roadms
[transportpce.git] / renderer / src / test / java / org / opendaylight / transportpce / renderer / provisiondevice / RendererServiceOperationsImplDeleteTest.java
index 4ce85b0a6a7ea50b345e79c56bfc93cca67dd87e..24d9361e5478dea9262cca7474a2609d0334411c 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.transportpce.renderer.provisiondevice;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
-
 import java.util.Collections;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executors;
@@ -33,6 +32,7 @@ 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.fixedflex.FlexGridImpl;
 import org.opendaylight.transportpce.common.mapping.MappingUtils;
 import org.opendaylight.transportpce.common.mapping.MappingUtilsImpl;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
@@ -58,8 +58,14 @@ import org.opendaylight.transportpce.renderer.utils.TransactionUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownOutputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.TransportpceOlmService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesBuilder;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.service.handler.header.ServiceHandlerHeaderBuilder;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.ServicePathList;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
@@ -67,6 +73,7 @@ import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
 
@@ -86,6 +93,7 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
     private PortMappingVersion121 portMappingVersion121;
     private CrossConnectImpl121 crossConnectImpl121;
     private CrossConnectImpl221 crossConnectImpl221;
+    private OtnDeviceRendererService otnDeviceRendererService;
 
     private void setMountPoint(MountPoint mountPoint) {
         MountPointService mountPointService = new MountPointServiceStub(mountPoint);
@@ -108,16 +116,21 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
             this.crossConnectImpl221);
         this.crossConnect = Mockito.spy(crossConnect);
         FixedFlexInterface fixedFlexInterface = new FixedFlexImpl();
+        FlexGridImpl flexGrid = new FlexGridImpl();
         OpenRoadmInterface121 openRoadmInterface121 = new OpenRoadmInterface121(portMapping,openRoadmInterfaces);
         OpenRoadmInterface221 openRoadmInterface221 = new OpenRoadmInterface221(portMapping,openRoadmInterfaces,
-            fixedFlexInterface);
+            fixedFlexInterface, flexGrid);
         OpenRoadmOtnInterface221 openRoadmOTNInterface = new OpenRoadmOtnInterface221(portMapping, openRoadmInterfaces);
         OpenRoadmInterfaceFactory openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(this.mappingUtils,
              openRoadmInterface121, openRoadmInterface221, openRoadmOTNInterface);
 
         this.deviceRenderer = new DeviceRendererServiceImpl(this.getDataBroker(),
             this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect,
-            this.portMapping);
+            this.portMapping, null);
+
+        this.otnDeviceRendererService = new OtnDeviceRendererServiceImpl(openRoadmInterfaceFactory, crossConnect,
+            openRoadmInterfaces, this.deviceTransactionManager, null);
+
     }
 
     @Before
@@ -129,8 +142,9 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
             MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
         this.networkModelWavelengthService = new NetworkModelWavelengthServiceImpl(getDataBroker());
         NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
-        this.rendererServiceOperations =  new RendererServiceOperationsImpl(this.deviceRenderer, olmService,
-                getDataBroker(), this.networkModelWavelengthService, notificationPublishService);
+        this.rendererServiceOperations =  new RendererServiceOperationsImpl(this.deviceRenderer,
+            this.otnDeviceRendererService, olmService, getDataBroker(), this.networkModelWavelengthService,
+            notificationPublishService);
 
     }
 
@@ -144,11 +158,20 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
             .setRequestId("request1").build());
         Mockito.doReturn(Collections.emptyList()).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(),
             Mockito.anyString(), Mockito.eq(false));
+        ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
+            .setServiceFormat(ServiceFormat.Ethernet)
+            .setServiceRate(Uint32.valueOf("100"))
+            .build();
+        Services service = new ServicesBuilder()
+            .setConnectionType(ConnectionType.Service)
+            .setServiceAEnd(serviceAEnd)
+            .build();
         ServiceDeleteOutput serviceDeleteOutput
-                = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build()).get();
+                = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build(), service).get();
         Assert.assertEquals(ResponseCodes.RESPONSE_OK,
             serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
-        Mockito.verify(this.crossConnect, Mockito.times(2)).deleteCrossConnect(Mockito.any(), Mockito.any(), Mockito.eq(false));
+        Mockito.verify(this.crossConnect, Mockito.times(2))
+                .deleteCrossConnect(Mockito.any(), Mockito.any(), Mockito.eq(false));
     }
 
     @Test
@@ -156,10 +179,11 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
         ServiceDeleteInputBuilder serviceDeleteInputBuilder = new ServiceDeleteInputBuilder();
         serviceDeleteInputBuilder.setServiceName("service 1");
         ServiceDeleteOutput serviceDeleteOutput
-                = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build()).get();
+                = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build(), null).get();
         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
             serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
-        Mockito.verify(this.crossConnect, Mockito.times(0)).deleteCrossConnect(Mockito.any(), Mockito.any(), Mockito.eq(false));
+        Mockito.verify(this.crossConnect, Mockito.times(0))
+                .deleteCrossConnect(Mockito.any(), Mockito.any(), Mockito.eq(false));
     }
 
     @Test
@@ -174,8 +198,16 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
         serviceDeleteInputBuilder.setServiceName("service 1");
         serviceDeleteInputBuilder.setServiceHandlerHeader((new ServiceHandlerHeaderBuilder())
                 .setRequestId("request1").build());
+        ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
+            .setServiceFormat(ServiceFormat.Ethernet)
+            .setServiceRate(Uint32.valueOf("100"))
+            .build();
+        Services service = new ServicesBuilder()
+            .setConnectionType(ConnectionType.Service)
+            .setServiceAEnd(serviceAEnd)
+            .build();
         ListenableFuture<ServiceDeleteOutput> serviceDeleteOutput
-                = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build());
+                = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build(), service);
         ServiceDeleteOutput output = serviceDeleteOutput.get();
         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
                 output.getConfigurationResponseCommon().getResponseCode());
@@ -200,8 +232,16 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
         serviceDeleteInputBuilder.setServiceName("service 1");
         serviceDeleteInputBuilder.setServiceHandlerHeader((new ServiceHandlerHeaderBuilder())
             .setRequestId("request1").build());
+        ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
+            .setServiceFormat(ServiceFormat.Ethernet)
+            .setServiceRate(Uint32.valueOf("100"))
+            .build();
+        Services service = new ServicesBuilder()
+            .setConnectionType(ConnectionType.Service)
+            .setServiceAEnd(serviceAEnd)
+            .build();
         ServiceDeleteOutput serviceDeleteOutput =
-                this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build()).get();
+                this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build(), service).get();
         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
             serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
         Mockito.verify(this.olmService, Mockito.times(2)).servicePowerTurndown(Mockito.any());