diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-10-26 15:05:42 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-10-26 15:50:37 -0400 |
commit | 959493d3274d2f2749586248cf31ee12b730e2af (patch) | |
tree | 77904da6efa6105149f289be3d285a3499d92c80 /bpmn | |
parent | 373c057bfa82583f615ea46814ad3cdf9ea8d669 (diff) |
Bug fixes October 26th
Set non-custom health diagnostic check code to a default value.
created custom java serialization for SimpleUri
changed property value for cloud-owner in unit test
converted aai call to use the AAI Client
Correct a JUnit data file to include userParams values that are
expected to be set.
Set userParams on requestContext to parameters that need to be passed
to downstream systems.
Change-Id: I3974691875ef967f90a15f076ae27bc0cd76ee8e
Issue-ID: SO-1169
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn')
8 files changed, 118 insertions, 19 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index d463fde09c..0f52c96d0e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -22,6 +22,7 @@ package org.onap.so.bpmn.servicedecomposition.tasks; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -84,6 +85,8 @@ import org.springframework.stereotype.Component; @Component("BBInputSetupMapperLayer") public class BBInputSetupMapperLayer { + private static final String USER_PARAM_NAME_KEY = "name"; + private static final String USER_PARAM_VALUE_KEY = "value"; private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, BBInputSetupMapperLayer.class); @@ -332,6 +335,7 @@ public class BBInputSetupMapperLayer { if (null != requestParameters) { context.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType()); context.setRequestParameters(this.mapRequestParameters(requestDetails.getRequestParameters())); + context.setUserParams(this.mapNameValueUserParams(requestDetails.getRequestParameters())); } return context; } @@ -344,6 +348,20 @@ public class BBInputSetupMapperLayer { requestParams.setPayload(requestParameters.getPayload()); return requestParams; } + + protected HashMap<String,String> mapNameValueUserParams(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) { + HashMap<String,String> userParamsResult = new HashMap<String,String>(); + if (requestParameters.getUserParams() != null) { + List<Map<String, Object>> userParams = requestParameters.getUserParams(); + for (Map<String, Object> userParamsMap : userParams) { + if ( userParamsMap.containsKey(USER_PARAM_NAME_KEY) && (userParamsMap.get(USER_PARAM_NAME_KEY) instanceof String) + && userParamsMap.containsKey(USER_PARAM_VALUE_KEY) && (userParamsMap.get(USER_PARAM_VALUE_KEY) instanceof String)) { + userParamsResult.put((String) userParamsMap.get(USER_PARAM_NAME_KEY), (String) userParamsMap.get(USER_PARAM_VALUE_KEY)); + } + } + } + return userParamsResult; + } protected OrchestrationContext mapOrchestrationContext(RequestDetails requestDetails) { OrchestrationContext context = new OrchestrationContext(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index 94dbbf427c..1babac68ca 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -23,6 +23,8 @@ package org.onap.so.bpmn.servicedecomposition.tasks; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; @@ -33,7 +35,6 @@ import java.util.List; import java.util.Map; import org.junit.Test; -import org.mockito.InjectMocks; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -636,4 +637,20 @@ public class BBInputSetupMapperLayerTest { assertThat(actual, sameBeanAs(expected)); } + + @Test + public void testMapNameValueUserParams() throws IOException { + RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class); + HashMap<String,String> actual = bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters()); + + assertTrue(actual.containsKey("name1")); + assertTrue(actual.containsValue("value1")); + assertTrue(actual.get("name1").equals("value1")); + assertTrue(actual.containsKey("name2")); + assertTrue(actual.containsValue("value2")); + assertTrue(actual.get("name2").equals("value2")); + assertFalse(actual.containsKey("ignore")); + assertFalse(actual.containsValue("ignore")); + } + } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json index 8640c2e899..a53ed4dfde 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json @@ -1,6 +1,7 @@ { "requestContext": { "source": "VID", + "user-params": {}, "mso-request-id": "requestId", "action": "createInstance", "requestParameters": { diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json index cf65143c9a..926bf2ccb7 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json @@ -5,11 +5,28 @@ "requestor-id": "requestorId", "mso-request-id": "requestId", "subscription-service-type": "subscriptionServiceType", - "user-params": null, + "user-params": { + "name1": "value1", + "name2": "value2" + }, "action": "createInstance", "callback-url": "callbackURL", "requestParameters": { - "subscriptionServiceType": "subscriptionServiceType" + "subscriptionServiceType": "subscriptionServiceType", + "userParams": [ + { + "name": "name1", + "value": "value1" + }, + { + "name": "name2", + "value": "value2" + }, + { + "ignore": "false", + "skip": "ignore" + } + ] } }, "orchContext": { diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestContextExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestContextExpected.json index 6f82a9dd75..dfc6d4f555 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestContextExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestContextExpected.json @@ -2,11 +2,29 @@ "product-family-id": "productFamilyId", "source": "source", "requestor-id": "requestorId", - "subscription-service-type": "subscriptionServiceType", - "user-params": null, + "subscription-service-type": "subscriptionServiceType", "action": null, "callback-url": "callbackURL", + "user-params": { + "name1": "value1", + "name2": "value2" + }, "requestParameters": { - "subscriptionServiceType": "subscriptionServiceType" + "subscriptionServiceType": "subscriptionServiceType", + "userParams": [ + { + "name": "name1", + "value": "value1" + }, + { + "name": "name2", + "value": "value2" + }, + { + "ignore": "false", + "skip": "ignore" + } + ] } + } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContext.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContext.json index e91875135b..7386828d27 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContext.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContext.json @@ -7,7 +7,22 @@ "requestorId": "requestorId" }, "requestParameters": { - "subscriptionServiceType": "subscriptionServiceType" + "subscriptionServiceType": "subscriptionServiceType", + "userParams": [ + { + "name": "name1", + "value": "value1" + }, + { + "name": "name2", + "value": "value2" + }, + { + "ignore": "false", + "skip": "ignore" + } + ] + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy index 82e27ec116..0f9a0ad292 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy @@ -29,10 +29,13 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.VfModuleBase import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.core.WorkflowException +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 +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse -import org.springframework.web.util.UriUtils class UpdateVfModuleVolume extends VfModuleBase { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleVolume.class); @@ -172,14 +175,15 @@ class UpdateVfModuleVolume extends VfModuleBase { try { def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + - '/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/' + UriUtils.encode(aicCloudRegion, "UTF-8") + - '/volume-groups/volume-group/' + UriUtils.encode(volumeGroupId, "UTF-8") + + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + String endPoint = aaiUtil.createAaiUri(uri) + msoLogger.debug('Sending GET to AAI endpoint \'' + endPoint + '\'') msoLogger.debug("UpdateVfModuleVolume sending GET for quering AAI endpoint: " + endPoint) - AaiUtil aaiUtil = new AaiUtil(this) APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) def int statusCode = response.getStatusCode() def responseData = response.getResponseBodyAsString() diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java index 04397c499d..f492ba3ead 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java @@ -27,7 +27,10 @@ import static org.junit.Assert.assertNull; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.junit.Rule; import org.junit.Test; @@ -40,6 +43,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; @@ -80,8 +84,8 @@ public class VfModuleTopologyOperationRequestMapperTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); // RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); - userParams.put("key1", "value1"); + HashMap<String,String> userParams = new HashMap<String,String>(); + userParams.put("key1", "value1"); requestContext.setUserParams(userParams); requestContext.setProductFamilyId("productFamilyId"); @@ -108,7 +112,7 @@ public class VfModuleTopologyOperationRequestMapperTest { modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); vfModule.setModelInfoVfModule(modelInfoVfModule); HashMap<String, String> cloudParams = new HashMap<String, String>(); - userParams.put("key2", "value2"); + cloudParams.put("key2", "value2"); vfModule.setCloudParams(cloudParams); VolumeGroup volumeGroup = new VolumeGroup(); @@ -189,9 +193,14 @@ public class VfModuleTopologyOperationRequestMapperTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); // RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); - userParams.put("key1", "value1"); - requestContext.setUserParams(userParams); + RequestParameters requestParameters = new RequestParameters(); + HashMap<String,Object> userParams1 = new HashMap<String,Object>(); + userParams1.put("key1", "value1"); + List<Map<String,Object>> userParams = new ArrayList<Map<String,Object>>(); + userParams.add(userParams1); + + requestParameters.setUserParams(userParams); + requestContext.setRequestParameters(requestParameters); requestContext.setProductFamilyId("productFamilyId"); GenericVnf vnf = new GenericVnf(); @@ -225,7 +234,7 @@ public class VfModuleTopologyOperationRequestMapperTest { assertNull(vfModuleSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); assertEquals("vnfModelCustomizationUuid", vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid()); - assertEquals("vfModuleModelCustomizationUuid", vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid()); + assertEquals("vfModuleModelCustomizationUuid", vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid()); } @Test |