diff options
author | Steve Smokowski <ss835w@att.com> | 2019-01-21 20:42:51 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-01-21 20:42:51 +0000 |
commit | 244b9781a51c6172797f2ec8193399d1233778cc (patch) | |
tree | 69342e891b8fc7dab956722a7fc69c1e4c45ba77 /bpmn | |
parent | e05094129320f3ffb1ec01fb4af1b601b4282f81 (diff) | |
parent | 63bee11f255fcd2cc39a3d87c208aa6e517a8f85 (diff) |
Merge "Bug fixes from AT&T January 20th"
Diffstat (limited to 'bpmn')
16 files changed, 117 insertions, 81 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index 934aea8241..abf53f96f5 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -308,7 +308,7 @@ <dependency> <groupId>org.onap.appc.client</groupId> <artifactId>client-lib</artifactId> - <version>1.3.0</version> + <version>1.4.4</version> <exclusions> <exclusion> <groupId>org.mockito</groupId> @@ -327,7 +327,7 @@ <dependency> <groupId>org.onap.appc.client</groupId> <artifactId>client-kit</artifactId> - <version>1.3.0</version> + <version>1.4.4</version> <exclusions> <exclusion> <groupId>org.mockito</groupId> diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index 9e71313e09..57af763ed5 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -20,8 +20,6 @@ package org.onap.so.bpmn.common.scripts; -import groovy.json.JsonSlurper - import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.camunda.bpm.engine.variable.VariableMap @@ -30,11 +28,13 @@ import org.camunda.bpm.engine.variable.Variables.SerializationDataFormats import org.camunda.bpm.engine.variable.impl.value.ObjectValueImpl import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder -import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException import org.onap.so.client.aai.AAIResourcesClient import org.springframework.web.util.UriUtils +import groovy.json.JsonSlurper + public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcessor { public MsoUtils utils = new MsoUtils() @@ -767,4 +767,4 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess public AAIResourcesClient getAAIClient(){ return new AAIResourcesClient(); } -}
\ No newline at end of file +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index 9fd16340b6..f96e3bea0e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -174,7 +174,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { String newPersonaModelId = execution.getVariable('UAAIGenVnf_personaModelId') String newPersonaModelVersion = execution.getVariable('UAAIGenVnf_personaModelVersion') - String personaModelVersionEntry = "" + String personaModelVersionEntry = null if (newPersonaModelId != null || newPersonaModelVersion != null) { if (newPersonaModelId != genericVnf.getModelInvariantId()) { def msg = 'Can\'t update Generic VNF ' + vnfId + ' since there is \'persona-model-id\' mismatch between the current and new values' @@ -188,7 +188,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Handle ipv4-oam-address String ipv4OamAddress = execution.getVariable('UAAIGenVnf_ipv4OamAddress') - String ipv4OamAddressEntry = "" + String ipv4OamAddressEntry = null if (ipv4OamAddress != null) { // Construct payload ipv4OamAddressEntry = updateGenericVnfNode(origRequest, 'ipv4-oam-address') @@ -196,7 +196,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Handle management-v6-address String managementV6Address = execution.getVariable('UAAIGenVnf_managementV6Address') - String managementV6AddressEntry = "" + String managementV6AddressEntry = null if (managementV6Address != null) { // Construct payload managementV6AddressEntry = updateGenericVnfNode(origRequest, 'management-v6-address') @@ -204,21 +204,19 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Handle orchestration-status String orchestrationStatus = execution.getVariable('UAAIGenVnf_orchestrationStatus') - String orchestrationStatusEntry = "" + String orchestrationStatusEntry = null if (orchestrationStatus != null) { // Construct payload orchestrationStatusEntry = updateGenericVnfNode(origRequest, 'orchestration-status') } - - String payload = """ - { ${personaModelVersionEntry} - ${ipv4OamAddressEntry} - ${managementV6AddressEntry} - ${orchestrationStatusEntry} - "vnf-id": "${vnfId}" - } - """ - + + org.onap.aai.domain.yang.GenericVnf payload = new org.onap.aai.domain.yang.GenericVnf(); + payload.setVnfId(vnfId) + payload.setPersonaModelVersion(personaModelVersionEntry) + payload.setIpv4OamAddress(ipv4OamAddressEntry) + payload.setManagementV6Address(managementV6AddressEntry) + payload.setOrchestrationStatus(orchestrationStatusEntry) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) try { @@ -246,16 +244,16 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { public String updateGenericVnfNode(String origRequest, String elementName) { if (!utils.nodeExists(origRequest, elementName)) { - return "" + return null } def elementValue = utils.getNodeText(origRequest, elementName) if (elementValue == 'DELETE') { - // Set the element being deleted to null - return """"${elementName}": null,""" + // Set the element being deleted to empty string + return "" } else { - return """"${elementName}": "${elementValue}",""" + return elementValue } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index 6c2df13c61..d2e0b07dd1 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -53,6 +53,7 @@ public class ExecuteBuildingBlockRainyDay { @Autowired private Environment environment; protected String retryDurationPath = "mso.rainyDay.retryDurationMultiplier"; + protected String defaultCode = "mso.rainyDay.defaultCode"; public void setRetryTimer(DelegateExecution execution) { try { @@ -149,7 +150,8 @@ public class ExecuteBuildingBlockRainyDay { execution.setVariable(HANDLING_CODE, handlingCode); } catch (Exception e) { msoLogger.error("Failed to determine RainyDayHandler Status. Seting handlingCode = Abort"); - execution.setVariable(HANDLING_CODE, "Abort"); + String code = this.environment.getProperty(defaultCode); + execution.setVariable(HANDLING_CODE, code); } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index 9af9b2f2c9..cb5683dcc8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -21,7 +21,7 @@ package org.onap.so.bpmn.servicedecomposition.tasks; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; diff --git a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml index 1651f4f1fc..18f94f3b88 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml +++ b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml @@ -110,6 +110,7 @@ mso: rollback: 'true' rainyDay: retryDurationMultiplier: '2' + defaultCode: Abort site-name: localDevEnv workflow: default: diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index 38a1ccdf35..70ae02b0fe 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> <bpmn:process id="WorkflowActionBB" name="WorkflowActionBB" isExecutable="true"> <bpmn:startEvent id="Start_WorkflowActionBB" name="start"> <bpmn:outgoing>SequenceFlow_15s0okp</bpmn:outgoing> @@ -22,6 +22,7 @@ <camunda:out source="orchestrationStatusValidationResult" target="orchestrationStatusValidationResult" /> <camunda:out source="RetryDuration" target="RetryDuration" /> <camunda:in source="suppressRollback" target="suppressRollback" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0mew9im</bpmn:incoming> <bpmn:outgoing>SequenceFlow_07h9d4y</bpmn:outgoing> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index c95704e51a..67fbb97797 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -451,10 +451,11 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { URL url = new URL(vnfAdapterUrl) HttpClient httpClient = new HttpClientFactory().newXmlClient(url, TargetEntity.OPENSTACK_ADAPTER) + httpClient.accept = "application/xml" httpClient.addAdditionalHeader("Authorization", execution.getVariable("BasicAuthHeaderValuePO")) Response response = httpClient.delete(vnfAdapterRequest) - + execution.setVariable(Prefix + "deleteNetworkResponse", response.readEntity(String.class)) execution.setVariable(Prefix + "networkReturnCode", response.getStatus()) } catch (Exception ex) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java index 173d5f7e73..a4ef28496e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.exception.MapperException; @@ -31,6 +30,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpClientErrorException; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.PathNotFoundException; @@ -64,15 +64,18 @@ public class SDNCRequestTasks { String finalMessageIndicator = JsonPath.read(response, "$.output.ack-final-indicator"); execution.setVariable("isSDNCCompleted", convertIndicatorToBoolean(finalMessageIndicator)); } catch(PathNotFoundException e) { - logger.error("Error Parsing SDNC Response", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Error Parsing SDNC Response"); + logger.error("Error Parsing SDNC Response. Could not find read final ack indicator from JSON.", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Recieved invalid response from SDNC, unable to read message content."); } catch (MapperException e) { - logger.error("Error Parsing SDNC Response", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Error Parsing SDNC Response"); + logger.error("Failed to map SDNC object to JSON prior to POST.", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Failed to map SDNC object to JSON prior to POST."); } catch (BadResponseException e) { - logger.error("Error Reading SDNC Response", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error Reading SDNC Response"); - } + logger.error("Did not receive a successful response from SDNC.", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getLocalizedMessage()); + } catch (HttpClientErrorException e){ + logger.error("HttpClientErrorException: 404 Not Found, Failed to contact SDNC", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "SDNC cannot be contacted."); + } } public void processCallback (DelegateExecution execution) { 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 50f2091ae2..d18fd006f4 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 @@ -109,7 +109,9 @@ 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 String FABRIC_CONFIGURATION = "FabricConfiguration"; + private static final String G_SERVICE_TYPE = "serviceType"; + private static final String SERVICE_TYPE_TRANSPORT = "TRANSPORT"; private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @Autowired @@ -146,6 +148,8 @@ public class WorkflowAction { final String uri = (String) execution.getVariable(G_URI); final String vnfType = (String) execution.getVariable(VNF_TYPE); String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); + final String serviceType = Optional.ofNullable((String) execution.getVariable(G_SERVICE_TYPE)).orElse(""); + List<OrchestrationFlow> orchFlows = (List<OrchestrationFlow>) execution.getVariable(G_ORCHESTRATION_FLOW); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution); @@ -192,7 +196,7 @@ public class WorkflowAction { if (aLaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { - orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner); + orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner, serviceType); } orchFlows = filterOrchFlows(orchFlows, resourceType, execution); String key = ""; @@ -277,7 +281,7 @@ public class WorkflowAction { logger.info("Found {}", foundObjects); if (orchFlows == null || orchFlows.isEmpty()) { - orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner); + orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner, serviceType); } flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceCounter, requestId, apiVersion, resourceId, resourceType, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails); @@ -1054,9 +1058,21 @@ public class WorkflowAction { protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction, WorkflowType resourceName, boolean aLaCarte, String cloudOwner) { + return this.queryNorthBoundRequestCatalogDb(execution, requestAction, resourceName, aLaCarte, cloudOwner, ""); + } + + protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction, + WorkflowType resourceName, boolean aLaCarte, String cloudOwner, String serviceType) { List<OrchestrationFlow> listToExecute = new ArrayList<>(); - NorthBoundRequest northBoundRequest = catalogDbClient - .getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(requestAction, resourceName.toString(), aLaCarte, cloudOwner); + NorthBoundRequest northBoundRequest = null; + if (serviceType.equalsIgnoreCase(SERVICE_TYPE_TRANSPORT)) { + northBoundRequest = catalogDbClient + .getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType(requestAction, + resourceName.toString(), aLaCarte, cloudOwner, serviceType); + } else { + northBoundRequest = catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner( + requestAction, resourceName.toString(), aLaCarte, cloudOwner); + } if(northBoundRequest == null){ if(aLaCarte){ buildAndThrowException(execution,"The request: ALaCarte " + resourceName + " " + requestAction + " is not supported by GR_API."); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java index 4fb480892a..1812e50328 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java @@ -25,6 +25,7 @@ import java.util.Optional; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.core.WorkflowException; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.slf4j.Logger; @@ -67,7 +68,7 @@ public class WorkflowActionBBFailure { String errorMsg = ""; Boolean rollbackCompletedSuccessfully = (Boolean) execution.getVariable("isRollbackComplete"); Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback"); - + ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock"); if(rollbackCompletedSuccessfully==null) rollbackCompletedSuccessfully = false; @@ -97,6 +98,17 @@ public class WorkflowActionBBFailure { request.setStatusMessage(errorMsg); execution.setVariable("ErrorMessage", errorMsg); } + if(ebb!=null && ebb.getBuildingBlock()!=null){ + String flowStatus = ""; + if(rollbackCompletedSuccessfully){ + flowStatus = "All Rollback flows have completed successfully"; + }else{ + flowStatus = ebb.getBuildingBlock().getBpmnFlowName() + " has failed."; + } + request.setFlowStatus(flowStatus); + execution.setVariable("flowStatus", flowStatus); + } + request.setProgress(Long.valueOf(100)); request.setRequestStatus("FAILED"); request.setLastModifiedBy("CamundaBPMN"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 917039b17b..78a84b1772 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -199,6 +199,7 @@ public class WorkflowActionBBTasks { execution.setVariable("finalStatusMessage", macroAction); Timestamp endTime = new Timestamp(System.currentTimeMillis()); request.setEndTime(endTime); + request.setFlowStatus("Successfully completed all Building Blocks"); request.setStatusMessage(macroAction); request.setProgress(Long.valueOf(100)); request.setRequestStatus("COMPLETE"); @@ -269,7 +270,7 @@ public class WorkflowActionBBTasks { int flowSize = rollbackFlows.size(); String handlingCode = (String) execution.getVariable("handlingCode"); if(handlingCode.equals("RollbackToAssigned")){ - for(int i = 0; i<flowSize -1; i++){ + for(int i = 0; i<flowSize; i++){ if(rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Unassign")){ rollbackFlows.remove(i); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java index 7d92a5304a..7ad2ef00b2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java @@ -21,7 +21,6 @@ package org.onap.so.client.sdnc; import java.util.LinkedHashMap; -import java.util.Optional; import javax.ws.rs.core.UriBuilder; @@ -36,9 +35,6 @@ import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - @Component public class SDNCClient { @@ -49,6 +45,7 @@ public class SDNCClient { private SDNCProperties properties; @Autowired private SdnCommonTasks sdnCommonTasks; + /** * * @param request @@ -59,13 +56,13 @@ public class SDNCClient { * @throws BadResponseException */ public String post(Object request, SDNCTopology topology) throws MapperException, BadResponseException { - String jsonRequest = sdnCommonTasks.buildJsonRequest(request); - String targetUrl = properties.getHost() + properties.getPath() + ":" + topology.toString() + "/"; - STOClient.setTargetUrl(targetUrl); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); - STOClient.setHttpHeader(httpHeader); - LinkedHashMap<String, Object> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); - return sdnCommonTasks.validateSDNResponse(output); + String jsonRequest = sdnCommonTasks.buildJsonRequest(request); + String targetUrl = properties.getHost() + properties.getPath() + ":" + topology.toString() + "/"; + STOClient.setTargetUrl(targetUrl); + HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); + STOClient.setHttpHeader(httpHeader); + LinkedHashMap<String, Object> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); + return sdnCommonTasks.validateSDNResponse(output); } @@ -76,9 +73,8 @@ public class SDNCClient { STOClient.setHttpHeader(httpHeader); LinkedHashMap<String, Object> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); return sdnCommonTasks.validateSDNResponse(output); -} + } - /** * * @param queryLink @@ -90,15 +86,14 @@ public class SDNCClient { * @throws BadResponseException */ public String get(String queryLink) throws MapperException, BadResponseException { - - String request = ""; - String jsonRequest = sdnCommonTasks.buildJsonRequest(request); - String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); - STOClient.setTargetUrl(targetUrl); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); - STOClient.setHttpHeader(httpHeader); - LinkedHashMap<String, Object> output = STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); - return sdnCommonTasks.validateSDNGetResponse(output); + String request = ""; + String jsonRequest = sdnCommonTasks.buildJsonRequest(request); + String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); + STOClient.setTargetUrl(targetUrl); + HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); + STOClient.setHttpHeader(httpHeader); + LinkedHashMap<String, Object> output = STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); + return sdnCommonTasks.validateSDNGetResponse(output); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 5c1485979e..f3b094f645 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -21,9 +21,9 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; @@ -258,33 +258,28 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); BuildingBlock bb1 = new BuildingBlock(); - bb1.setBpmnFlowName("AssignServiceInstanceBB"); + bb1.setBpmnFlowName("AssignVfModuleBB"); ebb1.setBuildingBlock(bb1); flowsToExecute.add(ebb1); ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("CreateNetworkCollectionBB"); + bb2.setBpmnFlowName("CreateVfModuleBB"); ebb2.setBuildingBlock(bb2); flowsToExecute.add(ebb2); ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("AssignNetworkBB"); + bb3.setBpmnFlowName("ActivateVfModuleBB"); ebb3.setBuildingBlock(bb3); flowsToExecute.add(ebb3); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - BuildingBlock bb4 = new BuildingBlock(); - bb4.setBpmnFlowName("CreateNetworkBB"); - ebb4.setBuildingBlock(bb4); - flowsToExecute.add(ebb4); execution.setVariable("flowsToExecute", flowsToExecute); - execution.setVariable("gCurrentSequence", 3); - doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class)); - + execution.setVariable("gCurrentSequence", 2); + workflowActionBBTasks.rollbackExecutionPath(execution); List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); - assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkCollectionBB"); + assertEquals("DeleteVfModuleBB",ebbs.get(0).getBuildingBlock().getBpmnFlowName()); assertEquals(0,execution.getVariable("gCurrentSequence")); + assertEquals(1,ebbs.size()); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 72f0ce4e6d..7b348c8cb3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -982,6 +982,17 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals(flows.get(8).getFlowName(),"SDNOVnfHealthCheckBB"); assertEquals(flows.get(9).getFlowName(),"AAIUnsetVnfInMaintBB"); } + + @Test + public void queryNorthBoundRequestCatalogDbTransportTest() throws MalformedURLException { + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB"); + northBoundRequest.setOrchestrationFlowList(orchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType("createInstance","Service",true,"my-custom-cloud-owner","TRANSPORT")).thenReturn(northBoundRequest); + + List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "createInstance", WorkflowType.SERVICE, true,"my-custom-cloud-owner","TRANSPORT"); + assertEquals(flows.get(0).getFlowName(),"AssignServiceInstanceBB"); + } @Test public void extractResourceIdAndTypeFromUriTest(){ 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 index 4008240203..297d75a104 100644 --- 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 @@ -144,7 +144,7 @@ public class WorkflowActionUnitTest { flow.setFlowName("flow x"); List<OrchestrationFlow> flows = Arrays.asList(flow); - doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean(), any()); + doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean(), any(), any()); workflowAction.selectExecutionList(execution); verify(workflowAction, times(1)).filterOrchFlows(eq(flows), any(), any()); |