X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=renderer%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Frenderer%2Fprovisiondevice%2FRendererServiceOperationsImplTest.java;h=c169ec5089f3875c829d288e04056a032259f00d;hb=26c22f3f96ad697ddcc3bcce508922b10d7ac9ff;hp=8dac8877fca67fd291a05d6255bd111325c39a43;hpb=be660d35c655920e7385c0185873801d937c286d;p=transportpce.git diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImplTest.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImplTest.java index 8dac8877f..c169ec508 100644 --- a/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImplTest.java +++ b/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImplTest.java @@ -12,7 +12,6 @@ import java.util.List; import java.util.concurrent.ExecutionException; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.mockito.Mockito; import org.opendaylight.mdsal.binding.api.MountPoint; @@ -20,40 +19,24 @@ import org.opendaylight.mdsal.binding.api.MountPointService; import org.opendaylight.mdsal.binding.api.NotificationPublishService; 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.crossconnect.CrossConnectImpl710; 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.PortMappingVersion221; -import org.opendaylight.transportpce.common.mapping.PortMappingVersion710; 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.OpenRoadmInterfacesImpl221; import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl710; -import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterface121; -import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterface221; -import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterface710; -import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory; -import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmOtnInterface221; -import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmOtnInterface710; import org.opendaylight.transportpce.renderer.stub.OlmServiceStub; -import org.opendaylight.transportpce.renderer.utils.MountPointUtils; import org.opendaylight.transportpce.renderer.utils.NotificationPublishServiceMock; import org.opendaylight.transportpce.renderer.utils.ServiceDataUtils; import org.opendaylight.transportpce.test.AbstractTest; import org.opendaylight.transportpce.test.stub.MountPointServiceStub; import org.opendaylight.transportpce.test.stub.MountPointStub; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.ServicePathOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmInput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmInputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmOutput; @@ -61,90 +44,47 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.TransportpceOlmService; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.get.pm.output.Measurements; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.get.pm.output.MeasurementsBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.ServiceImplementationRequestInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.ServiceImplementationRequestOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestOutput; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmGranularity; import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum; import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.olm.get.pm.input.ResourceIdentifierBuilder; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -@Ignore public class RendererServiceOperationsImplTest extends AbstractTest { private MountPointService mountPointService; private DeviceTransactionManager deviceTransactionManager; + private final DeviceRendererService deviceRenderer = Mockito.mock(DeviceRendererService.class); + private final OtnDeviceRendererService otnDeviceRendererService = Mockito.mock(OtnDeviceRendererService.class); + private final PortMapping portMapping = Mockito.mock(PortMapping.class); private RendererServiceOperationsImpl rendererServiceOperations; private OpenRoadmInterfaces openRoadmInterfaces; - private DeviceRendererService deviceRenderer; - private OtnDeviceRendererService otnDeviceRendererService; - private PortMapping portMapping; - private OpenRoadmInterfaceFactory openRoadmInterfaceFactory; - private CrossConnect crossConnect; private TransportpceOlmService olmService; private MappingUtils mappingUtils; private OpenRoadmInterfacesImpl121 openRoadmInterfacesImpl121; private OpenRoadmInterfacesImpl221 openRoadmInterfacesImpl221; private OpenRoadmInterfacesImpl710 openRoadmInterfacesImpl710; - private PortMappingVersion710 portMappingVersion710; - private PortMappingVersion221 portMappingVersion22; - private PortMappingVersion121 portMappingVersion121; - private CrossConnectImpl121 crossConnectImpl121; - private CrossConnectImpl221 crossConnectImpl221; - private CrossConnectImpl710 crossConnectImpl710; private void setMountPoint(MountPoint mountPoint) { this.mountPointService = new MountPointServiceStub(mountPoint); this.deviceTransactionManager = new DeviceTransactionManagerImpl(this.mountPointService, 3000); - this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager); - this.openRoadmInterfacesImpl221 = new OpenRoadmInterfacesImpl221(deviceTransactionManager); - this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager); this.mappingUtils = new MappingUtilsImpl(getDataBroker()); this.openRoadmInterfaces = new OpenRoadmInterfacesImpl(deviceTransactionManager, mappingUtils, openRoadmInterfacesImpl121, openRoadmInterfacesImpl221, openRoadmInterfacesImpl710); this.openRoadmInterfaces = Mockito.spy(this.openRoadmInterfaces); - this.portMappingVersion22 = - new PortMappingVersion221(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces); - this.portMappingVersion121 = - new PortMappingVersion121(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces); - this.portMappingVersion710 = - new PortMappingVersion710(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces); - this.portMapping = new PortMappingImpl(getDataBroker(), this.portMappingVersion710, this.portMappingVersion22, - this.portMappingVersion121); - OpenRoadmInterface121 openRoadmInterface121 = new OpenRoadmInterface121(portMapping,openRoadmInterfaces); - OpenRoadmInterface221 openRoadmInterface221 = new OpenRoadmInterface221(portMapping,openRoadmInterfaces); - OpenRoadmInterface710 openRoadmInterface710 = new OpenRoadmInterface710(portMapping,openRoadmInterfaces); - OpenRoadmOtnInterface221 openRoadmOTNInterface221 = new OpenRoadmOtnInterface221(portMapping, - openRoadmInterfaces); - OpenRoadmOtnInterface710 openRoadmOtnInterface710 = new OpenRoadmOtnInterface710(portMapping, - openRoadmInterfaces); - this.openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(this.mappingUtils,openRoadmInterface121, - openRoadmInterface221, openRoadmInterface710, openRoadmOTNInterface221, openRoadmOtnInterface710); - this.crossConnectImpl121 = new CrossConnectImpl121(deviceTransactionManager); - this.crossConnectImpl221 = new CrossConnectImpl221(deviceTransactionManager); - this.crossConnect = new CrossConnectImpl(deviceTransactionManager, this.mappingUtils, this.crossConnectImpl121, - this.crossConnectImpl221, this.crossConnectImpl710); } @Before public void setUp() throws OpenRoadmInterfaceException { setMountPoint(new MountPointStub(getDataBroker())); this.olmService = new OlmServiceStub(); - this.deviceRenderer = new DeviceRendererServiceImpl(getDataBroker(), this.deviceTransactionManager, - openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect, portMapping, null); - this.otnDeviceRendererService = new OtnDeviceRendererServiceImpl(openRoadmInterfaceFactory, this.crossConnect, - openRoadmInterfaces, this.deviceTransactionManager, null); Mockito.doNothing().when(this.openRoadmInterfaces).postEquipmentState(Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean()); NotificationPublishService notificationPublishService = new NotificationPublishServiceMock(); this.olmService = Mockito.spy(this.olmService); - this.deviceRenderer = Mockito.spy(this.deviceRenderer); - this.rendererServiceOperations = new RendererServiceOperationsImpl(this.deviceRenderer, - this.otnDeviceRendererService, this.olmService, getDataBroker(), notificationPublishService, null); - - ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success") - .setSuccess(true); - Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(), - Mockito.any()); + this.rendererServiceOperations = new RendererServiceOperationsImpl(deviceRenderer, + otnDeviceRendererService, this.olmService, getDataBroker(), notificationPublishService, portMapping); } @Test @@ -152,7 +92,6 @@ public class RendererServiceOperationsImplTest extends AbstractTest { ServiceImplementationRequestInput input = ServiceDataUtils .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.TTP_TOKEN); - writePortMapping(input, StringConstants.TTP_TOKEN); ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success") .setSuccess(true); Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(), @@ -167,7 +106,6 @@ public class RendererServiceOperationsImplTest extends AbstractTest { ServiceImplementationRequestInput input = ServiceDataUtils .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.TTP_TOKEN); - writePortMapping(input, StringConstants.TTP_TOKEN); ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success") .setSuccess(true); Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(), @@ -184,7 +122,6 @@ public class RendererServiceOperationsImplTest extends AbstractTest { ServiceImplementationRequestInput input = ServiceDataUtils .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.PP_TOKEN); - writePortMapping(input, StringConstants.PP_TOKEN); ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success") .setSuccess(true); Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(), @@ -196,11 +133,10 @@ public class RendererServiceOperationsImplTest extends AbstractTest { @Test public void serviceImplementationTerminationPointAsResourceNetwork() - throws InterruptedException, ExecutionException { + throws InterruptedException, ExecutionException { ServiceImplementationRequestInput input = ServiceDataUtils .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); - writePortMapping(input, StringConstants.NETWORK_TOKEN); ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success") .setSuccess(true); Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(), @@ -212,20 +148,21 @@ public class RendererServiceOperationsImplTest extends AbstractTest { @Test public void serviceImplementationTerminationPointAsResourceClient() - throws InterruptedException, ExecutionException { + throws InterruptedException, ExecutionException { ServiceImplementationRequestInput input = ServiceDataUtils - // .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.CLIENT_TOKEN); .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.CLIENT_TOKEN); - // writePortMapping(input, OpenRoadmInterfacesImpl.CLIENT_TOKEN); - writePortMapping(input, StringConstants.CLIENT_TOKEN); + ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success") + .setSuccess(true); + Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(), + Mockito.any()); ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get(); Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode()); } @Test public void serviceImplementationTerminationPointAsResourceNoMapping() - throws InterruptedException, ExecutionException { + throws InterruptedException, ExecutionException { String[] interfaceTokens = { StringConstants.NETWORK_TOKEN, @@ -249,37 +186,12 @@ public class RendererServiceOperationsImplTest extends AbstractTest { } } - private void writePortMapping(ServiceImplementationRequestInput input, String tpToken) { - MountPointUtils.writeMapping( - input.getServiceAEnd().getNodeId(), - input.getServiceAEnd().getNodeId() + "-" + tpToken, - this.deviceTransactionManager - ); - MountPointUtils.writeMapping( - input.getServiceZEnd().getNodeId(), - input.getServiceZEnd().getNodeId() + "-" - + input.getServiceAEnd().getNodeId() + "-" + tpToken, - this.deviceTransactionManager - ); - MountPointUtils.writeMapping( - input.getServiceAEnd().getNodeId(), - input.getServiceAEnd().getNodeId() + "-" - + input.getServiceZEnd().getNodeId() + "-" + tpToken, - this.deviceTransactionManager - ); - MountPointUtils.writeMapping( - input.getServiceZEnd().getNodeId(), - input.getServiceZEnd().getNodeId() + "-" + tpToken, - this.deviceTransactionManager - ); - } - @Test public void serviceImplementationRollbackAllNecessary() throws InterruptedException, ExecutionException { ServiceImplementationRequestInput input = ServiceDataUtils .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); - writePortMapping(input, StringConstants.NETWORK_TOKEN); +// writePortMapping(input, StringConstants.NETWORK_TOKEN); Mockito.doReturn(RpcResultBuilder.failed().buildFuture()).when(this.olmService) .servicePowerSetup(Mockito.any()); ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get(); @@ -303,7 +215,6 @@ public class RendererServiceOperationsImplTest extends AbstractTest { ServiceImplementationRequestInput input = ServiceDataUtils .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); - writePortMapping(input, StringConstants.NETWORK_TOKEN); Measurements measurements = new MeasurementsBuilder().setPmparameterName("FECUncorrectableBlocks") .setPmparameterValue("1").build(); List measurementsList = new ArrayList(); @@ -322,15 +233,12 @@ public class RendererServiceOperationsImplTest extends AbstractTest { ServiceImplementationRequestInput input = ServiceDataUtils .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); - writePortMapping(input, StringConstants.NETWORK_TOKEN); Measurements measurements = new MeasurementsBuilder().setPmparameterName("FECUncorrectableBlocks") .setPmparameterValue("1").build(); List measurementsList = new ArrayList(); measurementsList.add(measurements); GetPmOutput getPmOutput = new GetPmOutputBuilder() .setNodeId("node1").setMeasurements(measurementsList).build(); - GetPmOutput getPmOutput2 = new GetPmOutputBuilder() - .setNodeId("node1").setMeasurements(new ArrayList<>()).build(); Mockito.when(this.olmService.getPm(Mockito.any())) .thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture()); @@ -342,9 +250,6 @@ public class RendererServiceOperationsImplTest extends AbstractTest { @Test public void serviceImplementationServiceInActive3() throws InterruptedException, ExecutionException { - ServiceImplementationRequestInput input = ServiceDataUtils - .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); - writePortMapping(input, StringConstants.NETWORK_TOKEN); Measurements measurements = new MeasurementsBuilder().setPmparameterName("FECUncorrectableBlocks") .setPmparameterValue("1").build(); List measurementsList = new ArrayList(); @@ -363,6 +268,12 @@ public class RendererServiceOperationsImplTest extends AbstractTest { .thenReturn(RpcResultBuilder.success(getPmOutput2).buildFuture()); Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputA))) .thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture()); + ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success") + .setSuccess(true); + Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(), + Mockito.any()); + ServiceImplementationRequestInput input = ServiceDataUtils + .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get(); Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode()); @@ -373,9 +284,6 @@ public class RendererServiceOperationsImplTest extends AbstractTest { ServiceImplementationRequestInput input = ServiceDataUtils .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); - writePortMapping(input, StringConstants.NETWORK_TOKEN); - GetPmOutput getPmOutput = new GetPmOutputBuilder() - .setNodeId("node1").setMeasurements(new ArrayList<>()).build(); GetPmOutput getPmOutput1 = null; Mockito.when(this.olmService.getPm(Mockito.any())).thenReturn(RpcResultBuilder.success(getPmOutput1) .buildFuture()); @@ -393,7 +301,6 @@ public class RendererServiceOperationsImplTest extends AbstractTest { ServiceImplementationRequestInput input = ServiceDataUtils .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); - writePortMapping(input, StringConstants.NETWORK_TOKEN); GetPmOutput getPmOutput = new GetPmOutputBuilder().setMeasurements(new ArrayList<>()).build(); Mockito.when(this.olmService.getPm(Mockito.any())).thenReturn(RpcResultBuilder.success(getPmOutput) .buildFuture()); @@ -409,9 +316,6 @@ public class RendererServiceOperationsImplTest extends AbstractTest { @Test public void serviceImplementationServiceInActive4() throws InterruptedException, ExecutionException { - ServiceImplementationRequestInput input = ServiceDataUtils - .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); - writePortMapping(input, StringConstants.NETWORK_TOKEN); Measurements measurements = new MeasurementsBuilder().setPmparameterName("preFECCorrectedErrors") .setPmparameterValue("1").build(); List measurementsList = new ArrayList(); @@ -425,6 +329,8 @@ public class RendererServiceOperationsImplTest extends AbstractTest { .setSuccess(true); Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(), Mockito.any()); + ServiceImplementationRequestInput input = ServiceDataUtils + .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get(); Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode()); @@ -435,7 +341,6 @@ public class RendererServiceOperationsImplTest extends AbstractTest { ServiceImplementationRequestInput input = ServiceDataUtils .buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN); - writePortMapping(input, StringConstants.NETWORK_TOKEN); Measurements measurements = new MeasurementsBuilder().setPmparameterName("preFECCorrectedErrors") .setPmparameterValue("112000000000d").build(); List measurementsList = new ArrayList();