diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-10-11 13:55:37 -0400 |
---|---|---|
committer | Rob Daugherty <rd472p@att.com> | 2018-10-12 10:10:16 -0400 |
commit | 6ba0a22bc952232d14d2d24c5f73a42aae2791a9 (patch) | |
tree | 9046e63bccb77ca3e2df4ae7ceab44cc238dd074 /bpmn/so-bpmn-tasks/src | |
parent | 58c1d90a787979e507f559d7075aac8a1428df42 (diff) |
Dynamic Cloud Owner Support
added in cloud configuration object to request params
Fix Bean scanning so it picks up the resttemplate
removed unnecessary RestTemplate Bean configurations
corrected typo in CloudConfiguration class
updated gr api test cases with dynamic cloud owner
updated groovy files to allow for dynamic cloud owner values
updated GR API layer to include cloud owner
added enum for default cloud owner
add cloud owner variable to camunda in mapping
removed references to att-aic from BBInputSetup
updated aai schema dependency to 1.3.1 from 1.3.0
Fixed incorrect type AAIUri and updated logging in the method.
use existing service instance id instead of generating
Pass cloudOwner to process to propagate to subprocesses.
NOTE: our aai-schema dependency is 1.3.1-SNAPSHOT to be
compatible with the cloud owner changes here. The
releaesed 1.3.0 version is NOT compatible.
Change-Id: I43b46774b77981d1c8bfe7c7a79b9434889e62ae
Issue-ID: SO-1128
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
16 files changed, 406 insertions, 59 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java index 7bc48519b0..0190f3df56 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,6 +29,7 @@ import java.util.UUID; import org.apache.commons.lang.SerializationUtils; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; import org.json.JSONArray; import org.json.JSONObject; import org.onap.so.bpmn.common.BuildingBlockExecution; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java index bf429ee4fc..534e93637a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java @@ -29,6 +29,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIInstanceGroupResources; import org.springframework.beans.factory.annotation.Autowired; @@ -55,10 +56,10 @@ public class AssignVnf { if(ModelInfoInstanceGroup.TYPE_VNFC.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { instanceGroup.setInstanceGroupName(aaiObjectInstanceNameGenerator.generateInstanceGroupName(instanceGroup, vnf)); aaiInstanceGroupResources.createInstanceGroup(instanceGroup); - aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf); + aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO); } else if(ModelInfoInstanceGroup.TYPE_NETWORK_INSTANCE_GROUP.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { - aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf); + aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.USES); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index e7d09f83e0..724dea6cf5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -104,6 +104,7 @@ public class WorkflowAction { private static final String USERPARAMSERVICE = "service"; private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances"; private static final String HOMINGSOLUTION = "Homing_Solution"; + private static final String FABRIC_CONFIGURATION = "FabricConfiguration"; private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @Autowired @@ -177,6 +178,7 @@ public class WorkflowAction { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte); } + orchFlows = filterOrchFlows(orchFlows, resourceType, execution); String key = ""; ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo(); if(modelInfo.getModelType().equals(ModelType.service)) { @@ -238,7 +240,7 @@ public class WorkflowAction { && (requestAction.equalsIgnoreCase("activateInstance") || requestAction.equalsIgnoreCase("unassignInstance") || requestAction.equalsIgnoreCase("deleteInstance") - || requestAction.equalsIgnoreCase("activateFabricConfiguration"))) { + || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) { // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and // SERVICE-MACRO-DELETE // Will never get user params with service, macro will have @@ -619,13 +621,13 @@ public class WorkflowAction { } - private List<String> traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) { + protected List<String> traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) { List<String> configurations = new ArrayList<>(); try{ List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(vnfCustomizationUUID, vfModuleCustomizationUUID); for(CvnfcCustomization cvnfc : cvnfcCustomizations){ for(VnfVfmoduleCvnfcConfigurationCustomization customization : cvnfc.getVnfVfmoduleCvnfcConfigurationCustomization()){ - if(customization.getConfigurationResource().getToscaNodeType().contains("FabricConfiguration")){ + if(customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)){ configurations.add(customization.getConfigurationResource().getModelUUID()); } } @@ -964,6 +966,17 @@ public class WorkflowAction { } return listToExecute; } + + protected List<OrchestrationFlow> filterOrchFlows(List<OrchestrationFlow> orchFlows, WorkflowType resourceType, DelegateExecution execution) { + List<OrchestrationFlow> result = new ArrayList<>(orchFlows); + if (resourceType.equals(WorkflowType.VFMODULE)) { + List<String> fabricCustomizations = traverseCatalogDbForConfiguration((String)execution.getVariable("vnfId"), (String)execution.getVariable("vfModuleId")); + if (fabricCustomizations.isEmpty()) { + result = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList()); + } + } + return result; + } protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { logger.error(msg, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 2b58b7bdd7..81c2107328 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -23,15 +23,18 @@ package org.onap.so.client.adapter.vnf.mapper; import static java.util.Arrays.asList; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; import javax.annotation.PostConstruct; -import javax.validation.Valid; import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; @@ -303,6 +306,9 @@ public class VnfAdapterVfModuleObjectMapper { buildVfModuleSriovParameters(paramsMap, network, networkKey); // IPV4 and IPV6 Addresses buildVfModuleNetworkInformation(paramsMap, network, key, networkKey); + + buildVlanInformation(paramsMap, network, key, networkKey); + } } } @@ -315,6 +321,36 @@ public class VnfAdapterVfModuleObjectMapper { } } + protected void buildVlanInformation(Map<String, String> paramsMap, + GenericResourceApiVmNetworkData network, String key, String networkKey) { + + String networkString = convertToString(network); + String vlanFilterKey = key + UNDERSCORE + networkKey + UNDERSCORE + "vlan_filter"; + String privateVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "private_vlans"; + String publicVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "public_vlans"; + String guestVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "guest_vlans"; + + if (network.getSegmentationId() != null) { + paramsMap.put(vlanFilterKey, network.getSegmentationId()); + } + + List<String> privateVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == true)].vlan-tags.upper-tag-id"); + List<String> publicVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == false)].vlan-tags.upper-tag-id"); + List<String> concat = new ArrayList<>(privateVlans); + concat.addAll(publicVlans); + Collection<String> guestVlans = new HashSet<>(concat); + + if (!privateVlans.isEmpty()) { + paramsMap.put(privateVlansKey, Joiner.on(",").join(privateVlans)); + } + if (!publicVlans.isEmpty()) { + paramsMap.put(publicVlansKey, Joiner.on(",").join(publicVlans)); + } + if (!guestVlans.isEmpty()) { + paramsMap.put(guestVlansKey, Joiner.on(",").join(guestVlans)); + } + } + private void buildVfModuleVmNames(Map<String,String> paramsMap, GenericResourceApiVmTopologyData vm, String key) { String values = ""; GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java index 4c4edb7fe9..68f6e8ffa2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java @@ -26,6 +26,7 @@ import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @@ -57,6 +58,12 @@ public class AAIInstanceGroupResources { injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI); } + public void connectInstanceGroupToVnf(InstanceGroup instanceGroup, GenericVnf vnf, AAIEdgeLabel aaiLabel) { + AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI, aaiLabel); + } + public boolean exists(InstanceGroup instanceGroup) { AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); return injectionHelper.getAaiClient().exists(instanceGroupUri); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java index b5738dcb40..86dd22b65c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java @@ -107,7 +107,7 @@ public class AAIServiceInstanceResources { } public boolean existsOwningEntityName(String owningEntityName) { - AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITIES).queryParam("owning-entity-name", owningEntityName); + AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY).queryParam("owning-entity-name", owningEntityName); AAIResourcesClient aaiRC = injectionHelper.getAaiClient(); return aaiRC.exists(owningEntityUri); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java index 8bd55f0f90..092af30558 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,6 +28,7 @@ import org.onap.aai.domain.yang.VpnBindings; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; @@ -39,10 +40,10 @@ import org.springframework.stereotype.Component; public class AAIVpnBindingResources { @Autowired private InjectionHelper injectionHelper; - + @Autowired private AAIObjectMapper aaiObjectMapper; - + /** * @param customer */ @@ -56,10 +57,10 @@ public class AAIVpnBindingResources { * @return */ public Optional<VpnBindings> getVpnBindingByCustomerVpnId (String customerVpnId) { - AAIResourceUri aaiVpnBindingsResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDINGS) + AAIResourceUri aaiVpnBindingsResourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VPN_BINDING) .queryParam("customer-vpn-id",customerVpnId); - return injectionHelper.getAaiClient().get(VpnBindings.class,aaiVpnBindingsResourceUri); - + return injectionHelper.getAaiClient().get(VpnBindings.class,aaiVpnBindingsResourceUri); + } /** diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java index 432399b1b8..3975b25356 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java @@ -86,8 +86,8 @@ public class GeneralTopologyObjectMapper { networkInformation.setFromPreload(null); networkInformation.setNetworkId(network.getNetworkId()); - //TODO fix this after network type filed included in L3Network object type - //networkInformation.setNetworkType(network.getNetwork); + networkInformation.setNetworkType(network.getNetworkType()); + networkInformation.setNetworkTechnology(network.getNetworkTechnology()); return networkInformation; } /* diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java index 8944d1eaa4..1355151919 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -71,7 +71,7 @@ public class VnfTopologyOperationRequestMapper { vnfRequestInput.setTenant(cloudRegion.getTenantId()); vnfRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); - + if (StringUtils.isNotBlank(vnf.getVnfName())) { vnfRequestInput.setVnfName(vnf.getVnfName()); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java index e1b652a140..8382b9be72 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java @@ -33,6 +33,7 @@ import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.springframework.beans.factory.annotation.Autowired; public class AssignVnfTest extends BaseTaskTest { @@ -87,10 +88,10 @@ public class AssignVnfTest extends BaseTaskTest { assignVnf.createInstanceGroups(execution); verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup1); verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup2); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup1, genericVnf); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup2, genericVnf); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup3, genericVnf); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup4, genericVnf); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup1, genericVnf, AAIEdgeLabel.BELONGS_TO); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup2, genericVnf, AAIEdgeLabel.BELONGS_TO); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup3, genericVnf, AAIEdgeLabel.USES); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup4, genericVnf, AAIEdgeLabel.USES); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java new file mode 100644 index 0000000000..b818b07c1f --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java @@ -0,0 +1,158 @@ +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIConfigurationResources; +import org.onap.so.db.catalog.beans.ConfigurationResource; +import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; +import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; +import org.onap.so.db.catalog.client.CatalogDbClient; + +@RunWith(MockitoJUnitRunner.class) +public class WorkflowActionUnitTest { + + private final static String JSON_FILE_LOCATION = "src/test/resources/__files/Macro/"; + + @Mock + private CatalogDbClient catalogDbClient; + @Mock + private BBInputSetup bbInputSetup; + @Mock + private BBInputSetupUtils bbInputSetupUtils; + @Mock + private ExceptionBuilder exceptionBuilder; + @Mock + private AAIConfigurationResources aaiConfigurationResources; + + @InjectMocks + @Spy + private WorkflowAction workflowAction; + + @Test + public void filterOrchFlowsHasFabricTest() { + + List<OrchestrationFlow> flows = createFlowList( + "DeactivateFabricConfigurationBB", + "flow x", + "flow y", + "ActivateFabricConfigurationBB", + "flow z"); + doReturn(Arrays.asList("yes", "yes")).when(workflowAction).traverseCatalogDbForConfiguration(any(String.class), any(String.class)); + + List<OrchestrationFlow> result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class)); + + assertThat(result, is(flows)); + } + + @Test + public void filterOrchFlowNoFabricTest() { + List<OrchestrationFlow> flows = createFlowList( + "DeactivateFabricConfigurationBB", + "flow x", + "flow y", + "ActivateFabricConfigurationBB", + "flow z"); + doReturn(Arrays.asList()).when(workflowAction).traverseCatalogDbForConfiguration(any(String.class), any(String.class)); + + List<OrchestrationFlow> result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class)); + List<OrchestrationFlow> expected = createFlowList( + "flow x", + "flow y", + "flow z"); + + assertThat(result, is(expected)); + } + + @Test + public void traverseCatalogDbForConfigurationTest() { + + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + VnfVfmoduleCvnfcConfigurationCustomization vfModuleCustomization = new VnfVfmoduleCvnfcConfigurationCustomization(); + ConfigurationResource configuration = new ConfigurationResource(); + configuration.setToscaNodeType("FabricConfiguration"); + configuration.setModelUUID("my-uuid"); + vfModuleCustomization.setConfigurationResource(configuration); + cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(Collections.singleton(vfModuleCustomization)); + List<CvnfcCustomization> cvnfcCustomizations = Arrays.asList(cvnfcCustomization); + when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(any(String.class), any(String.class))) + .thenReturn(cvnfcCustomizations); + + List<String> results = workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId"); + + assertThat(results, is(Arrays.asList("my-uuid"))); + + } + + @Test + public void verifyFilterOrchInvocation() throws Exception { + DelegateExecution execution = mock(DelegateExecution.class); + + when(execution.getVariable(eq("aLaCarte"))).thenReturn(true); + when(execution.getVariable(eq("bpmnRequest"))).thenReturn(getJson("ServiceMacroAssign.json")); + when(execution.getVariable(eq("requestUri"))).thenReturn("/v6/serviceInstances/123/vnfs/1234"); + + OrchestrationFlow flow = new OrchestrationFlow(); + flow.setFlowName("flow x"); + + List<OrchestrationFlow> flows = Arrays.asList(flow); + doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean()); + workflowAction.selectExecutionList(execution); + + verify(workflowAction, times(1)).filterOrchFlows(eq(flows), any(), any()); + + flow = new OrchestrationFlow(); + flow.setFlowName("flow y"); + flows = Arrays.asList(flow); + when(execution.getVariable(eq("aLaCarte"))).thenReturn(false); + workflowAction.selectExecutionList(execution); + + verify(workflowAction, never()).filterOrchFlows(eq(flows), any(), any()); + + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename))); + } + + private List<OrchestrationFlow> createFlowList(String... myList) { + + List<OrchestrationFlow> result = new ArrayList<>(); + for (String name : myList) { + OrchestrationFlow flow = new OrchestrationFlow(); + flow.setFlowName(name); + result.add(flow); + } + + return result; + + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java index 0c9e281fc7..a68afd811a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java @@ -22,17 +22,20 @@ package org.onap.so.client.adapter.vnf.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashMap; +import java.util.Map; import org.junit.Before; import org.junit.Test; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVmNetworkData; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; @@ -770,4 +773,18 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); } + + @Test + public void networkCloudParamsTest() throws IOException { + + String json = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "grApiVmNetworkSubSectionWith5GParams.json"))); + GenericResourceApiVmNetworkData network = omapper.readValue(json, GenericResourceApiVmNetworkData.class); + Map<String, String> paramsMap = new HashMap<>(); + vfModuleObjectMapper.buildVlanInformation(paramsMap, network, "testKey", "testType"); + + assertEquals("1,3", paramsMap.get("testKey_testType_private_vlans")); + assertEquals("2,3", paramsMap.get("testKey_testType_public_vlans")); + assertEquals("1,2,3", paramsMap.get("testKey_testType_guest_vlans")); + assertEquals("my-segemntation-id", paramsMap.get("testKey_testType_vlan_filter")); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java index aef25e5ded..621e275fdf 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java @@ -40,6 +40,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @RunWith(MockitoJUnitRunner.class) @@ -87,6 +88,12 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup{ } @Test + public void connectInstanceGroupWithEdgeTest() throws Exception { + aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO); + verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())), eq(AAIEdgeLabel.BELONGS_TO)); + } + + @Test public void existsTest() throws Exception { aaiInstanceGroupResources.exists(instanceGroup); verify(MOCK_aaiResourcesClient, times(1)).exists(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()))); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java index 298a3de9ba..ba7dc8d618 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java @@ -20,9 +20,11 @@ package org.onap.so.client.sdnc.mapper; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; import java.util.HashMap; @@ -32,28 +34,31 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InjectMocks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; - -public class GeneralTopologyObjectMapperTest extends TestDataSetup{ +public class GeneralTopologyObjectMapperTest extends TestDataSetup { @InjectMocks private GeneralTopologyObjectMapper genObjMapper = new GeneralTopologyObjectMapper(); @@ -222,4 +227,55 @@ public class GeneralTopologyObjectMapperTest extends TestDataSetup{ assertEquals(vnf.getVnfId(),gcRequestInput.getVnfId()); assertNotNull(gcRequestInput.getVnfId()); } + + @Test + public void buildNetworkInformationTest() { + + L3Network network = new L3Network(); + ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); + modelInfoNetwork.setModelInvariantUUID("my-uuid"); + modelInfoNetwork.setModelName("my-model-name"); + modelInfoNetwork.setModelVersion("my-model-version"); + modelInfoNetwork.setModelUUID("my-model-uuid"); + modelInfoNetwork.setModelCustomizationUUID("my-customization-uuid"); + network.setModelInfoNetwork(modelInfoNetwork); + network.setNetworkId("my-network-id"); + network.setNetworkType("my-network-type"); + network.setNetworkTechnology("my-network-technology"); + + GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation(); + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation(); + networkInformation.setNetworkId("my-network-id"); + networkInformation.setNetworkType("my-network-type"); + networkInformation.networkTechnology("my-network-technology"); + networkInformation.setFromPreload(null); + onapModelInformation.setModelInvariantUuid("my-uuid"); + onapModelInformation.setModelName("my-model-name"); + onapModelInformation.setModelVersion("my-model-version"); + onapModelInformation.setModelUuid("my-model-uuid"); + onapModelInformation.setModelCustomizationUuid("my-customization-uuid"); + networkInformation.setOnapModelInformation(onapModelInformation); + + assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network))); + + } + + @Test + public void buildNetworkInformationNoModelTest() { + + L3Network network = new L3Network(); + network.setNetworkId("my-network-id"); + network.setNetworkType("my-network-type"); + network.setNetworkTechnology("my-network-technology"); + + GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation(); + networkInformation.setNetworkId("my-network-id"); + networkInformation.setNetworkType("my-network-type"); + networkInformation.networkTechnology("my-network-technology"); + networkInformation.setFromPreload(null); + + + assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network))); + + } } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/grApiVmNetworkSubSectionWith5GParams.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/grApiVmNetworkSubSectionWith5GParams.json new file mode 100644 index 0000000000..e83f487a64 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/grApiVmNetworkSubSectionWith5GParams.json @@ -0,0 +1,73 @@ +{ + "network-role": "vmNetworkRole0", + "segmentation-id" : "my-segemntation-id", + "floating-ips": { + "floating-ip-v4": [ + "floatingIpV40", + "floatingIpV41" + ], + "floating-ip-v6": [ + "floatingIpV60", + "floatingIpV61" + ] + }, + "interface-route-prefixes": { + "interface-route-prefix": [ + "interfaceRoutePrefix0", + "interfaceRoutePrefix1" + ] + }, + "sriov-parameters": { + "heat-vlan-filters": { + "heat-vlan-filter": [ + "heatVlanFilter0", + "heatVlanFilter1" + ] + } + }, + "network-information-items": { + "network-information-item": [ + { + "network-ips": { + "network-ip": [ + "ip0", + "ip1" + ] + }, + "ip-version": "ipv4" + }, + { + "network-ips": { + "network-ip": [ + "ip2", + "ip3" + ] + }, + "ip-version": "ipv6" + } + ] + }, + "related-networks" : { + "related-network" : [{ + "vlan-tags" : { + "is-private" : "True", + "upper-tag-id" : "1" + } + },{ + "vlan-tags" : { + "is-private" : "False", + "upper-tag-id" : "2" + } + },{ + "vlan-tags" : { + "is-private" : "True", + "upper-tag-id" : "3" + } + },{ + "vlan-tags" : { + "is-private" : "False", + "upper-tag-id" : "3" + } + }] + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml index 4562ebdaea..6f67a9ccc4 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml @@ -114,30 +114,6 @@ mso: version: '9' generic-vnf: version: '9' - v8: - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf global: default: aai: @@ -220,4 +196,4 @@ camunda: bpm: metrics: enabled: false - db-reporter-activate: false
\ No newline at end of file + db-reporter-activate: false |