diff options
Diffstat (limited to 'bpmn')
18 files changed, 341 insertions, 153 deletions
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 1e2a703e70..0692e5022a 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 @@ -755,8 +755,6 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess public void setBasicDBAuthHeader(DelegateExecution execution, isDebugLogEnabled) { try { String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution) - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled) - def encodedString = utils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution)) execution.setVariable("BasicAuthHeaderValueDB",encodedString) } catch (IOException ex) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java index c3511e69a4..78f3e96978 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java @@ -20,13 +20,14 @@ package org.onap.so.bpmn.common.baseclient; +import org.onap.so.logging.jaxrs.filter.SpringClientFilter; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.http.client.BufferingClientHttpRequestFactory; -import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; @@ -59,11 +60,12 @@ public class BaseClient<I,O> { public O post(I data, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { return run(data, HttpMethod.POST, typeRef, uriVariables); } - + public O run(I data, HttpMethod method, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { HttpEntity<I> requestEntity = new HttpEntity<I>(data, getHttpHeader()); RestTemplate restTemplate = new RestTemplate(); - restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory())); + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); + restTemplate.getInterceptors().add(new SpringClientFilter()); ResponseEntity<O> responseEntity = restTemplate.exchange(getTargetUrl(), method, requestEntity, typeRef, uriVariables); return responseEntity.getBody(); diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn index 67bd961844..63c867f3c7 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_EsMs0HcuEeW2U_kkOHX1ZQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_EsMs0HcuEeW2U_kkOHX1ZQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="CompleteMsoProcess" name="CompleteMsoProcess" isExecutable="true"> <bpmn2:scriptTask id="preProcessRequest" name="Pre-Process Request" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> @@ -56,6 +56,7 @@ completeMsoProcess.setUpdateDBstatustoSuccessPayload(execution)]]></bpmn2:script <camunda:map> <camunda:entry key="content-type">application/soap+xml</camunda:entry> <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry> + <camunda:entry key="X-ONAP-RequestID">#{CMSO_request_id}</camunda:entry> </camunda:map> </camunda:inputParameter> <camunda:inputParameter name="method">POST</camunda:inputParameter> @@ -88,7 +89,7 @@ buildDataErrorMessage.buildDataError(execution, "Complete MSO -- Update DB stat <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="ExclusiveGateway_7" targetRef="BuildErrorMessage" /> <bpmn2:boundaryEvent id="BoundaryEvent_7" name="" attachedToRef="updateInfraRequest"> <bpmn2:outgoing>SequenceFlow_0mipf25</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_84" errorRef="Error_1" /> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_84" errorRef="Error_1" camunda:errorCodeVariable="gJavaErrorCode" camunda:errorMessageVariable="gJavaErrorMessage" /> </bpmn2:boundaryEvent> <bpmn2:endEvent id="EndEvent_1"> <bpmn2:incoming>SequenceFlow_1pzb94j</bpmn2:incoming> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn index c59564b1e3..990863ec93 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_3SPHsLr9EeWak-hhutJWuQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_3SPHsLr9EeWak-hhutJWuQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="FalloutHandler" name="Fallout Handler" isExecutable="true"> <bpmn2:parallelGateway id="ParallelGateway_1"> <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming> @@ -139,6 +139,7 @@ falloutHandler.buildDBWorkflowException(execution, "FH_updateRequestInfraRespons <camunda:map> <camunda:entry key="content-type">application/soap+xml</camunda:entry> <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry> + <camunda:entry key="X-ONAP-RequestID">#{FH_request_id}</camunda:entry> </camunda:map> </camunda:inputParameter> <camunda:inputParameter name="payload"> @@ -168,7 +169,7 @@ return updateRequestInfra.updateRequestInfraPayload(execution)]]></camunda:scrip </bpmn2:sequenceFlow> <bpmn2:boundaryEvent id="BoundaryEvent_3" name="Connect Fault" attachedToRef="ServiceTask_2"> <bpmn2:outgoing>SequenceFlow_80</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_90" errorRef="Error_2" /> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_90" errorRef="Error_2" camunda:errorCodeVariable="gJavaErrorCode" camunda:errorMessageVariable="gJavaErrorMessage" /> </bpmn2:boundaryEvent> <bpmn2:sequenceFlow id="SequenceFlow_80" name="" sourceRef="BoundaryEvent_3" targetRef="ScriptTask_7" /> <bpmn2:subProcess id="SubProcess_1" name="Event Handler" triggeredByEvent="true"> 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 da24ba14fd..9ea97258ef 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 @@ -31,7 +31,6 @@ import org.camunda.bpm.engine.variable.impl.VariableMapImpl; 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.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -46,19 +45,14 @@ public class WorkflowProcessor extends ProcessEngineAwareService { @Async public void startProcess( String processKey, VariableMapImpl variableMap) throws InterruptedException { - MDC.getCopyOfContextMap(); + long startTime = System.currentTimeMillis(); Map<String, Object> inputVariables = null; String processInstanceId = null; try { inputVariables = getInputVariables(variableMap); - setLogContext(processKey, inputVariables); - // This variable indicates that the flow was invoked asynchronously inputVariables.put("isAsyncProcess", "true"); - - - setLogContext(processKey, inputVariables); // Note: this creates a random businessKey if it wasn't specified. String businessKey = getBusinessKey(inputVariables); @@ -87,14 +81,6 @@ public class WorkflowProcessor extends ProcessEngineAwareService { } } - protected static void setLogContext(String processKey, - Map<String, Object> inputVariables) { - MsoLogger.setServiceName("MSO." + processKey); - if (inputVariables != null) { - MsoLogger.setLogContext(getKeyValueFromInputVariables(inputVariables,"mso-request-id"), getKeyValueFromInputVariables(inputVariables,"mso-service-instance-id")); - } - } - protected static String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) { if (inputVariables == null) { return ""; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 00ee6eb235..9b65cca6c9 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -70,9 +70,7 @@ import org.springframework.stereotype.Component; * Plugin for MSO logging and URN mapping. */ @Component -public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, LoggingAndURNMappingPlugin.class); - private static final String FSPROPKEY = "URNMapping.FileSystemLoading.Enabled"; +public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { @Autowired private LoggingParseListener loggingParseListener; @@ -198,7 +196,6 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { @Override public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) { - //injectLogExecutionListener(activity); } @Override @@ -216,9 +213,9 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { injectLogExecutionListener(timerActivity); } - @Override + @Override public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) { - //injectLogExecutionListener(activity); + } @Override @@ -298,17 +295,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { } @Override - public void notify(DelegateExecution execution) throws Exception { - logger.trace("Logging for activity---------------:" + event + ":" - + execution.getCurrentActivityName() - + ", processDefinitionId=" - + execution.getProcessDefinitionId() + ", activtyId=" - + execution.getCurrentActivityId() + ", activtyName='" - + execution.getCurrentActivityName() + "'" - + ", processInstanceId=" - + execution.getProcessInstanceId() + ", businessKey=" - + execution.getProcessBusinessKey() + ", executionId=" - + execution.getId()); + public void notify(DelegateExecution execution) throws Exception { //required for legacy groovy processing in camunda execution.setVariable("isDebugLogEnabled", "true"); if (!isBlank(execution.getCurrentActivityName())) { @@ -322,20 +309,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { .singleResult() .getName(); - if (execution.getBpmnModelElementInstance() instanceof StartEvent) { - logger.debug("Starting process: " + processName); - } - if (execution.getBpmnModelElementInstance() instanceof EndEvent) { - logger.debug("Ending process: " + processName); - } - - String serviceName = MDC.get(MsoLogger.SERVICE_NAME); - - if(serviceName != null && !serviceName.contains(processName)) - MsoLogger.setServiceName( serviceName + "." + processName); - else if(serviceName == null) - MsoLogger.setServiceName(processName); - + MsoLogger.setServiceName(processName); String requestId = (String) execution.getVariable("mso-request-id"); String svcid = (String) execution.getVariable("mso-service-instance-id"); MsoLogger.setLogContext(requestId, svcid); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java index db2304d6b7..efd73ba4f2 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java @@ -30,6 +30,8 @@ import org.camunda.bpm.engine.ProcessEngine; import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; import org.onap.so.logger.MsoLogger; +import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -102,7 +104,7 @@ public class MSOInfrastructureApplication { @Primary public Executor asyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - + executor.setTaskDecorator(new MDCTaskDecorator()); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/FlowCompleteActivitySpec.json b/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/FlowCompleteActivitySpec.json new file mode 100644 index 0000000000..e031c85501 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/FlowCompleteActivitySpec.json @@ -0,0 +1,14 @@ +{ + "name": "FlowCompleteActivity", + "description": "Activity to Complete the BPMN Flow", + "categoryList": [ + "VNF" + ], + "inputParameters": [ + { + "name": "WorkflowException", + "type": "WorkflowException" + } + ], + "outputParameters": [] +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/FlowCompleteActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/FlowCompleteActivity.bpmn new file mode 100644 index 0000000000..e255689e75 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/FlowCompleteActivity.bpmn @@ -0,0 +1,49 @@ +<?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:process id="FlowCompleteActivity" name="FlowCompleteActivity" isExecutable="true"> + <bpmn:startEvent id="FlowCompleteActivity_Start"> + <bpmn:outgoing>SequenceFlow_1tbhm2c</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="FlowCompleteActivity_End"> + <bpmn:incoming>SequenceFlow_10spt85</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1tbhm2c" sourceRef="FlowCompleteActivity_Start" targetRef="TaskUpdateRequestDB" /> + <bpmn:sequenceFlow id="SequenceFlow_10spt85" sourceRef="TaskUpdateRequestDB" targetRef="FlowCompleteActivity_End" /> + <bpmn:serviceTask id="TaskUpdateRequestDB" name="Update Request DB with Status" camunda:expression="${FlowCompletionTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1tbhm2c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_10spt85</bpmn:outgoing> + </bpmn:serviceTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="FlowCompleteActivity"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="FlowCompleteActivity_Start"> + <dc:Bounds x="173" y="102" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0uee341_di" bpmnElement="FlowCompleteActivity_End"> + <dc:Bounds x="428" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="446" y="138" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1tbhm2c_di" bpmnElement="SequenceFlow_1tbhm2c"> + <di:waypoint xsi:type="dc:Point" x="209" y="120" /> + <di:waypoint xsi:type="dc:Point" x="264" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="237" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_10spt85_di" bpmnElement="SequenceFlow_10spt85"> + <di:waypoint xsi:type="dc:Point" x="364" y="120" /> + <di:waypoint xsi:type="dc:Point" x="394" y="120" /> + <di:waypoint xsi:type="dc:Point" x="394" y="120" /> + <di:waypoint xsi:type="dc:Point" x="428" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="409" y="120" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0f1gnqq_di" bpmnElement="TaskUpdateRequestDB"> + <dc:Bounds x="264" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn index 67ee5d0f74..344b7d8761 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="_vwRmIBsREeeIQtzUKIjH4g" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.16.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> - <bpmn2:process id="Homing" name="Homing" isExecutable="true"> + <bpmn2:process id="HomingBB" name="Homing" isExecutable="true"> <bpmn2:startEvent id="StartEvent_1"> <bpmn2:outgoing>SequenceFlow_1x9usa6</bpmn2:outgoing> </bpmn2:startEvent> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java index 8bd4aeb387..ac62af2e9d 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java @@ -63,6 +63,7 @@ import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCChangeAssignTasks; import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCDeactivateTasks; import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCQueryTasks; import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCUnassignTasks; +import org.onap.so.bpmn.infrastructure.workflow.tasks.FlowCompletionTasks; import org.onap.so.bpmn.infrastructure.workflow.tasks.OrchestrationStatusValidator; import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowAction; import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBTasks; @@ -199,6 +200,9 @@ public abstract class BaseBPMNTest { @MockBean protected ConfigurationScaleOut configurationScaleOut; + @MockBean + protected FlowCompletionTasks flowCompletionTasks; + @LocalServerPort private int port; diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/FlowCompleteActivity.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/FlowCompleteActivity.java new file mode 100644 index 0000000000..50184a535d --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/FlowCompleteActivity.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.infrastructure.bpmn.subprocess; + +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doThrow; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Test; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.BaseBPMNTest; + +public class FlowCompleteActivity extends BaseBPMNTest{ + @Test + public void sunnyDayFlowCompleteActivity_Test() throws InterruptedException { + ProcessInstance pi = runtimeService.startProcessInstanceByKey("FlowCompleteActivity", variables); + assertThat(pi).isNotNull(); + assertThat(pi).isStarted().hasPassedInOrder("FlowCompleteActivity_Start", + "TaskUpdateRequestDB", + "FlowCompleteActivity_End"); + assertThat(pi).isEnded(); + } + + @Test + public void rainyDayFlowCompleteActivity_Test() throws Exception { + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(flowCompletionTasks) + .updateRequestDbStatus(any(BuildingBlockExecution.class)); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("FlowCompleteActivity", variables); + assertThat(pi).isNotNull(); + assertThat(pi).isStarted().hasPassedInOrder("FlowCompleteActivity_Start", + "TaskUpdateRequestDB").hasNotPassed( + "FlowCompleteActivity_End"); + assertThat(pi).isEnded(); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index 86c5f65e8c..dd135f3af5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -232,6 +232,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } if ("Homing_Solution".equals(userParam?.name)) { execution.setVariable("homingService", userParam.value) + execution.setVariable("callHoming", true) inputMap.put("Homing_Solution", userParam.value) } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java new file mode 100644 index 0000000000..ec2ccdf202 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 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.infrastructure.workflow.tasks; + +import java.util.ArrayList; +import java.util.List; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.BuildingBlockExecution; +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.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.serviceinstancebeans.RequestReferences; +import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class FlowCompletionTasks { + + private static final Logger logger = LoggerFactory.getLogger(FlowCompletionTasks.class); + + @Autowired + private RequestsDbClient requestDbclient; + + public void updateRequestDbStatus(BuildingBlockExecution execution) { + try { + String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId(); + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + + WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); + if (workflowException == null) { + request.setStatusMessage("RequestCompletedSuccessfully"); + request.setRequestStatus("COMPLETE"); + + } + else { + request.setStatusMessage(workflowException.getErrorMessage()); + request.setRequestStatus("FAILED"); + } + request.setProgress(100L); + request.setLastModifiedBy("CamundaBPMN"); + + requestDbclient.updateInfraActiveRequests(request); + } catch (Exception e) { + logger.error("Unable to save the updated request status to the DB",e); + } + } + + +} 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 a998f6934f..2d5638c2b7 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 @@ -35,6 +35,7 @@ import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; +import org.slf4j.LoggerFactory; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.Relationship; @@ -61,8 +62,6 @@ import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.Networks; @@ -71,6 +70,7 @@ import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.VfModules; import org.onap.so.serviceinstancebeans.Vnfs; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -79,6 +79,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; @Component public class WorkflowAction { + private static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage"; + private static final String SERVICE_INSTANCES = "serviceInstances"; + private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI = "WorkflowAction was unable to verify if the instance name already exist in AAI."; private static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow"; private static final String G_ACTION = "requestAction"; private static final String G_CURRENT_SEQUENCE = "gCurrentSequence"; @@ -100,7 +103,8 @@ public class WorkflowAction { private static final String CREATEINSTANCE = "createInstance"; private static final String USERPARAMSERVICE = "service"; private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances"; - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, WorkflowAction.class); + private static final String HOMINGSOLUTION = "Homing_Solution"; + private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @Autowired protected BBInputSetup bbInputSetup; @@ -157,6 +161,18 @@ public class WorkflowAction { execution.setVariable("resourceId", resourceId); execution.setVariable("resourceType", resourceType); + if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { + List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters() + .getUserParams(); + for (Map<String, Object> params : userParams) { + if (params.containsKey(HOMINGSOLUTION)) { + execution.setVariable("homing", true); + execution.setVariable("callHoming", true); + execution.setVariable("homingSolution", params.get(HOMINGSOLUTION)); + } + } + } + if (aLaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte); @@ -239,7 +255,7 @@ public class WorkflowAction { for(WorkflowType type : WorkflowType.values()){ foundObjects = foundObjects + type + " - " + resourceCounter.stream().filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList()).size() + " "; } - msoLogger.info("Found " + foundObjects); + logger.info("Found {}", foundObjects); if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte); @@ -247,7 +263,7 @@ public class WorkflowAction { flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceCounter, requestId, apiVersion, resourceId, resourceType, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails); if (!resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList()).isEmpty()) { - msoLogger.info("Sorting for Vlan Tagging"); + logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } if (resourceType == WorkflowType.SERVICE @@ -267,9 +283,9 @@ public class WorkflowAction { throw new IllegalStateException("Macro did not come up with a valid execution path."); } - msoLogger.info("List of BuildingBlocks to execute:"); + logger.info("List of BuildingBlocks to execute:"); for (ExecuteBuildingBlock ebb : flowsToExecute) { - msoLogger.info(ebb.getBuildingBlock().getBpmnFlowName()); + logger.info(ebb.getBuildingBlock().getBpmnFlowName()); } execution.setVariable(G_CURRENT_SEQUENCE, 0); @@ -296,7 +312,7 @@ public class WorkflowAction { private void updateResourceIdsFromAAITraversal(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceCounter, List<Pair<WorkflowType, String>> aaiResourceIds) { for(Pair<WorkflowType,String> pair : aaiResourceIds){ - msoLogger.debug(pair.getValue0() + ", " + pair.getValue1()); + logger.debug(pair.getValue0() + ", " + pair.getValue1()); } Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> { @@ -389,12 +405,12 @@ public class WorkflowAction { if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) { List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); if(customizations.isEmpty()) { - msoLogger.debug("No Collections found. CollectionResourceCustomization list is empty."); + logger.debug("No Collections found. CollectionResourceCustomization list is empty."); }else{ CollectionResourceCustomization collectionResourceCustomization = findCatalogNetworkCollection(execution, service); if(collectionResourceCustomization!=null){ resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,collectionResourceCustomization.getModelCustomizationUUID(),false)); - msoLogger.debug("Found a network collection"); + logger.debug("Found a network collection"); if(collectionResourceCustomization.getCollectionResource()!=null){ if(collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null){ String toscaNodeType = collectionResourceCustomization.getCollectionResource().getInstanceGroup().getToscaNodeType(); @@ -413,7 +429,7 @@ public class WorkflowAction { minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); } } - msoLogger.debug("minNetworks: " + minNetworks); + logger.debug("minNetworks: {}" , minNetworks); CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; for(CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup.getCollectionNetworkResourceCustomizations()) { if(collectionNetworkTemp.getNetworkResourceCustomization().getModelCustomizationUUID().equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) { @@ -429,21 +445,21 @@ public class WorkflowAction { } } } else { - msoLogger.debug("Instance Group tosca node type does not contain NetworkCollection: " + toscaNodeType); + logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}" , toscaNodeType); } }else{ - msoLogger.debug("No Instance Group found for network collection."); + logger.debug("No Instance Group found for network collection."); } }else{ - msoLogger.debug("No Network Collection found. collectionResource is null"); + logger.debug("No Network Collection found. collectionResource is null"); } } else { - msoLogger.debug("No Network Collection Customization found"); + logger.debug("No Network Collection Customization found"); } } if (resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList()).isEmpty()) { if (service.getNetworkCustomizations() == null) { - msoLogger.debug("No networks were found on this service model"); + logger.debug("No networks were found on this service model"); } else { for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { resourceCounter.add(new Resource(WorkflowType.NETWORK,service.getNetworkCustomizations().get(i).getModelCustomizationUUID(),false)); @@ -491,7 +507,7 @@ public class WorkflowAction { } } if (serviceInstanceMSO.getCollection() != null) { - msoLogger.debug("found networkcollection"); + logger.debug("found networkcollection"); aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId())); resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,serviceInstanceMSO.getCollection().getId(),false)); } @@ -613,9 +629,10 @@ public class WorkflowAction { } } } - msoLogger.debug("found " + configurations.size() + " configurations"); + logger.debug("found {} configurations" , configurations.size() ); return configurations; } catch (Exception ex){ + logger.error("Error in finding configurations", ex); return configurations; } } @@ -649,7 +666,7 @@ public class WorkflowAction { Boolean generated = false; if (m.find()) { - msoLogger.debug("found match on " + uri + ": " + m); + logger.debug("found match on {} : {} " , uri , m); String type = m.group("type"); String id = m.group("id"); String action = m.group("action"); @@ -657,7 +674,7 @@ public class WorkflowAction { throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri); } if (action == null) { - if (type.equals("serviceInstances") && (id == null || id.equals("assign"))) { + if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) { id = UUID.randomUUID().toString(); generated = true; } @@ -727,9 +744,9 @@ public class WorkflowAction { } return generatedResourceId; } catch (Exception ex) { - msoLogger.error(ex); + logger.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex); throw new IllegalStateException( - "WorkflowAction was unable to verify if the instance name already exist in AAI."); + WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI); } } @@ -737,7 +754,7 @@ public class WorkflowAction { if (!type.matches(supportedTypes)) { return type; } else { - if (type.equals("serviceInstances")) { + if (type.equals(SERVICE_INSTANCES)) { return SERVICE; } else { return type.substring(0, 1).toUpperCase() + type.substring(1, type.length() - 1); @@ -948,20 +965,19 @@ public class WorkflowAction { } protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, msg, ex); - execution.setVariable("WorkflowActionErrorMessage", msg); + logger.error(msg, ex); + execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); } protected void buildAndThrowException(DelegateExecution execution, String msg) { - msoLogger.error(msg); - execution.setVariable("WorkflowActionErrorMessage", msg); + logger.error(msg); + execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); } public void handleRuntimeException (DelegateExecution execution){ - StringBuffer wfeExpMsg = new StringBuffer("Runtime error "); + StringBuilder wfeExpMsg = new StringBuilder("Runtime error "); String runtimeErrorMessage = null; try{ String javaExpMsg = (String) execution.getVariable("BPMN_javaExpMsg"); @@ -969,10 +985,10 @@ public class WorkflowAction { wfeExpMsg = wfeExpMsg.append(": ").append(javaExpMsg); } runtimeErrorMessage = wfeExpMsg.toString(); - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, runtimeErrorMessage, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, runtimeErrorMessage); - execution.setVariable("WorkflowActionErrorMessage", runtimeErrorMessage); + logger.error(runtimeErrorMessage); + execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, runtimeErrorMessage); } catch (Exception e){ + logger.error("Runtime error", e); //if runtime message was mulformed runtimeErrorMessage = "Runtime error"; } 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 a4b40393a3..67843a7ef9 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 @@ -64,28 +64,10 @@ public class SDNCClient { STOClient.setTargetUrl(targetUrl); HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); STOClient.setHttpHeader(httpHeader); - msoLogger.info("Running SDNC CLIENT for TargetUrl: " + targetUrl); LinkedHashMap<?, ?> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); - Optional<String> sdncResponse = logSDNCResponse(output); - if(sdncResponse.isPresent()){ - msoLogger.info(sdncResponse.get()); - } - msoLogger.info("Validating output..."); return sdnCommonTasks.validateSDNResponse(output); } - protected Optional<String> logSDNCResponse(LinkedHashMap<?, ?> output) { - ObjectMapper mapper = new ObjectMapper(); - String sdncOutput = ""; - try { - sdncOutput = mapper.writeValueAsString(output); - return Optional.of(sdncOutput); - } catch (JsonProcessingException e) { - msoLogger.debug("Failed to map response from sdnc to json string for logging purposes."); - } - return Optional.empty(); - } - /** * * @param queryLink @@ -102,12 +84,9 @@ public class SDNCClient { String jsonRequest = sdnCommonTasks.buildJsonRequest(request); String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); STOClient.setTargetUrl(targetUrl); - msoLogger.info("TargetUrl: " + targetUrl); HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); STOClient.setHttpHeader(httpHeader); - msoLogger.info("Running SDNC CLIENT..."); LinkedHashMap<?, ?> output = STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); - msoLogger.info("Validating output..."); return sdnCommonTasks.validateSDNGetResponse(output); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java new file mode 100644 index 0000000000..03ed2cb4d4 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 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.infrastructure.workflow.tasks; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.junit.Before; +import org.junit.Test; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.core.WorkflowException; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.springframework.beans.factory.annotation.Autowired; + +public class FlowCompletionTasksTest extends BaseTaskTest { + + @Autowired + protected FlowCompletionTasks flowCompletionTasks; + + @Before + public void before() { + setRequestContext(); + } + + @Test + public void updateRequestDbStatusComplete_Test() throws Exception{ + InfraActiveRequests mockedRequest = new InfraActiveRequests(); + when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); + doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); + flowCompletionTasks.updateRequestDbStatus(execution); + verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class)); + assertEquals(mockedRequest.getRequestStatus(), "COMPLETE"); + } + + @Test + public void updateRequestDbStatusFailed_Test() throws Exception{ + WorkflowException workflowException = new WorkflowException("testProcessKey", 7000, "Error"); + execution.setVariable("WorkflowException", workflowException); + InfraActiveRequests mockedRequest = new InfraActiveRequests(); + when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); + doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); + flowCompletionTasks.updateRequestDbStatus(execution); + verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class)); + assertEquals(mockedRequest.getRequestStatus(), "FAILED"); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientLogResponseTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientLogResponseTest.java deleted file mode 100644 index e28c465437..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientLogResponseTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 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.client.sdnc; - -import static org.junit.Assert.*; - -import java.util.LinkedHashMap; -import java.util.Optional; - -import org.junit.Test; - -public class SDNCClientLogResponseTest { - - private SDNCClient sdncClient = new SDNCClient(); - - @Test - public void logSDNCResponseTest() { - LinkedHashMap<String, String> output = new LinkedHashMap<>(); - output.put("response-code", "404"); - output.put("response-message", "not found"); - Optional<String> response = sdncClient.logSDNCResponse(output); - assertEquals(true, response.isPresent()); - assertEquals("{\"response-code\":\"404\",\"response-message\":\"not found\"}",response.get()); - } -} |