X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=renderer%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Frenderer%2Fprovisiondevice%2FRendererServiceOperationsImplDeleteTest.java;h=23ad8eb4de06d18434f80516824ae0eaa5489be5;hb=4378fca1d31d1f75c0480c752aa711fb885e6135;hp=62a96093ba31cfabbe755697cc8aea9b1fa7435a;hpb=e6e13c5ba1221d74154c089ec95cd631950f1ef4;p=transportpce.git diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImplDeleteTest.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImplDeleteTest.java index 62a96093b..23ad8eb4d 100644 --- a/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImplDeleteTest.java +++ b/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImplDeleteTest.java @@ -8,44 +8,62 @@ 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; import org.junit.Assert; import org.junit.Before; 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.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.mdsal.binding.api.MountPointService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.common.api.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.CrossConnectImpl221; 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; +import org.opendaylight.transportpce.common.mapping.PortMappingVersion221; 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.OpenRoadmInterfacesImpl221; 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.OpenRoadmInterface221; import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory; import org.opendaylight.transportpce.renderer.stub.MountPointServiceStub; import org.opendaylight.transportpce.renderer.stub.MountPointStub; import org.opendaylight.transportpce.renderer.stub.OlmServiceStub; +import org.opendaylight.transportpce.renderer.utils.NotificationPublishServiceMock; import org.opendaylight.transportpce.renderer.utils.ServiceDeleteDataUtils; import org.opendaylight.transportpce.renderer.utils.TransactionUtils; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInputBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServicePathList; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePaths; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePathsBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePathsKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.OlmService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownOutputBuilder; +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.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; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsBuilder; +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; @@ -59,20 +77,44 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest { private PortMapping portMapping; private CrossConnect crossConnect; private NetworkModelWavelengthService networkModelWavelengthService; - private OlmService olmService; + private TransportpceOlmService olmService; + private MappingUtils mappingUtils; + private OpenRoadmInterfacesImpl121 openRoadmInterfacesImpl121; + private OpenRoadmInterfacesImpl221 openRoadmInterfacesImpl221; + private PortMappingVersion221 portMappingVersion22; + private PortMappingVersion121 portMappingVersion121; + private CrossConnectImpl121 crossConnectImpl121; + private CrossConnectImpl221 crossConnectImpl221; private void setMountPoint(MountPoint mountPoint) { MountPointService mountPointService = new MountPointServiceStub(mountPoint); this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000); - this.openRoadmInterfaces = new OpenRoadmInterfacesImpl(this.deviceTransactionManager); - this.portMapping = new PortMappingImpl(this.getDataBroker(), this.deviceTransactionManager, - openRoadmInterfaces); - OpenRoadmInterfaceFactory openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(portMapping, - openRoadmInterfaces); - this.crossConnect = new CrossConnectImpl(this.deviceTransactionManager); + this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager); + this.openRoadmInterfacesImpl221 = new OpenRoadmInterfacesImpl221(deviceTransactionManager); + this.mappingUtils = new MappingUtilsImpl(getDataBroker()); + this.openRoadmInterfaces = new OpenRoadmInterfacesImpl(deviceTransactionManager, mappingUtils, + openRoadmInterfacesImpl121, openRoadmInterfacesImpl221); + this.openRoadmInterfaces = Mockito.spy(this.openRoadmInterfaces); + this.portMappingVersion22 = + new PortMappingVersion221(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces); + this.portMappingVersion121 = + new PortMappingVersion121(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces); + this.portMapping = new PortMappingImpl(getDataBroker(), this.portMappingVersion22, + this.portMappingVersion121); + this.crossConnectImpl121 = new CrossConnectImpl121(deviceTransactionManager); + this.crossConnectImpl221 = new CrossConnectImpl221(deviceTransactionManager); + this.crossConnect = new CrossConnectImpl(deviceTransactionManager, this.mappingUtils, this.crossConnectImpl121, + this.crossConnectImpl221); this.crossConnect = Mockito.spy(crossConnect); + FixedFlexInterface fixedFlexInterface = new FixedFlexImpl(); + OpenRoadmInterface121 openRoadmInterface121 = new OpenRoadmInterface121(portMapping,openRoadmInterfaces); + OpenRoadmInterface221 openRoadmInterface221 = new OpenRoadmInterface221(portMapping,openRoadmInterfaces, + fixedFlexInterface); + OpenRoadmInterfaceFactory openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(this.mappingUtils, + openRoadmInterface121,openRoadmInterface221); + this.deviceRenderer = new DeviceRendererServiceImpl(this.getDataBroker(), - this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect, + this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect, this.portMapping); } @@ -82,10 +124,11 @@ 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, - getDataBroker(), this.networkModelWavelengthService); + getDataBroker(), this.networkModelWavelengthService, notificationPublishService); } @@ -96,63 +139,67 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest { ServiceDeleteInputBuilder serviceDeleteInputBuilder = new ServiceDeleteInputBuilder(); serviceDeleteInputBuilder.setServiceName("service 1"); serviceDeleteInputBuilder.setServiceHandlerHeader((new ServiceHandlerHeaderBuilder()) - .setRequestId("request1").build()); - Mockito.doReturn(true).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(), Mockito.anyString()); + .setRequestId("request1").build()); + Mockito.doReturn(Collections.emptyList()).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(), + Mockito.anyString()); ServiceDeleteOutput serviceDeleteOutput - = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build()); + = 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()); } @Test - public void serviceDeleteOperationNoDescription() { + public void serviceDeleteOperationNoDescription() throws InterruptedException, ExecutionException { ServiceDeleteInputBuilder serviceDeleteInputBuilder = new ServiceDeleteInputBuilder(); serviceDeleteInputBuilder.setServiceName("service 1"); ServiceDeleteOutput serviceDeleteOutput - = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build()); + = 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()); } @Test public void serviceDeleteOperationTearDownFailedAtoZ() throws ExecutionException, InterruptedException { - Mockito.doReturn(true).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(), Mockito.anyString()); + Mockito.doReturn(Collections.emptyList()).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(); serviceDeleteInputBuilder.setServiceName("service 1"); serviceDeleteInputBuilder.setServiceHandlerHeader((new ServiceHandlerHeaderBuilder()) .setRequestId("request1").build()); - ServiceDeleteOutput serviceDeleteOutput + ListenableFuture serviceDeleteOutput = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build()); + ServiceDeleteOutput output = serviceDeleteOutput.get(); Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, - serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode()); + output.getConfigurationResponseCommon().getResponseCode()); 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()); } @Test public void serviceDeleteOperationTearDownFailedZtoA() throws ExecutionException, InterruptedException { - Mockito.doReturn(true).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(), Mockito.anyString()); + Mockito.doReturn(Collections.emptyList()).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()); + 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()); @@ -161,7 +208,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")); @@ -170,10 +217,10 @@ public class RendererServiceOperationsImplDeleteTest extends AbstractTest { InstanceIdentifier 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()); } }