Update Renderer Module
[transportpce.git] / renderer / src / test / java / org / opendaylight / transportpce / renderer / provisiondevice / RendererServiceOperationsImplDeleteTest.java
index 820982fb0ef4fad2121c0877c691bd975b1038fe..aeef8d0fbfebd6e0130a2b146f05a394976cb79e 100644 (file)
@@ -23,12 +23,15 @@ import org.opendaylight.controller.md.sal.binding.api.MountPointService;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.ResponseCodes;
+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.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;
@@ -41,6 +44,8 @@ import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfa
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl22;
 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthServiceImpl;
+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.stub.MountPointServiceStub;
 import org.opendaylight.transportpce.renderer.stub.MountPointStub;
@@ -87,23 +92,28 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
         this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl22(deviceTransactionManager);
         this.mappingUtils = new MappingUtilsImpl(getDataBroker());
         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.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(crossConnect);
-        OpenRoadmInterfaceFactory openRoadmInterfaceFactory =
-                new OpenRoadmInterfaceFactory(portMapping, 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.deviceRenderer = new DeviceRendererServiceImpl(this.getDataBroker(),
-                this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect,
+            this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect,
             this.portMapping);
     }
 
@@ -113,7 +123,7 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
         this.olmService = new OlmServiceStub();
         this.olmService = Mockito.spy(this.olmService);
         ListeningExecutorService executor =
-                MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
+            MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
         this.networkModelWavelengthService = new NetworkModelWavelengthServiceImpl(getDataBroker());
         NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
         this.rendererServiceOperations =  new RendererServiceOperationsImpl(this.deviceRenderer, olmService,
@@ -128,12 +138,12 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
         ServiceDeleteInputBuilder serviceDeleteInputBuilder = new ServiceDeleteInputBuilder();
         serviceDeleteInputBuilder.setServiceName("service 1");
         serviceDeleteInputBuilder.setServiceHandlerHeader((new ServiceHandlerHeaderBuilder())
-                .setRequestId("request1").build());
+            .setRequestId("request1").build());
         Mockito.doReturn(true).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(), Mockito.anyString());
         ServiceDeleteOutput serviceDeleteOutput
                 = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build()).get();
         Assert.assertEquals(ResponseCodes.RESPONSE_OK,
-                serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
+            serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
         Mockito.verify(this.crossConnect, Mockito.times(2)).deleteCrossConnect(Mockito.any(), Mockito.any());
     }
 
@@ -144,7 +154,7 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
         ServiceDeleteOutput serviceDeleteOutput
                 = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build()).get();
         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
-                serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
+            serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
         Mockito.verify(this.crossConnect, Mockito.times(0)).deleteCrossConnect(Mockito.any(), Mockito.any());
     }
 
@@ -152,7 +162,7 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
     public void serviceDeleteOperationTearDownFailedAtoZ() throws ExecutionException, InterruptedException {
         Mockito.doReturn(true).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(), Mockito.anyString());
         Mockito.doReturn(RpcResultBuilder.success((new ServicePowerTurndownOutputBuilder())
-                .setResult("Failed").build()).buildFuture()).when(this.olmService).servicePowerTurndown(Mockito.any());
+            .setResult("Failed").build()).buildFuture()).when(this.olmService).servicePowerTurndown(Mockito.any());
 
         writePathDescription();
         ServiceDeleteInputBuilder serviceDeleteInputBuilder = new ServiceDeleteInputBuilder();
@@ -172,20 +182,20 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
     public void serviceDeleteOperationTearDownFailedZtoA() throws ExecutionException, InterruptedException {
         Mockito.doReturn(true).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(), Mockito.anyString());
         Mockito.when(this.olmService.servicePowerTurndown(Mockito.any()))
-                .thenReturn(RpcResultBuilder.success((new ServicePowerTurndownOutputBuilder())
-                        .setResult("Success").build()).buildFuture())
-                .thenReturn(RpcResultBuilder.success((new ServicePowerTurndownOutputBuilder())
-                        .setResult("Failed").build()).buildFuture());
+            .thenReturn(RpcResultBuilder.success((new ServicePowerTurndownOutputBuilder())
+                .setResult("Success").build()).buildFuture())
+            .thenReturn(RpcResultBuilder.success((new ServicePowerTurndownOutputBuilder())
+                .setResult("Failed").build()).buildFuture());
 
         writePathDescription();
         ServiceDeleteInputBuilder serviceDeleteInputBuilder = new ServiceDeleteInputBuilder();
         serviceDeleteInputBuilder.setServiceName("service 1");
         serviceDeleteInputBuilder.setServiceHandlerHeader((new ServiceHandlerHeaderBuilder())
-                .setRequestId("request1").build());
+            .setRequestId("request1").build());
         ServiceDeleteOutput serviceDeleteOutput =
                 this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build()).get();
         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
-                serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
+            serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
         Mockito.verify(this.olmService, Mockito.times(2)).servicePowerTurndown(Mockito.any());
         Mockito.verify(this.crossConnect, Mockito.times(0)).deleteCrossConnect(Mockito.eq("node1"), Mockito.any());
         Mockito.verify(this.crossConnect, Mockito.times(0)).deleteCrossConnect(Mockito.eq("node2"), Mockito.any());
@@ -194,7 +204,7 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
     private void writePathDescription() throws ExecutionException, InterruptedException {
         ServicePathsBuilder servicePathsBuilder = new ServicePathsBuilder();
         servicePathsBuilder.setPathDescription(ServiceDeleteDataUtils
-            .createTransactionPathDescription(OpenRoadmInterfacesImpl.PP_TOKEN));
+            .createTransactionPathDescription(StringConstants.PP_TOKEN));
         servicePathsBuilder.setServiceAEnd(ServiceDeleteDataUtils.getServiceAEndBuild().build())
             .setServiceZEnd(ServiceDeleteDataUtils.getServiceZEndBuild().build());
         servicePathsBuilder.withKey(new ServicePathsKey("service 1"));
@@ -203,10 +213,10 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
         InstanceIdentifier<ServicePaths> servicePathsInstanceIdentifier = InstanceIdentifier.create(
             ServicePathList.class).child(ServicePaths.class, new ServicePathsKey("service 1"));
         TransactionUtils.writeTransaction(
-                this.deviceTransactionManager,
-                "node1" + OpenRoadmInterfacesImpl.PP_TOKEN,
-                LogicalDatastoreType.OPERATIONAL,
-                servicePathsInstanceIdentifier,
-                servicePathsBuilder.build());
+            this.deviceTransactionManager,
+            "node1" + StringConstants.PP_TOKEN,
+            LogicalDatastoreType.OPERATIONAL,
+            servicePathsInstanceIdentifier,
+            servicePathsBuilder.build());
     }
 }