diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-08-22 12:10:23 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-08-22 12:10:59 -0400 |
commit | ce28fc9159d0d554ef06fdd1f6e1f4c0918ad269 (patch) | |
tree | 807d79ffc32d9bc590e0c85d78d3acadad1cfbeb /bpmn/mso-infrastructure-bpmn | |
parent | 66c2def4d7b1a85cccea76f9d5096bf3e23f3b9b (diff) |
Prod fixes August 18th
fixed compilation issues and all unit tests now pass
fix condition that checks for vnf in list to set homing flags
fix resource name variable being null
Skip volume group search for alacarte VF Module creation, since that group is expected to be specified on the input
Remove temporary change to JUnit for creation of volume group.
Add mapping of isBaseVfModule setting to AAIObjectMapper for vfModule.
adding a unit test for hte issue which was fixed
Explicitly return heatStackId variable from VnfAdapter subprocess
Fixing an issue with the workflow processor/asynresource which may lead to
apihandler leaving the active_Request table record in_progress while the bpmn quits the processing due to the error.
Change-Id: I7587193fcb5251f50370d72a1e4c10d112a1c72f
Issue-ID: SO-879
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn')
3 files changed, 91 insertions, 12 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index cfd07d8c39..ef72149d10 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -40,6 +40,7 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowContext; import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.logger.MsoLogger; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -92,7 +93,6 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { /** * Asynchronous JAX-RS method that starts a process instance. - * @param asyncResponse an object that will receive the asynchronous response * @param processKey the process key * @param variableMap input variables to the process * @return @@ -114,7 +114,10 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { processor.startProcess(processKey, variableMap); WorkflowResponse response = waitForResponse(getRequestId(inputVariables)); return Response.status(202).entity(response).build(); - } catch (Exception e) { + } catch (WorkflowProcessorException e) { + WorkflowResponse response = e.getWorkflowResponse(); + return Response.status(500).entity(response).build(); + }catch (Exception e) { WorkflowResponse response = buildUnkownError(getRequestId(inputVariables),e.getMessage()); return Response.status(500).entity(response).build(); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index edc05afba2..da24ba14fd 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java @@ -28,11 +28,10 @@ import java.util.UUID; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.camunda.bpm.engine.variable.impl.VariableMapImpl; -import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse; -import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; +import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.logger.MsoLogger; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException; import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -79,13 +78,12 @@ public class WorkflowProcessor extends ProcessEngineAwareService { msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, logMarker + "Error in starting the process: " + e.getMessage()); - WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse(); - callbackResponse.setStatusCode(500); - callbackResponse.setMessage("Fail"); - callbackResponse.setResponse("Error occurred while executing the process: " + e); - - WorkflowContextHolder.getInstance().processCallback(processKey, processInstanceId, - getRequestId(inputVariables), callbackResponse); + WorkflowResponse workflowResponse = new WorkflowResponse(); + workflowResponse.setResponse("Error occurred while executing the process: " + e); + workflowResponse.setProcessInstanceID(processInstanceId); + workflowResponse.setMessageCode(500); + workflowResponse.setMessage("Fail"); + throw new WorkflowProcessorException(workflowResponse); } } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java new file mode 100644 index 0000000000..ff5e18c210 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.workflow.service; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.ws.rs.core.Response; + +import org.camunda.bpm.engine.test.Deployment; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.junit.Test; +import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; + + +public class WorkflowAsyncResourceExceptionHandlingTest { + + @Test + @Deployment(resources = { "testAsyncResource.bpmn" }) + public void asyncRequestSuccess() throws InterruptedException { + VariableMapImpl variableMap = new VariableMapImpl(); + + Map<String, Object> variableValueType = new HashMap<>(); + + Map<String, Object> requestMsg = new HashMap<>(); + requestMsg.put("value", ""); + requestMsg.put("type", "String"); + + Map<String, Object> msorequestId = new HashMap<>(); + msorequestId.put("type", "String"); + msorequestId.put("value",UUID.randomUUID().toString()); + + Map<String, Object> timeout = new HashMap<>(); + timeout.put("type", "String"); + timeout.put("value","5"); + + variableValueType.put("testAsyncRequestMsg", requestMsg); + variableValueType.put("mso-request-id", msorequestId); + variableValueType.put("mso-service-request-timeout", timeout); + + variableMap.put("variables", variableValueType); + WorkflowAsyncResource workflowAsyncResource = new WorkflowAsyncResource(); + workflowAsyncResource.setProcessor(new WorkflowProcessor()); + Response res = workflowAsyncResource.startProcessInstanceByKey("randomKey", variableMap); + assertEquals(500,res.getStatus()); + WorkflowResponse workflowResponse = (WorkflowResponse)res.getEntity(); + assertNotNull(workflowResponse); + assertEquals(500, workflowResponse.getMessageCode()); + assertTrue(workflowResponse.getResponse().startsWith("Error occurred while executing the process:")); + assertEquals("Fail", workflowResponse.getMessage()); + + + } + +} |