diff options
author | Gamboa, Gilbert <gilbert.g.gamboa@att.com> | 2019-06-06 14:23:36 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-06-06 15:38:14 -0400 |
commit | 62b2e47808fe1adcbac31dbcdf992617b7f0bd4d (patch) | |
tree | 6fbdcf652784be141c869259f2c2919d2a7ce378 /bpmn/MSOCommonBPMN/src/test/java | |
parent | c4b90365d5c117bc6fd64af421a1468539a8aec3 (diff) |
Accommodate WAN Networking
checked and evaluated naming policy only if infra bonding.
Updated workflowAction to include vrf configuration for vpn-binding in
resourceIds list.
added in linked resource to service proxy cust
committing the asdc controller classpath change
added some unit tests for vrf validation and updated bbinput setup test
update config resource cust foreign key mapping
Moved mockbean for AssignVrfConfiguration task class into BaseBpmnTest.
added in a check to see if list is empty before access
added unit tests for bbinput setup for vrf config
Update AssignFlows enum with correct AssignVrfConfiguration flow name
Change-Id: Ibf14e36505638b19c1366ecebfce560c02e69e44
Issue-ID: SO-1975
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test/java')
3 files changed, 163 insertions, 8 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java index 3bb417741f..9e10058ec8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java @@ -247,6 +247,7 @@ public class BuildingBlockTestDataSetup { modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter); configuration.setModelInfoConfiguration(modelInfoConfiguration); + configuration.setVpnBinding(buildVpnBinding()); return configuration; } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java new file mode 100644 index 0000000000..bcee62013f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java @@ -0,0 +1,47 @@ +package org.onap.so.bpmn.servicedecomposition.bbobjects.wrappers; + +import static org.junit.Assert.assertEquals; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.wrappers.exceptions.ServiceProxyNotFoundException; + +public class ServiceInstanceWrapperTest { + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Test + public void getTransportServiceProxyTest() throws ServiceProxyNotFoundException { + ServiceInstance si = buildServiceInstance(); + si.getServiceProxies().add(buildServiceProxy()); + ServiceInstanceWrapper sw = new ServiceInstanceWrapper(si); + ServiceProxy sp = sw.getTransportServiceProxy(); + assertEquals("sp-001", sp.getId()); + assertEquals("transport", sp.getType()); + } + + @Test + public void getTransportServiceProxyExceptionTest() throws ServiceProxyNotFoundException { + expectedException.expect(ServiceProxyNotFoundException.class); + ServiceInstanceWrapper sw = new ServiceInstanceWrapper(buildServiceInstance()); + sw.getTransportServiceProxy(); + } + + private ServiceInstance buildServiceInstance() { + ServiceInstance si = new ServiceInstance(); + si.setServiceInstanceId("si-001"); + si.setServiceInstanceName("Test SI"); + return si; + } + + private ServiceProxy buildServiceProxy() { + ServiceProxy sp = new ServiceProxy(); + sp.setId("sp-001"); + sp.setType("transport"); + return sp; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index ad1918e6da..787957dc38 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -65,6 +65,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; @@ -82,6 +83,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.client.aai.AAICommonObjectMapperProvider; import org.onap.so.client.aai.AAIObjectType; @@ -94,14 +96,15 @@ import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.ConfigurationResource; import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; +import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.InstanceGroupType; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.serviceinstancebeans.CloudConfiguration; @@ -1231,19 +1234,19 @@ public class BBInputSetupTest { configResourceKeys.setVnfcName(vnfcName); Vnfc vnfc = new Vnfc(); vnfc.setVnfcName(vnfcName); - + RequestDetails requestDetails = new RequestDetails(); doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName); SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - instanceName, configResourceKeys); + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, null); SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - instanceName, configResourceKeys); + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(2)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); @@ -1255,7 +1258,7 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys); SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - instanceName, configResourceKeys); + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys); } @@ -1307,6 +1310,7 @@ public class BBInputSetupTest { configResourceKeys.setVnfcName(vnfcName); Vnfc vnfc = new Vnfc(); vnfc.setVnfcName(vnfcName); + RequestDetails requestDetails = new RequestDetails(); CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization(); @@ -1319,7 +1323,7 @@ public class BBInputSetupTest { doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName); SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - instanceName, configResourceKeys); + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); } @@ -1972,14 +1976,117 @@ public class BBInputSetupTest { configurationCustList.add(configurationCust); doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), - isA(ConfigurationResourceKeys.class)); + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); executeBB.getBuildingBlock().setBpmnFlowName("AssignFabricConfigurationBB"); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), - isA(ConfigurationResourceKeys.class)); + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + + + } + + @Test + public void testGBBMacroNoUserParamsVrfConfiguration() throws Exception { + GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), + GeneralBuildingBlock.class); + ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), + ExecuteBuildingBlock.class); + RequestDetails requestDetails = mapper + .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacroVrf.json"), RequestDetails.class); + InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId"); + lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId"); + String resourceId = "123"; + String vnfType = "vnfType"; + Service service = Mockito.mock(Service.class); + String requestAction = "createInstance"; + + ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys(); + configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID"); + configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID"); + configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID"); + executeBB.setConfigurationResourceKeys(configResourceKeys); + + executeBB.setRequestDetails(requestDetails); + doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, + requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID)); + doReturn(service).when(SPY_bbInputSetupUtils) + .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid()); + + RelatedInstance relatedVpnBinding = new RelatedInstance(); + relatedVpnBinding.setInstanceId("vpnBindingInstanceId"); + RelatedInstance relatedLocalNetwork = new RelatedInstance(); + relatedLocalNetwork.setInstanceId("localNetworkInstanceId"); + org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = new org.onap.aai.domain.yang.VpnBinding(); + aaiVpnBinding.setVpnId("vpnBindingId"); + org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network(); + aaiLocalNetwork.setNetworkId("localNetworkId"); + Optional<org.onap.aai.domain.yang.VpnBinding> aaiAICVpnBindingOp = + Optional.of(new org.onap.aai.domain.yang.VpnBinding()); + aaiAICVpnBindingOp.get().setVpnId("AICVpnBindingId"); + ServiceProxy proxy = new ServiceProxy(); + proxy.setType("transport"); + proxy.setServiceInstance(new ServiceInstance()); + proxy.getServiceInstance().setModelInfoServiceInstance(new ModelInfoServiceInstance()); + proxy.getServiceInstance().getModelInfoServiceInstance().setModelUuid("sourceServiceModelUUID"); + doReturn(relatedVpnBinding).when(SPY_bbInputSetupUtils).getRelatedInstanceByType(requestDetails, + ModelType.vpnBinding); + doReturn(relatedLocalNetwork).when(SPY_bbInputSetupUtils).getRelatedInstanceByType(requestDetails, + ModelType.network); + doReturn(aaiVpnBinding).when(SPY_bbInputSetupUtils).getAAIVpnBinding(relatedVpnBinding.getInstanceId()); + doReturn(aaiLocalNetwork).when(SPY_bbInputSetupUtils).getAAIL3Network(relatedLocalNetwork.getInstanceId()); + doReturn(aaiAICVpnBindingOp).when(SPY_bbInputSetupUtils).getAICVpnBindingFromNetwork(aaiLocalNetwork); + doReturn(proxy).when(SPY_bbInputSetup).getServiceProxy(service); + + Configuration configuration = new Configuration(); + configuration.setConfigurationId("configurationId"); + gBB.getServiceInstance().getConfigurations().add(configuration); + List<ConfigurationResourceCustomization> configurationCustList = new ArrayList<>(); + ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization(); + configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); + configurationCustList.add(configurationCust); + doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + + executeBB.getBuildingBlock().setBpmnFlowName("AssignVrfConfigurationBB"); + executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); + gBB = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); + verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + assertEquals(gBB.getCustomer().getVpnBindings().get(0).getVpnId(), "vpnBindingId"); + assertEquals(gBB.getServiceInstance().getNetworks().get(0).getNetworkId(), "localNetworkId"); + assertEquals(gBB.getServiceInstance().getNetworks().get(0).getVpnBindings().get(0).getVpnId(), + "AICVpnBindingId"); + assertEquals(gBB.getServiceInstance().getServiceProxies().get(0).getType(), "transport"); + } + + @Test + public void testGetServiceProxy() { + ServiceProxy expected = new ServiceProxy(); + expected.setType("TRANSPORT"); + expected.setModelInfoServiceProxy(new ModelInfoServiceProxy()); + expected.getModelInfoServiceProxy().setModelCustomizationUuid("modelCustomizationUUID"); + expected.setServiceInstance(new ServiceInstance()); + expected.getServiceInstance().setModelInfoServiceInstance(new ModelInfoServiceInstance()); + expected.getServiceInstance().getModelInfoServiceInstance().setModelUuid("modelUUID"); + expected.getServiceInstance().getModelInfoServiceInstance().setServiceType("TRANSPORT"); + Service service = new Service(); + ServiceProxyResourceCustomization serviceProxyCatalog = new ServiceProxyResourceCustomization(); + serviceProxyCatalog.setModelCustomizationUUID("modelCustomizationUUID"); + Service sourceService = new Service(); + sourceService.setModelUUID("modelUUID"); + sourceService.setServiceType("TRANSPORT"); + serviceProxyCatalog.setSourceService(sourceService); + service.setServiceProxyCustomizations(new ArrayList<ServiceProxyResourceCustomization>()); + service.getServiceProxyCustomizations().add(serviceProxyCatalog); + ServiceProxy actual = SPY_bbInputSetup.getServiceProxy(service); + assertThat(actual, sameBeanAs(expected)); } @Test |