diff options
Diffstat (limited to 'bpmn')
29 files changed, 947 insertions, 207 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionCompletion.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionCompletion.java new file mode 100644 index 0000000000..1018d7f025 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionCompletion.java @@ -0,0 +1,25 @@ +/*- + * ============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.common.listener.validation; + +public interface WorkflowActionCompletion extends WorkflowActionListener { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListener.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListener.java new file mode 100644 index 0000000000..4788c55053 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListener.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 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.listener.validation; + +import org.camunda.bpm.engine.delegate.DelegateExecution; + +public interface WorkflowActionListener { + + /** + * Should this listener run for given bb + * + * @return + * + */ + public boolean shouldRunFor(String bbName, String eventName); + + /** + * Determines whether or not the listener should be executed + * + * + * @param execution + * @return + */ + public void executeListener(DelegateExecution execution); + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListenerRunner.java new file mode 100644 index 0000000000..806c1b835d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListenerRunner.java @@ -0,0 +1,64 @@ +/*- + * ============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.common.listener.validation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import javax.annotation.PostConstruct; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.listener.ListenerRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + + + +@Component +public class WorkflowActionListenerRunner extends ListenerRunner { + + private static Logger logger = LoggerFactory.getLogger(WorkflowActionListenerRunner.class); + + protected List<WorkflowActionListener> workflowActionListeners; + + @PostConstruct + protected void init() { + workflowActionListeners = new ArrayList<>(Optional + .ofNullable(context.getBeansOfType(WorkflowActionListener.class)).orElse(new HashMap<>()).values()); + } + + public void executeAsyncListeners(String bbName, DelegateExecution execution, String eventName) { + try { + logger.info("NotifyingWorkflowActionListeners"); + runNotifications(workflowActionListeners, bbName, execution, eventName); + } catch (Exception e) { + logger.error("Error in Notifying Workflow Action Listeners", e); + } + } + + protected void runNotifications(List<? extends WorkflowActionListener> listeners, String bbName, + DelegateExecution execution, String eventName) { + List<? extends WorkflowActionListener> filtered = + filterListeners(listeners, (item -> item.shouldRunFor(bbName, eventName))); + filtered.forEach(item -> item.executeListener(execution)); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index dcb9e08d0b..fcac86b251 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -23,9 +23,7 @@ package org.onap.so.bpmn.servicedecomposition.tasks; import java.io.IOException; -import java.io.ObjectOutputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Optional; @@ -76,12 +74,11 @@ 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.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.type.TypeFactory; @Component("BBInputSetupUtils") public class BBInputSetupUtils { @@ -177,39 +174,32 @@ public class BBInputSetupUtils { } public InfraActiveRequests loadOriginalInfraActiveRequestById(String requestId) { - return this.requestsDbClient.getInfraActiveRequestbyRequestId( this.requestsDbClient.getInfraActiveRequestbyRequestId(requestId).getOriginalRequestId()); } public List<ExecuteBuildingBlock> loadOriginalFlowExecutionPath(String requestId) { - - List<ExecuteBuildingBlock> asList = null; if (requestId != null) { - InfraActiveRequests request = loadInfraActiveRequestById(requestId); - if (request.getOriginalRequestId() != null) { - RequestProcessingData requestProcessingData = this.requestsDbClient.getRequestProcessingDataBySoRequestIdAndName( request.getOriginalRequestId(), PROCESSING_DATA_NAME_EXECUTION_FLOWS); - - ObjectMapper om = new ObjectMapper(); try { - ExecuteBuildingBlock[] asArray = - om.readValue(requestProcessingData.getValue(), ExecuteBuildingBlock[].class); - asList = Arrays.asList(asArray); + ObjectMapper om = new ObjectMapper(); + TypeFactory typeFactory = objectMapper.getTypeFactory(); + return om.readValue(requestProcessingData.getValue(), + typeFactory.constructCollectionType(List.class, ExecuteBuildingBlock.class)); } catch (Exception e) { logger.error(DATA_LOAD_ERROR, e); + throw new RuntimeException("Error Loading Original Request Data", e); } + } else { + throw new RuntimeException("Original Request Id is null for record: " + requestId); } - } else { - logger.debug(REQUEST_ERROR); + throw new RuntimeException("Null Request Id Passed in"); } - - return asList; } public Service getCatalogServiceByModelUUID(String modelUUID) { diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java index 5f70ab5924..3a1e126fef 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java @@ -82,7 +82,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple String correlationValue = messageId; callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "queryVnfNotification") @@ -117,7 +117,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setOutputs(outputs); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "createVnfNotification") @@ -150,7 +150,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setRollback(rollback); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "updateVnfNotification") @@ -181,7 +181,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setRollback(rollback); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "deleteVnfNotification") @@ -208,6 +208,6 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setErrorMessage(errorMessage); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutor.java new file mode 100644 index 0000000000..56526c7f89 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutor.java @@ -0,0 +1,21 @@ +package org.onap.so.bpmn.core.plugins; + +import org.camunda.bpm.engine.delegate.ExecutionListener; +import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl; +import org.camunda.bpm.engine.impl.util.xml.Element; +import org.springframework.stereotype.Component; + +@Component +public class AsyncTaskExecutor extends AbstractBpmnParseListener { + + private void injectTaskExecutorExecutionListener(ActivityImpl activity) { + activity.addListener(ExecutionListener.EVENTNAME_END, new AsyncTaskExecutorListener()); + } + + @Override + public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity) { + injectTaskExecutorExecutionListener(activity); + } +} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutorListener.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutorListener.java new file mode 100644 index 0000000000..94f4b313d4 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutorListener.java @@ -0,0 +1,42 @@ +package org.onap.so.bpmn.core.plugins; + +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.ExecutionListener; +import org.onap.so.bpmn.common.listener.validation.WorkflowActionListenerRunner; +import org.onap.so.spring.SpringContextHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AsyncTaskExecutorListener implements ExecutionListener { + private final Logger logger = LoggerFactory.getLogger(AsyncTaskExecutorListener.class); + + + private WorkflowActionListenerRunner listenerRunner; + + @Override + public void notify(DelegateExecution execution) throws Exception { + if (!isBlank(execution.getCurrentActivityName())) { + try { + String id = execution.getId(); + if (id != null) { + RepositoryService repositoryService = execution.getProcessEngineServices().getRepositoryService(); + String processName = repositoryService.createProcessDefinitionQuery() + .processDefinitionId(execution.getProcessDefinitionId()).singleResult().getName(); + logger.info("ProcessName : {}", processName); + if (processName != null) { + listenerRunner = + SpringContextHelper.getAppContext().getBean(WorkflowActionListenerRunner.class); + listenerRunner.executeAsyncListeners(processName, execution, ExecutionListener.EVENTNAME_END); + } + } + } catch (Exception e) { + logger.error("Error occured in executing Complete Task Listeners", e); + } + } + } + + private boolean isBlank(Object object) { + return object == null || "".equals(object.toString().trim()); + } +} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/BPMNProcessCompletePlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/BPMNProcessCompletePlugin.java new file mode 100644 index 0000000000..96c6af42ed --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/BPMNProcessCompletePlugin.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * 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.core.plugins; + +import java.util.ArrayList; +import java.util.List; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener; +import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + + +@Component +public class BPMNProcessCompletePlugin extends AbstractProcessEnginePlugin { + + @Autowired + private AsyncTaskExecutor asyncTaskExecutor; + + @Override + public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { + List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners(); + if (preParseListeners == null) { + preParseListeners = new ArrayList<>(); + processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); + } + preParseListeners.add(asyncTaskExecutor); + } + +} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImplTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImplTest.java new file mode 100644 index 0000000000..d15d71a9e9 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImplTest.java @@ -0,0 +1,118 @@ +package org.onap.so.bpmn.common.workflow.service; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.common.adapter.vnf.CreateVnfNotification; +import org.onap.so.bpmn.common.adapter.vnf.DeleteVnfNotification; +import org.onap.so.bpmn.common.adapter.vnf.MsoExceptionCategory; +import org.onap.so.bpmn.common.adapter.vnf.QueryVnfNotification; +import org.onap.so.bpmn.common.adapter.vnf.RollbackVnfNotification; +import org.onap.so.bpmn.common.adapter.vnf.UpdateVnfNotification; +import org.onap.so.bpmn.common.adapter.vnf.VnfRollback; +import org.onap.so.bpmn.common.adapter.vnf.VnfStatus; +import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult; + +@RunWith(MockitoJUnitRunner.class) +public class VnfAdapterNotifyServiceImplTest { + + + @InjectMocks + @Spy + private VnfAdapterNotifyServiceImpl vnfAdapterNotifyServiceImpl; + + @Mock + private CallbackHandlerService callbackHandlerService; + + @Mock + private CallbackResult callbackResult; + + protected CreateVnfNotification.Outputs outputs = new CreateVnfNotification.Outputs(); + protected QueryVnfNotification.Outputs queryOutputs = new QueryVnfNotification.Outputs(); + protected UpdateVnfNotification.Outputs updateOutputs = new UpdateVnfNotification.Outputs(); + + protected VnfRollback vnfRollback = new VnfRollback(); + + @Test + public void rollbackVnfNotificationTest() { + doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("rollbackVnfNotification"), + any(RollbackVnfNotification.class), eq("rollbackVnfNotificationCallback"), + eq("rollbackVnfNotificationCallback"), eq("VNFRB_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + + vnfAdapterNotifyServiceImpl.rollbackVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, + "Error creating stack"); + + verify(callbackHandlerService, times(1)).handleCallback(eq("rollbackVnfNotification"), + any(RollbackVnfNotification.class), eq("rollbackVnfNotificationCallback"), + eq("rollbackVnfNotificationCallback"), eq("VNFRB_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + } + + @Test + public void queryVnfNotificationTest() { + doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("queryVnfNotification"), + any(QueryVnfNotification.class), eq("queryVnfNotificationCallback"), eq("queryVnfNotificationCallback"), + eq("VNFQ_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), eq(null)); + + vnfAdapterNotifyServiceImpl.queryVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, "", + Boolean.TRUE, "vnfid", VnfStatus.ACTIVE, queryOutputs); + + verify(callbackHandlerService, times(1)).handleCallback(eq("queryVnfNotification"), + any(QueryVnfNotification.class), eq("queryVnfNotificationCallback"), eq("queryVnfNotificationCallback"), + eq("VNFQ_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), eq(null)); + } + + @Test + public void createVnfNotificationTest() { + doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("createVnfNotification"), + any(CreateVnfNotification.class), eq("createVnfNotificationCallback"), + eq("createVnfNotificationCallback"), eq("VNFC_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + + vnfAdapterNotifyServiceImpl.createVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, "", + "vnfId", outputs, vnfRollback); + + verify(callbackHandlerService, times(1)).handleCallback(eq("createVnfNotification"), + any(CreateVnfNotification.class), eq("createVnfNotificationCallback"), + eq("createVnfNotificationCallback"), eq("VNFC_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + } + + @Test + public void updateVnfNotificationTest() { + doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("updateVnfNotification"), + any(UpdateVnfNotification.class), eq("updateVnfNotificationCallback"), + eq("updateVnfNotificationCallback"), eq("VNFU_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + + vnfAdapterNotifyServiceImpl.updateVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, "", + updateOutputs, vnfRollback); + + verify(callbackHandlerService, times(1)).handleCallback(eq("updateVnfNotification"), + any(UpdateVnfNotification.class), eq("updateVnfNotificationCallback"), + eq("updateVnfNotificationCallback"), eq("VNFU_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + } + + @Test + public void deleteVnfNotificationTest() { + doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("deleteVnfNotification"), + any(DeleteVnfNotification.class), eq("deleteVnfACallback"), eq("deleteVnfACallback"), eq("VNFDEL_uuid"), + eq("messageId"), eq("[VNF-NOTIFY]"), eq(null)); + + vnfAdapterNotifyServiceImpl.deleteVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, ""); + + verify(callbackHandlerService, times(1)).handleCallback(eq("deleteVnfNotification"), + any(DeleteVnfNotification.class), eq("deleteVnfACallback"), eq("deleteVnfACallback"), eq("VNFDEL_uuid"), + eq("messageId"), eq("[VNF-NOTIFY]"), eq(null)); + } +} 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 efdee8601e..bb900420e3 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="2.0.3"> +<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> @@ -46,7 +46,7 @@ <bpmn:outgoing>SequenceFlow_0l7kaba</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1m2eezj" name="Completed = true" sourceRef="ExclusiveGateway_Finished" targetRef="ExclusiveGateway_isTopLevelFlowC"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("completed")==true&&execution.getVariable("isRollback")==false&&execution.getVariable("handlingCode")=="Success"}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("completed")==true&&execution.getVariable("isRollback")==false&&execution.getVariable("handlingCode")=="Success"}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:serviceTask id="Task_RetrieveBBExectuionList" name="Retrieve BB Execution List" camunda:expression="${WorkflowAction.selectExecutionList(execution)}"> <bpmn:incoming>SequenceFlow_15s0okp</bpmn:incoming> @@ -54,7 +54,7 @@ </bpmn:serviceTask> <bpmn:serviceTask id="Task_SendSync" name="Send Sync Ack API Handler" camunda:asyncAfter="true" camunda:expression="${WorkflowActionBBTasks.sendSyncAck(execution)}"> <bpmn:incoming>SequenceFlow_0sckerv</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1wb59ic</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1lrz41x</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="Task_UpdateRequestComplete" name="Update Request To Complete" camunda:expression="${WorkflowActionBBTasks.updateRequestStatusToComplete(execution)}"> <bpmn:incoming>SequenceFlow_0kf5sen</bpmn:incoming> @@ -83,7 +83,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_024g0d1" name="no" sourceRef="ExclusiveGateway_10q79b6" targetRef="Task_UpdateDb" /> <bpmn:sequenceFlow id="SequenceFlow_0vi883o" name="yes" sourceRef="ExclusiveGateway_10q79b6" targetRef="Task_SendSyncAckError"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isTopLevelFlow")==true&&execution.getVariable("sentSyncResponse")==false}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isTopLevelFlow")==true&&execution.getVariable("sentSyncResponse")==false}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_0eana0l" sourceRef="Task_SendSyncAckError" targetRef="Task_UpdateDb" /> <bpmn:serviceTask id="Task_SendSyncAckError" name="Send Sync Ack API Handler" camunda:asyncAfter="true" camunda:expression="${WorkflowActionBBTasks.sendSyncAck(execution)}"> @@ -92,10 +92,10 @@ </bpmn:serviceTask> </bpmn:subProcess> <bpmn:sequenceFlow id="SequenceFlow_0v588sm" name="Rollback = true" sourceRef="ExclusiveGateway_Finished" targetRef="Task_RollbackExecutionPath"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("handlingCode")=="Rollback"||execution.getVariable("handlingCode")=="RollbackToAssigned"||execution.getVariable("handlingCode")=="RollbackToCreated"}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("handlingCode")=="Rollback"||execution.getVariable("handlingCode")=="RollbackToAssigned"||execution.getVariable("handlingCode")=="RollbackToCreated"}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1atzsgn" sourceRef="Task_RollbackExecutionPath" targetRef="Task_SelectBB"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isRollbackNeeded")==true}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isRollbackNeeded")==true}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:serviceTask id="Task_RollbackExecutionPath" name="Rollback Execution Path" camunda:expression="${WorkflowActionBBTasks.rollbackExecutionPath(execution)}"> <bpmn:incoming>SequenceFlow_0v588sm</bpmn:incoming> @@ -104,7 +104,7 @@ </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0vc9go9" sourceRef="Task_RetrieveBBExectuionList" targetRef="ExclusiveGateway_isTopLevelFlow" /> <bpmn:sequenceFlow id="SequenceFlow_11530ei" name="Abort = true" sourceRef="ExclusiveGateway_Finished" targetRef="ExclusiveGateway_isTopLevelFlowAbort"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("handlingCode")=="Abort"}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("handlingCode")=="Abort"}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:serviceTask id="Task_AbortAndCallErrorHandling" name="Update Request To Failed" camunda:expression="${WorkflowActionBBFailure.updateRequestStatusToFailed(execution)}"> <bpmn:incoming>SequenceFlow_02ksbt0</bpmn:incoming> @@ -115,7 +115,6 @@ <bpmn:incoming>SequenceFlow_1r570x3</bpmn:incoming> </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_1p8yxu6" sourceRef="Task_AbortAndCallErrorHandling" targetRef="EndEvent_0lzz1ya" /> - <bpmn:sequenceFlow id="SequenceFlow_1wb59ic" sourceRef="Task_SendSync" targetRef="Task_PreValidateWorkflow" /> <bpmn:sequenceFlow id="SequenceFlow_01j184u" sourceRef="ExclusiveGateway_Finished" targetRef="Task_0a31dkf" /> <bpmn:serviceTask id="Task_0a31dkf" name="Check Retry Status" camunda:expression="${WorkflowActionBBTasks.checkRetryStatus(execution)}"> <bpmn:incoming>SequenceFlow_01j184u</bpmn:incoming> @@ -128,7 +127,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0sckerv" name="yes" sourceRef="ExclusiveGateway_isTopLevelFlow" targetRef="Task_SendSync" /> <bpmn:sequenceFlow id="SequenceFlow_0unbew4" name="no" sourceRef="ExclusiveGateway_isTopLevelFlow" targetRef="Task_PreValidateWorkflow"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isTopLevelFlow")==false}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isTopLevelFlow")==false}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:exclusiveGateway id="ExclusiveGateway_isTopLevelFlowAbort" name="Is Top-Level Flow?" default="SequenceFlow_02ksbt0"> <bpmn:incoming>SequenceFlow_11530ei</bpmn:incoming> @@ -137,7 +136,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_02ksbt0" name="yes" sourceRef="ExclusiveGateway_isTopLevelFlowAbort" targetRef="Task_AbortAndCallErrorHandling" /> <bpmn:sequenceFlow id="SequenceFlow_1r570x3" name="no" sourceRef="ExclusiveGateway_isTopLevelFlowAbort" targetRef="EndEvent_0lzz1ya"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isTopLevelFlow")==false}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isTopLevelFlow")==false}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:exclusiveGateway id="ExclusiveGateway_isTopLevelFlowC" name="Is Top-Level Flow?" default="SequenceFlow_0kf5sen"> <bpmn:incoming>SequenceFlow_1m2eezj</bpmn:incoming> @@ -145,13 +144,13 @@ <bpmn:outgoing>SequenceFlow_0kf5sen</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0x4urgp" name="no" sourceRef="ExclusiveGateway_isTopLevelFlowC" targetRef="End_WorkflowActionBB"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isTopLevelFlow")==false}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isTopLevelFlow")==false}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:endEvent id="End_RollbackFailed" name="end"> <bpmn:incoming>SequenceFlow_1ui67mc</bpmn:incoming> </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_11dlyzt" name="Rollback Not Needed" sourceRef="Task_RollbackExecutionPath" targetRef="Task_UpdateRequestToFailed"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isRollbackNeeded")==false}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isRollbackNeeded")==false}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:serviceTask id="Task_UpdateRequestToFailed" name="Update Request To Failed" camunda:expression="${WorkflowActionBBFailure.updateRequestStatusToFailedWithRollback(execution)}"> <bpmn:incoming>SequenceFlow_11dlyzt</bpmn:incoming> @@ -159,7 +158,7 @@ <bpmn:outgoing>SequenceFlow_1ui67mc</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0l7kaba" name="Rollback Completed" sourceRef="ExclusiveGateway_Finished" targetRef="Task_UpdateRequestToFailed"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("completed")==true&&execution.getVariable("isRollback")==true&&execution.getVariable("handlingCode")=="Success"}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("completed")==true&&execution.getVariable("isRollback")==true&&execution.getVariable("handlingCode")=="Success"}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1ui67mc" sourceRef="Task_UpdateRequestToFailed" targetRef="End_RollbackFailed" /> <bpmn:subProcess id="SubProcess_0fuugr9" name="Java Exception Handling Sub Process" triggeredByEvent="true"> @@ -186,7 +185,7 @@ <bpmn:sequenceFlow id="SequenceFlow_1tfizxf" sourceRef="Task_PreValidateWorkflow" targetRef="Task_SelectBB" /> <bpmn:serviceTask id="Task_PreValidateWorkflow" name="PreValidate Workflow" camunda:expression="${WorkflowValidatorRunner.preValidate(execution.getVariable("requestAction"), execution)}"> <bpmn:incoming>SequenceFlow_0unbew4</bpmn:incoming> - <bpmn:incoming>SequenceFlow_1wb59ic</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0etawv5</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1tfizxf</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="ServiceTask_0lbkcyp" name="Post Processing Execute BB" camunda:expression="${WorkflowActionBBTasks.postProcessingExecuteBB(execution)}"> @@ -196,6 +195,19 @@ <bpmn:sequenceFlow id="SequenceFlow_1hsqed1" sourceRef="Call_ExecuteBB" targetRef="ServiceTask_0lbkcyp" /> <bpmn:sequenceFlow id="SequenceFlow_1fftixk" sourceRef="ServiceTask_0lbkcyp" targetRef="ExclusiveGateway_Finished" /> <bpmn:sequenceFlow id="SequenceFlow_1pnkpim" sourceRef="Task_0a31dkf" targetRef="Task_SelectBB" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1dez26n" name="Generated Id's?"> + <bpmn:incoming>SequenceFlow_1lrz41x</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0etawv5</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0ilo6lo</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1lrz41x" sourceRef="Task_SendSync" targetRef="ExclusiveGateway_1dez26n" /> + <bpmn:sequenceFlow id="SequenceFlow_0etawv5" name="no" sourceRef="ExclusiveGateway_1dez26n" targetRef="Task_PreValidateWorkflow"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("generateIdsOnly") == null || execution.getVariable("generateIdsOnly")==false}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="EndEvent_12f15tu" name="End"> + <bpmn:incoming>SequenceFlow_0ilo6lo</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0ilo6lo" name="yes" sourceRef="ExclusiveGateway_1dez26n" targetRef="EndEvent_12f15tu" /> </bpmn:process> <bpmn:error id="Error_0kd2o2a" name="java.lang.Exception" errorCode="java.lang.Exception" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> @@ -213,8 +225,8 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_15s0okp_di" bpmnElement="SequenceFlow_15s0okp"> - <di:waypoint x="-398" y="120" /> - <di:waypoint x="-365" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-398" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-365" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="-381" y="99" width="0" height="0" /> </bpmndi:BPMNLabel> @@ -223,8 +235,8 @@ <dc:Bounds x="560" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0mqrkxv_di" bpmnElement="SequenceFlow_0mqrkxv"> - <di:waypoint x="339" y="120" /> - <di:waypoint x="400" y="120" /> + <di:waypoint xsi:type="dc:Point" x="339" y="120" /> + <di:waypoint xsi:type="dc:Point" x="400" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="324.5" y="105" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -239,9 +251,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1m2eezj_di" bpmnElement="SequenceFlow_1m2eezj"> - <di:waypoint x="949" y="132" /> - <di:waypoint x="980" y="165" /> - <di:waypoint x="1060" y="165" /> + <di:waypoint xsi:type="dc:Point" x="949" y="132" /> + <di:waypoint xsi:type="dc:Point" x="980" y="165" /> + <di:waypoint xsi:type="dc:Point" x="1060" y="165" /> <bpmndi:BPMNLabel> <dc:Bounds x="968" y="168" width="83" height="12" /> </bpmndi:BPMNLabel> @@ -250,15 +262,15 @@ <dc:Bounds x="-365" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0654g3m_di" bpmnElement="Task_SendSync"> - <dc:Bounds x="-132" y="-6" width="100" height="80" /> + <dc:Bounds x="-100" y="-76" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0wzh11j_di" bpmnElement="Task_UpdateRequestComplete"> <dc:Bounds x="1161" y="206" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1pz6edz_di" bpmnElement="SequenceFlow_1pz6edz"> - <di:waypoint x="1261" y="246" /> - <di:waypoint x="1322" y="246" /> - <di:waypoint x="1322" y="183" /> + <di:waypoint xsi:type="dc:Point" x="1261" y="246" /> + <di:waypoint xsi:type="dc:Point" x="1322" y="246" /> + <di:waypoint xsi:type="dc:Point" x="1322" y="183" /> <bpmndi:BPMNLabel> <dc:Bounds x="1247" y="231" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -279,16 +291,16 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0v588sm_di" bpmnElement="SequenceFlow_0v588sm"> - <di:waypoint x="936" y="145" /> - <di:waypoint x="936" y="262" /> - <di:waypoint x="339" y="262" /> + <di:waypoint xsi:type="dc:Point" x="936" y="145" /> + <di:waypoint xsi:type="dc:Point" x="936" y="262" /> + <di:waypoint xsi:type="dc:Point" x="339" y="262" /> <bpmndi:BPMNLabel> <dc:Bounds x="769.202380952381" y="272" width="73" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1atzsgn_di" bpmnElement="SequenceFlow_1atzsgn"> - <di:waypoint x="289" y="222" /> - <di:waypoint x="289" y="160" /> + <di:waypoint xsi:type="dc:Point" x="289" y="222" /> + <di:waypoint xsi:type="dc:Point" x="289" y="160" /> <bpmndi:BPMNLabel> <dc:Bounds x="259" y="191" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -297,16 +309,16 @@ <dc:Bounds x="239" y="222" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0vc9go9_di" bpmnElement="SequenceFlow_0vc9go9"> - <di:waypoint x="-265" y="120" /> - <di:waypoint x="-228" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-265" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-228" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="-246" y="105" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_11530ei_di" bpmnElement="SequenceFlow_11530ei"> - <di:waypoint x="946" y="105" /> - <di:waypoint x="983" y="44" /> - <di:waypoint x="1060" y="45" /> + <di:waypoint xsi:type="dc:Point" x="946" y="105" /> + <di:waypoint xsi:type="dc:Point" x="983" y="44" /> + <di:waypoint xsi:type="dc:Point" x="1060" y="45" /> <bpmndi:BPMNLabel> <dc:Bounds x="975" y="17" width="58" height="12" /> </bpmndi:BPMNLabel> @@ -321,28 +333,19 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1p8yxu6_di" bpmnElement="SequenceFlow_1p8yxu6"> - <di:waypoint x="1276" y="-36" /> - <di:waypoint x="1359" y="-36" /> - <di:waypoint x="1359" y="45" /> - <di:waypoint x="1386" y="45" /> + <di:waypoint xsi:type="dc:Point" x="1276" y="-36" /> + <di:waypoint xsi:type="dc:Point" x="1359" y="-36" /> + <di:waypoint xsi:type="dc:Point" x="1359" y="45" /> + <di:waypoint xsi:type="dc:Point" x="1386" y="45" /> <bpmndi:BPMNLabel> <dc:Bounds x="1329" y="5" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1wb59ic_di" bpmnElement="SequenceFlow_1wb59ic"> - <di:waypoint x="-32" y="34" /> - <di:waypoint x="32" y="34" /> - <di:waypoint x="32" y="120" /> - <di:waypoint x="80" y="120" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="47" y="77" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_01j184u_di" bpmnElement="SequenceFlow_01j184u"> - <di:waypoint x="936" y="95" /> - <di:waypoint x="936" y="55" /> - <di:waypoint x="936" y="55" /> - <di:waypoint x="936" y="4" /> + <di:waypoint xsi:type="dc:Point" x="936" y="95" /> + <di:waypoint xsi:type="dc:Point" x="936" y="55" /> + <di:waypoint xsi:type="dc:Point" x="936" y="55" /> + <di:waypoint xsi:type="dc:Point" x="936" y="4" /> <bpmndi:BPMNLabel> <dc:Bounds x="906" y="49" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -357,16 +360,16 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0sckerv_di" bpmnElement="SequenceFlow_0sckerv"> - <di:waypoint x="-202" y="96" /> - <di:waypoint x="-202" y="34" /> - <di:waypoint x="-132" y="34" /> + <di:waypoint xsi:type="dc:Point" x="-202" y="96" /> + <di:waypoint xsi:type="dc:Point" x="-202" y="-36" /> + <di:waypoint xsi:type="dc:Point" x="-100" y="-36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-195" y="55.55555555555556" width="18" height="12" /> + <dc:Bounds x="-195" y="17.612903225806477" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0unbew4_di" bpmnElement="SequenceFlow_0unbew4"> - <di:waypoint x="-178" y="120" /> - <di:waypoint x="80" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-178" y="120" /> + <di:waypoint xsi:type="dc:Point" x="80" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="-87" y="99.95468180757382" width="12" height="12" /> </bpmndi:BPMNLabel> @@ -378,16 +381,16 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_02ksbt0_di" bpmnElement="SequenceFlow_02ksbt0"> - <di:waypoint x="1085" y="20" /> - <di:waypoint x="1085" y="-37" /> - <di:waypoint x="1176" y="-37" /> + <di:waypoint xsi:type="dc:Point" x="1085" y="20" /> + <di:waypoint xsi:type="dc:Point" x="1085" y="-37" /> + <di:waypoint xsi:type="dc:Point" x="1176" y="-37" /> <bpmndi:BPMNLabel> <dc:Bounds x="1091" y="-8" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1r570x3_di" bpmnElement="SequenceFlow_1r570x3"> - <di:waypoint x="1110" y="45" /> - <di:waypoint x="1386" y="45" /> + <di:waypoint xsi:type="dc:Point" x="1110" y="45" /> + <di:waypoint xsi:type="dc:Point" x="1386" y="45" /> <bpmndi:BPMNLabel> <dc:Bounds x="1242" y="20" width="12" height="12" /> </bpmndi:BPMNLabel> @@ -399,10 +402,10 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0x4urgp_di" bpmnElement="SequenceFlow_0x4urgp"> - <di:waypoint x="1110" y="165" /> - <di:waypoint x="1220" y="165" /> - <di:waypoint x="1220" y="165" /> - <di:waypoint x="1304" y="165" /> + <di:waypoint xsi:type="dc:Point" x="1110" y="165" /> + <di:waypoint xsi:type="dc:Point" x="1220" y="165" /> + <di:waypoint xsi:type="dc:Point" x="1220" y="165" /> + <di:waypoint xsi:type="dc:Point" x="1304" y="165" /> <bpmndi:BPMNLabel> <dc:Bounds x="1256" y="140" width="12" height="12" /> </bpmndi:BPMNLabel> @@ -414,9 +417,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_11dlyzt_di" bpmnElement="SequenceFlow_11dlyzt"> - <di:waypoint x="289" y="302" /> - <di:waypoint x="289" y="368" /> - <di:waypoint x="960" y="368" /> + <di:waypoint xsi:type="dc:Point" x="289" y="302" /> + <di:waypoint xsi:type="dc:Point" x="289" y="368" /> + <di:waypoint xsi:type="dc:Point" x="960" y="368" /> <bpmndi:BPMNLabel> <dc:Bounds x="381.45685840707966" y="325" width="63" height="24" /> </bpmndi:BPMNLabel> @@ -428,33 +431,33 @@ <dc:Bounds x="960" y="325" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0l7kaba_di" bpmnElement="SequenceFlow_0l7kaba"> - <di:waypoint x="942" y="139" /> - <di:waypoint x="976" y="252" /> - <di:waypoint x="1016" y="252" /> - <di:waypoint x="1016" y="325" /> + <di:waypoint xsi:type="dc:Point" x="942" y="139" /> + <di:waypoint xsi:type="dc:Point" x="976" y="252" /> + <di:waypoint xsi:type="dc:Point" x="1016" y="252" /> + <di:waypoint xsi:type="dc:Point" x="1016" y="325" /> <bpmndi:BPMNLabel> <dc:Bounds x="959" y="255" width="52" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1edjl5x_di" bpmnElement="SequenceFlow_1edjl5x"> - <di:waypoint x="556" y="657" /> - <di:waypoint x="602" y="657" /> + <di:waypoint xsi:type="dc:Point" x="556" y="657" /> + <di:waypoint xsi:type="dc:Point" x="602" y="657" /> <bpmndi:BPMNLabel> <dc:Bounds x="534" y="636" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0wvzfgf_di" bpmnElement="SequenceFlow_0wvzfgf"> - <di:waypoint x="813" y="657" /> - <di:waypoint x="880" y="657" /> + <di:waypoint xsi:type="dc:Point" x="813" y="657" /> + <di:waypoint xsi:type="dc:Point" x="880" y="657" /> <bpmndi:BPMNLabel> <dc:Bounds x="801.5" y="636" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1ui67mc_di" bpmnElement="SequenceFlow_1ui67mc"> - <di:waypoint x="1060" y="365" /> - <di:waypoint x="1134" y="365" /> - <di:waypoint x="1134" y="365" /> - <di:waypoint x="1159" y="365" /> + <di:waypoint xsi:type="dc:Point" x="1060" y="365" /> + <di:waypoint xsi:type="dc:Point" x="1134" y="365" /> + <di:waypoint xsi:type="dc:Point" x="1134" y="365" /> + <di:waypoint xsi:type="dc:Point" x="1159" y="365" /> <bpmndi:BPMNLabel> <dc:Bounds x="1104" y="359" width="90" height="13" /> </bpmndi:BPMNLabel> @@ -466,25 +469,25 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_024g0d1_di" bpmnElement="SequenceFlow_024g0d1"> - <di:waypoint x="652" y="657" /> - <di:waypoint x="683" y="657" /> - <di:waypoint x="683" y="657" /> - <di:waypoint x="713" y="657" /> + <di:waypoint xsi:type="dc:Point" x="652" y="657" /> + <di:waypoint xsi:type="dc:Point" x="683" y="657" /> + <di:waypoint xsi:type="dc:Point" x="683" y="657" /> + <di:waypoint xsi:type="dc:Point" x="713" y="657" /> <bpmndi:BPMNLabel> <dc:Bounds x="677" y="634" width="12" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0vi883o_di" bpmnElement="SequenceFlow_0vi883o"> - <di:waypoint x="627" y="632" /> - <di:waypoint x="627" y="548" /> - <di:waypoint x="713" y="548" /> + <di:waypoint xsi:type="dc:Point" x="627" y="632" /> + <di:waypoint xsi:type="dc:Point" x="627" y="548" /> + <di:waypoint xsi:type="dc:Point" x="713" y="548" /> <bpmndi:BPMNLabel> <dc:Bounds x="633" y="584" width="18" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0eana0l_di" bpmnElement="SequenceFlow_0eana0l"> - <di:waypoint x="763" y="588" /> - <di:waypoint x="763" y="617" /> + <di:waypoint xsi:type="dc:Point" x="763" y="588" /> + <di:waypoint xsi:type="dc:Point" x="763" y="617" /> <bpmndi:BPMNLabel> <dc:Bounds x="778" y="596.5" width="0" height="12" /> </bpmndi:BPMNLabel> @@ -511,15 +514,15 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_11d126w_di" bpmnElement="SequenceFlow_11d126w"> - <di:waypoint x="606" y="875" /> - <di:waypoint x="690" y="875" /> + <di:waypoint xsi:type="dc:Point" x="606" y="875" /> + <di:waypoint xsi:type="dc:Point" x="690" y="875" /> <bpmndi:BPMNLabel> <dc:Bounds x="603" y="854" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0w4sx88_di" bpmnElement="SequenceFlow_0w4sx88"> - <di:waypoint x="790" y="875" /> - <di:waypoint x="856" y="875" /> + <di:waypoint xsi:type="dc:Point" x="790" y="875" /> + <di:waypoint xsi:type="dc:Point" x="856" y="875" /> <bpmndi:BPMNLabel> <dc:Bounds x="778" y="854" width="0" height="12" /> </bpmndi:BPMNLabel> @@ -528,25 +531,25 @@ <dc:Bounds x="400" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0mew9im_di" bpmnElement="SequenceFlow_0mew9im"> - <di:waypoint x="500" y="120" /> - <di:waypoint x="560" y="120" /> + <di:waypoint xsi:type="dc:Point" x="500" y="120" /> + <di:waypoint xsi:type="dc:Point" x="560" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="530" y="99" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0kf5sen_di" bpmnElement="SequenceFlow_0kf5sen"> - <di:waypoint x="1085" y="190" /> - <di:waypoint x="1085" y="246" /> - <di:waypoint x="1161" y="246" /> + <di:waypoint xsi:type="dc:Point" x="1085" y="190" /> + <di:waypoint xsi:type="dc:Point" x="1085" y="246" /> + <di:waypoint xsi:type="dc:Point" x="1161" y="246" /> <bpmndi:BPMNLabel> <dc:Bounds x="1091" y="218" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1tfizxf_di" bpmnElement="SequenceFlow_1tfizxf"> - <di:waypoint x="180" y="120" /> - <di:waypoint x="211" y="120" /> - <di:waypoint x="211" y="120" /> - <di:waypoint x="239" y="120" /> + <di:waypoint xsi:type="dc:Point" x="180" y="120" /> + <di:waypoint xsi:type="dc:Point" x="211" y="120" /> + <di:waypoint xsi:type="dc:Point" x="211" y="120" /> + <di:waypoint xsi:type="dc:Point" x="239" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="226" y="120" width="0" height="0" /> </bpmndi:BPMNLabel> @@ -558,27 +561,60 @@ <dc:Bounds x="735" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1hsqed1_di" bpmnElement="SequenceFlow_1hsqed1"> - <di:waypoint x="660" y="120" /> - <di:waypoint x="735" y="120" /> + <di:waypoint xsi:type="dc:Point" x="660" y="120" /> + <di:waypoint xsi:type="dc:Point" x="735" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="697.5" y="99" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1fftixk_di" bpmnElement="SequenceFlow_1fftixk"> - <di:waypoint x="835" y="120" /> - <di:waypoint x="911" y="120" /> + <di:waypoint xsi:type="dc:Point" x="835" y="120" /> + <di:waypoint xsi:type="dc:Point" x="911" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="873" y="99" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1pnkpim_di" bpmnElement="SequenceFlow_1pnkpim"> - <di:waypoint x="886" y="-36" /> - <di:waypoint x="289" y="-36" /> - <di:waypoint x="289" y="80" /> + <di:waypoint xsi:type="dc:Point" x="886" y="-36" /> + <di:waypoint xsi:type="dc:Point" x="289" y="-36" /> + <di:waypoint xsi:type="dc:Point" x="289" y="80" /> <bpmndi:BPMNLabel> <dc:Bounds x="587.5" y="-57" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_1dez26n_di" bpmnElement="ExclusiveGateway_1dez26n" isMarkerVisible="true"> + <dc:Bounds x="105" y="-61" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="163" y="-48" width="61" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1lrz41x_di" bpmnElement="SequenceFlow_1lrz41x"> + <di:waypoint xsi:type="dc:Point" x="0" y="-36" /> + <di:waypoint xsi:type="dc:Point" x="105" y="-36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="52.5" y="-57" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0etawv5_di" bpmnElement="SequenceFlow_0etawv5"> + <di:waypoint xsi:type="dc:Point" x="130" y="-11" /> + <di:waypoint xsi:type="dc:Point" x="130" y="80" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="139" y="29" width="12" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_12f15tu_di" bpmnElement="EndEvent_12f15tu"> + <dc:Bounds x="112" y="-169.83592938733125" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="120" y="-195" width="19" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0ilo6lo_di" bpmnElement="SequenceFlow_0ilo6lo"> + <di:waypoint xsi:type="dc:Point" x="130" y="-61" /> + <di:waypoint xsi:type="dc:Point" x="130" y="-134" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="136" y="-103" width="19" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java index 8010ce62ab..a932e4ac50 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java @@ -28,6 +28,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.Spliterator; @@ -41,6 +42,9 @@ public final class JsonUtilForPnfCorrelationId { } static List<String> parseJsonToGelAllPnfCorrelationId(String json) { + if (json == null || json.isEmpty()) { + return Collections.emptyList(); + } JsonElement je = new JsonParser().parse(json); JsonArray array = je.getAsJsonArray(); List<String> list = new ArrayList<>(); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java index 02303a6b23..bd1a45c64d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java @@ -23,12 +23,14 @@ package org.onap.so.bpmn.infrastructure.pnf.dmaap; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javax.ws.rs.core.UriBuilder; import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; @@ -42,6 +44,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.AAIObjectType; +import static org.onap.so.bpmn.infrastructure.pnf.dmaap.JsonUtilForPnfCorrelationId.*; @Component public class PnfEventReadyDmaapClient implements DmaapClient { @@ -129,15 +132,10 @@ public class PnfEventReadyDmaapClient implements DmaapClient { try { logger.debug("dmaap listener starts listening pnf ready dmaap topic"); HttpResponse response = httpClient.execute(getRequest); - List<String> idList = getPnfCorrelationIdListFromResponse(response); - - // idList is never null - if (!idList.isEmpty()) { - // send only body of response - registerClientResponse(idList.get(0), EntityUtils.toString(response.getEntity(), "UTF-8")); - } - - if (idList != null) { + if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { + String responseString = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); + List<String> idList = parseJsonToGelAllPnfCorrelationId(responseString); + idList.stream().findFirst().ifPresent(id -> registerClientResponse(id, responseString)); idList.forEach(this::informAboutPnfReadyIfPnfCorrelationIdFound); } } catch (IOException e) { @@ -147,16 +145,6 @@ public class PnfEventReadyDmaapClient implements DmaapClient { } } - private List<String> getPnfCorrelationIdListFromResponse(HttpResponse response) throws IOException { - if (response.getStatusLine().getStatusCode() == 200) { - String responseString = EntityUtils.toString(response.getEntity(), "UTF-8"); - if (responseString != null) { - return JsonUtilForPnfCorrelationId.parseJsonToGelAllPnfCorrelationId(responseString); - } - } - return Collections.emptyList(); - } - private void informAboutPnfReadyIfPnfCorrelationIdFound(String pnfCorrelationId) { Runnable runnable = unregister(pnfCorrelationId); if (runnable != null) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceDataTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceDataTest.groovy index afbace76d6..715a7dff6d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceDataTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceDataTest.groovy @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 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.scripts import org.camunda.bpm.engine.delegate.BpmnError diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java index 8741208d26..4edee24531 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java @@ -63,4 +63,13 @@ public class JsonUtilForPnfCorrelationIdTest { assertThat(expectedResult).isEmpty(); } + @Test + public void shouldReturnEmptyListWhenInputIsNull() { + assertThat(JsonUtilForPnfCorrelationId.parseJsonToGelAllPnfCorrelationId(null)).isEmpty(); + } + + @Test + public void shouldReturnEmptyListWhenInputIsEmpty() { + assertThat(JsonUtilForPnfCorrelationId.parseJsonToGelAllPnfCorrelationId("")).isEmpty(); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java index 19e08d9d59..cccfe0c762 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java @@ -30,8 +30,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; +import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -41,7 +41,7 @@ import org.apache.http.HttpResponse; import org.apache.http.ProtocolVersion; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; -import org.apache.http.entity.StringEntity; +import org.apache.http.entity.InputStreamEntity; import org.apache.http.message.BasicHttpResponse; import org.junit.Before; import org.junit.Test; @@ -182,8 +182,8 @@ public class PnfEventReadyDmaapClientTest { threadRunFlag.setAccessible(false); } - private HttpResponse createResponse(String json) throws UnsupportedEncodingException { - HttpEntity entity = new StringEntity(json); + private HttpResponse createResponse(String json) { + HttpEntity entity = new InputStreamEntity(new ByteArrayInputStream(json.getBytes())); ProtocolVersion protocolVersion = new ProtocolVersion("", 1, 1); HttpResponse response = new BasicHttpResponse(protocolVersion, 1, ""); response.setEntity(entity); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java index 4e74e5d414..c223d3ff11 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java @@ -2,14 +2,15 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) Copyright (C) 2018 Bell Canada. + * Copyright (C) 2018 Bell Canada. + * Copyright (C) 2019 Nokia. * ================================================================================ * 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. @@ -20,7 +21,6 @@ package org.onap.so.bpmn.buildingblock; -import java.util.Map; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -28,37 +28,37 @@ import org.springframework.stereotype.Component; @Component public class HomingV2 { - @Autowired - private OofHomingV2 oofHomingV2; - @Autowired + static final String HOMING_SNIRO = "sniro"; + static final String HOMING_OOF = "oof"; + static final String HOMING_SOLUTION = "Homing_Solution"; + private SniroHomingV2 sniroHomingV2; + private OofHomingV2 oofHomingV2; - private static final String HOMINGSOLUTION = "Homing_Solution"; + @Autowired + public HomingV2(OofHomingV2 oofHomingV2, SniroHomingV2 sniroHomingV2) { + this.oofHomingV2 = oofHomingV2; + this.sniroHomingV2 = sniroHomingV2; + } public void callHoming(BuildingBlockExecution execution) { - if (isOof(execution)) { - oofHomingV2.callOof(execution); - } else { + if (isSniro(execution)) { sniroHomingV2.callSniro(execution); + } else { + oofHomingV2.callOof(execution); } } public void processSolution(BuildingBlockExecution execution, String asyncResponse) { - if (isOof(execution)) { - oofHomingV2.processSolution(execution, asyncResponse); - } else { + if (isSniro(execution)) { sniroHomingV2.processSolution(execution, asyncResponse); + } else { + oofHomingV2.processSolution(execution, asyncResponse); } } - // Default solution is SNIRO. OOF gets called only if specified. - private boolean isOof(BuildingBlockExecution execution) { - for (Map<String, Object> params : execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters() - .getUserParams()) { - if (params.containsKey(HOMINGSOLUTION) && ("oof").equals(params.get(HOMINGSOLUTION))) { - return true; - } - } - return false; + private boolean isSniro(BuildingBlockExecution execution) { + return execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters().getUserParams().stream() + .anyMatch(params -> HOMING_SNIRO.equals(params.get(HOMING_SOLUTION))); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index 9c72d229b2..79ccd9216f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -24,6 +24,7 @@ package org.onap.so.bpmn.infrastructure.appc.tasks; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import org.onap.so.logger.LoggingAnchor; import org.json.JSONArray; @@ -31,6 +32,7 @@ import org.json.JSONObject; import org.onap.aai.domain.yang.Vserver; import org.onap.appc.client.lcm.model.Action; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -166,6 +168,10 @@ public class AppcRunTasks { String pay = requestParameters.getPayload(); if (pay != null) { payload = Optional.of(pay); + } else { + String payloadFromUserParams = + buildPayloadFromUserParams(gBBInput.getRequestContext().getUserParams()); + payload = Optional.of(payloadFromUserParams); } } logger.debug("Running APP-C action: {}", action.toString()); @@ -221,6 +227,21 @@ public class AppcRunTasks { return payloadInfo; } + protected String buildPayloadFromUserParams(Map<String, Object> userParams) { + if (userParams == null || userParams.size() == 0) { + return null; + } + + String payload = "{}"; + for (Map.Entry<String, Object> entry : userParams.entrySet()) { + payload = JsonUtils.addJsonValue(payload, entry.getKey(), (String) entry.getValue()); + } + + payload = payload.replaceAll("\"", "\\\\\""); + payload = payload.replaceAll("\n", ""); + return payload; + } + protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws Exception { AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/exceptions/UnassignNetworkException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/exceptions/UnassignNetworkException.java new file mode 100644 index 0000000000..566cdccd50 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/exceptions/UnassignNetworkException.java @@ -0,0 +1,14 @@ +package org.onap.so.bpmn.infrastructure.flowspecific.exceptions; + +public class UnassignNetworkException extends Exception { + + private static final long serialVersionUID = 2864418350216433736L; + + public UnassignNetworkException() { + super(); + } + + public UnassignNetworkException(String message) { + super(message); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java index c9a937b824..f95e7afed9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java @@ -24,19 +24,22 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; import java.util.Optional; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.flowspecific.exceptions.UnassignNetworkException; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAINetworkResources; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class UnassignNetworkBB { - + private static final Logger logger = LoggerFactory.getLogger(UnassignNetworkBB.class); private static String messageCannotPerformUnassign = "Cannot perform Unassign Network. Network is still related to "; private static String messageErrorRollback = " Rollback is not possible. Please restore data manually."; @@ -71,7 +74,8 @@ public class UnassignNetworkBB { if (networkBBUtils.isRelationshipRelatedToExists(network, relatedToValue)) { String msg = messageCannotPerformUnassign + relatedToValue; execution.setVariable("ErrorUnassignNetworkBB", msg); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + logger.error("ErrorUnassignNetworkBB: {}", msg); + throw new UnassignNetworkException(msg); } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); 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 index e809ecd0ae..206942fcb1 100644 --- 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 @@ -20,27 +20,14 @@ 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 { @@ -50,7 +37,9 @@ public class FlowCompletionTasks { @Autowired private RequestsDbClient requestDbclient; + public void updateRequestDbStatus(BuildingBlockExecution execution) { + try { String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId(); InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); 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 1f07166b60..11c6455474 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 @@ -197,7 +197,9 @@ public class WorkflowAction { suppressRollback = false; } execution.setVariable("suppressRollback", suppressRollback); + boolean isResume = false; if (isUriResume(uri)) { + isResume = true; logger.debug("replacing URI {}", uri); uri = bbInputSetupUtils.loadOriginalInfraActiveRequestById(requestId).getRequestUrl(); logger.debug("for RESUME with original value {}", uri); @@ -225,6 +227,12 @@ public class WorkflowAction { if (flowsToExecute == null) { buildAndThrowException(execution, "Could not resume Macro flow. Error loading execution path."); } + } else if (aLaCarte && isResume) { + flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId); + if (flowsToExecute == null) { + buildAndThrowException(execution, + "Could not resume request with request Id: " + requestId + ". No flowsToExecute was found"); + } } else { if (aLaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { @@ -387,7 +395,7 @@ public class WorkflowAction { flowNames.add(ebb.getBuildingBlock().getBpmnFlowName()); } - if (!aLaCarte) { + if (!isResume) { bbInputSetupUtils.persistFlowExecutionPath(requestId, flowsToExecute); } execution.setVariable("flowNames", flowNames); 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 be3e06c9ea..56cd9fd70f 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 @@ -39,6 +39,8 @@ import org.springframework.stereotype.Component; @Component public class WorkflowActionBBFailure { + private static final String DEACTIVATE_FABRIC_CONFIGURATION_FLOW = "DeactivateFabricConfigurationBB"; + private static final String UNASSIGN_FABRIC_CONFIGURATION_FLOW = "UnassignFabricConfigurationBB"; private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBFailure.class); public static final String ROLLBACK_TARGET_STATE = "rollbackTargetState"; @Autowired @@ -96,6 +98,16 @@ public class WorkflowActionBBFailure { String rollbackTargetState = (String) execution.getVariable(ROLLBACK_TARGET_STATE); request.setRequestStatus(rollbackTargetState); } else if (isRollbackFailure) { + if (ebb != null && ebb.getBuildingBlock() != null && ebb.getBuildingBlock().getBpmnFlowName() != null) { + String flowName = ebb.getBuildingBlock().getBpmnFlowName(); + if (DEACTIVATE_FABRIC_CONFIGURATION_FLOW.equalsIgnoreCase(flowName) + || UNASSIGN_FABRIC_CONFIGURATION_FLOW.equalsIgnoreCase(flowName)) { + String statusMessage = String.format( + "%s Warning: The vf-module is active but configuration was not removed completely for one or more VMs.", + request.getStatusMessage()); + request.setStatusMessage(statusMessage); + } + } Optional<String> rollbackErrorMsgOp = retrieveErrorMessage(execution); if (rollbackErrorMsgOp.isPresent()) { rollbackErrorMsg = rollbackErrorMsgOp.get(); 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 d5798150d1..39aa9d6c41 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 @@ -38,6 +38,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.Configuration; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -309,7 +310,8 @@ public class WorkflowActionBBTasks { rollbackFlowsFiltered.addAll(rollbackFlows); if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode)) { for (int i = 0; i < rollbackFlows.size(); i++) { - if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Unassign")) { + if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Unassign") && !rollbackFlows + .get(i).getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) { rollbackFlowsFiltered.remove(rollbackFlows.get(i)); } else if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Delete") && ROLLBACKTOCREATED.equals(handlingCode)) { @@ -398,7 +400,7 @@ public class WorkflowActionBBTasks { if (fabricConfig != null && fabricConfig.getConfigurationResource() != null && fabricConfig.getConfigurationResource().getToscaNodeType() != null && fabricConfig.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) { - String configurationId = UUID.randomUUID().toString(); + String configurationId = getConfigurationId(vnfc); ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId); configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID); @@ -429,6 +431,17 @@ public class WorkflowActionBBTasks { } } + protected String getConfigurationId(Vnfc vnfc) { + List<Configuration> configurations = + workflowAction.getRelatedResourcesInVnfc(vnfc, Configuration.class, AAIObjectType.CONFIGURATION); + if (!configurations.isEmpty()) { + Configuration configuration = configurations.get(0); + return configuration.getConfigurationId(); + } else { + return UUID.randomUUID().toString(); + } + } + protected ExecuteBuildingBlock getExecuteBBForConfig(String bbName, ExecuteBuildingBlock ebb, String configurationId, ConfigurationResourceKeys configurationResourceKeys) { ExecuteBuildingBlock configBB = new ExecuteBuildingBlock(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/buildingblock/HomingV2Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/buildingblock/HomingV2Test.java new file mode 100644 index 0000000000..9dd0365e7a --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/buildingblock/HomingV2Test.java @@ -0,0 +1,149 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Nokia. + * ================================================================================ + * 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.buildingblock; + +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.buildingblock.HomingV2.HOMING_OOF; +import static org.onap.so.bpmn.buildingblock.HomingV2.HOMING_SNIRO; +import static org.onap.so.bpmn.buildingblock.HomingV2.HOMING_SOLUTION; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.Test; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; + +public class HomingV2Test { + + @Test + public void whenHomingSolutionSetToSniroShouldCallSniro() { + HashMap<String, Object> userParams = new HashMap<>(); + userParams.put(HOMING_SOLUTION, HOMING_SNIRO); + BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(userParams); + + OofHomingV2 oofHoming = mock(OofHomingV2.class); + SniroHomingV2 sniroHoming = mock(SniroHomingV2.class); + + HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming); + homingV2.callHoming(givenExecution); + + then(sniroHoming).should().callSniro(givenExecution); + then(oofHoming).shouldHaveZeroInteractions(); + } + + @Test + public void whenHomingSolutionSetToSniroShouldProcessSniro() { + HashMap<String, Object> userParams = new HashMap<>(); + userParams.put(HOMING_SOLUTION, HOMING_SNIRO); + BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(userParams); + + OofHomingV2 oofHoming = mock(OofHomingV2.class); + SniroHomingV2 sniroHoming = mock(SniroHomingV2.class); + + HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming); + homingV2.processSolution(givenExecution, "dummy"); + + then(sniroHoming).should().processSolution(givenExecution, "dummy"); + then(oofHoming).shouldHaveZeroInteractions(); + } + + @Test + public void whenHomingSolutionSetToOofShouldCallOof() { + HashMap<String, Object> userParams = new HashMap<>(); + userParams.put(HOMING_SOLUTION, HOMING_OOF); + BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(userParams); + + OofHomingV2 oofHoming = mock(OofHomingV2.class); + SniroHomingV2 sniroHoming = mock(SniroHomingV2.class); + + HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming); + homingV2.callHoming(givenExecution); + + then(oofHoming).should().callOof(givenExecution); + then(sniroHoming).shouldHaveZeroInteractions(); + } + + @Test + public void whenHomingSolutionSetToOofShouldProcessOof() { + HashMap<String, Object> userParams = new HashMap<>(); + userParams.put(HOMING_SOLUTION, HOMING_OOF); + BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(userParams); + + OofHomingV2 oofHoming = mock(OofHomingV2.class); + SniroHomingV2 sniroHoming = mock(SniroHomingV2.class); + + HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming); + homingV2.processSolution(givenExecution, "dummy"); + + then(oofHoming).should().processSolution(givenExecution, "dummy"); + then(sniroHoming).shouldHaveZeroInteractions(); + } + + @Test + public void whenHomingSolutionNotSetShouldCallOof() { + BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(new HashMap<>()); + + OofHomingV2 oofHoming = mock(OofHomingV2.class); + SniroHomingV2 sniroHoming = mock(SniroHomingV2.class); + + HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming); + homingV2.callHoming(givenExecution); + + then(oofHoming).should().callOof(givenExecution); + then(sniroHoming).shouldHaveZeroInteractions(); + } + + @Test + public void whenHomingSolutionNotSetShouldProcessOof() { + BuildingBlockExecution givenExecution = createBuildingBlockExecutionMock(new HashMap<>()); + + OofHomingV2 oofHoming = mock(OofHomingV2.class); + SniroHomingV2 sniroHoming = mock(SniroHomingV2.class); + + HomingV2 homingV2 = new HomingV2(oofHoming, sniroHoming); + homingV2.processSolution(givenExecution, "dummy"); + + then(oofHoming).should().processSolution(givenExecution, "dummy"); + then(sniroHoming).shouldHaveZeroInteractions(); + } + + private BuildingBlockExecution createBuildingBlockExecutionMock(Map<String, Object> userParams) { + BuildingBlockExecution execution = mock(BuildingBlockExecution.class); + GeneralBuildingBlock generalBuildingBlock = mock(GeneralBuildingBlock.class); + RequestContext requestContext = mock(RequestContext.class); + RequestParameters requestParameters = mock(RequestParameters.class); + List<Map<String, Object>> userParamsList = new ArrayList<>(); + + userParamsList.add(userParams); + + when(execution.getGeneralBuildingBlock()).thenReturn(generalBuildingBlock); + when(generalBuildingBlock.getRequestContext()).thenReturn(requestContext); + when(requestContext.getRequestParameters()).thenReturn(requestParameters); + when(requestParameters.getUserParams()).thenReturn(userParamsList); + + return execution; + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java index cc25689358..f0c333007e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java @@ -33,6 +33,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import org.junit.Test; import org.mockito.InjectMocks; @@ -168,6 +170,21 @@ public class AppcRunTasksTest extends BaseTaskTest { assertEquals(vmIdList, expectedVmIdList); } + @Test + public void testUserParams() throws Exception { + Map<String, Object> userParams = new HashMap<String, Object>(); + userParams.put("existing_software_version", "3.1"); + userParams.put("new_software_version", "3.2"); + userParams.put("operations_timeout", "150000"); + + String actualPayload = appcRunTasks.buildPayloadFromUserParams(userParams); + System.out.println(actualPayload); + String expectedPayload = + "{\\\"operations_timeout\\\":\\\"150000\\\",\\\"existing_software_version\\\":\\\"3.1\\\",\\\"new_software_version\\\":\\\"3.2\\\"}"; + assertEquals(expectedPayload, actualPayload.replaceAll(" ", "")); + + } + private void mockReferenceResponse() { ControllerSelectionReference reference = new ControllerSelectionReference(); reference.setControllerName("TEST-CONTROLLER-NAME"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java index bacc57758b..ed55c56231 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java @@ -40,9 +40,7 @@ import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; -import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.springframework.beans.factory.annotation.Autowired; public class UnassignNetworkBBTest extends BaseTaskTest { @@ -84,6 +82,15 @@ public class UnassignNetworkBBTest extends BaseTaskTest { } @Test + public void checkRelationshipRelatedToUnassignNetworkExceptionTest() throws Exception { + String msg = "Cannot perform Unassign Network. Network is still related to vf-module"; + expectedException.expect(BpmnError.class); + doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module")); + unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module"); + assertEquals(execution.getVariable("ErrorUnassignNetworkBB"), msg); + } + + @Test public void getCloudSdncRegion25Test() throws Exception { CloudRegion cloudRegion = setCloudRegion(); cloudRegion.setCloudRegionVersion("2.5"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java index 2d48d02774..573601b20f 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java @@ -41,6 +41,8 @@ import org.mockito.Spy; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -140,6 +142,31 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest { } @Test + public void updateRequestStatusToFailedRollbackFabric() { + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); + BuildingBlock bb = new BuildingBlock(); + bb.setBpmnFlowName("UnassignFabricConfigurationBB"); + ebb.setBuildingBlock(bb); + execution.setVariable("buildingBlock", ebb); + execution.setVariable("mso-request-id", "123"); + execution.setVariable("isRollbackComplete", false); + execution.setVariable("isRollback", true); + InfraActiveRequests req = new InfraActiveRequests(); + req.setStatusMessage("PINC failure."); + WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback"); + execution.setVariable("WorkflowException", wfe); + doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123"); + doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class)); + workflowActionBBFailure.updateRequestStatusToFailed(execution); + String errorMsg = (String) execution.getVariable("RollbackErrorMessage"); + assertEquals("error in rollback", errorMsg); + assertEquals( + "PINC failure. Warning: The vf-module is active but configuration was not removed completely for one or more VMs.", + req.getStatusMessage()); + assertEquals(Status.FAILED.toString(), req.getRequestStatus()); + } + + @Test public void updateRequestStatusToRolledback() { execution.setVariable("mso-request-id", "123"); execution.setVariable("isRollbackComplete", true); 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 aac09b4475..ac7d82cd51 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 @@ -328,6 +328,51 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void rollbackExecutionRollbackToAssignedWithFabricTest() { + execution.setVariable("isRollback", false); + execution.setVariable("handlingCode", "RollbackToAssigned"); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); + BuildingBlock bb1 = new BuildingBlock(); + bb1.setBpmnFlowName("AssignVfModuleBB"); + ebb1.setBuildingBlock(bb1); + flowsToExecute.add(ebb1); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); + BuildingBlock bb2 = new BuildingBlock(); + bb2.setBpmnFlowName("CreateVfModuleBB"); + ebb2.setBuildingBlock(bb2); + flowsToExecute.add(ebb2); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); + BuildingBlock bb3 = new BuildingBlock(); + bb3.setBpmnFlowName("ActivateVfModuleBB"); + ebb3.setBuildingBlock(bb3); + flowsToExecute.add(ebb3); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); + BuildingBlock bb4 = new BuildingBlock(); + bb4.setBpmnFlowName("AssignFabricConfigurationBB"); + ebb4.setBuildingBlock(bb4); + flowsToExecute.add(ebb4); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock(); + BuildingBlock bb5 = new BuildingBlock(); + bb5.setBpmnFlowName("ActivateFabricConfigurationBB"); + ebb5.setBuildingBlock(bb5); + flowsToExecute.add(ebb5); + + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("gCurrentSequence", 5); + + workflowActionBBTasks.rollbackExecutionPath(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEquals(0, execution.getVariable("gCurrentSequence")); + assertEquals(4, ebbs.size()); + assertEquals("DeactivateFabricConfigurationBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName()); + assertEquals("UnassignFabricConfigurationBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName()); + assertEquals("DeactivateVfModuleBB", ebbs.get(2).getBuildingBlock().getBpmnFlowName()); + assertEquals("DeleteVfModuleBB", ebbs.get(3).getBuildingBlock().getBpmnFlowName()); + + } + + @Test public void rollbackExecutionRollbackToCreatedTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "RollbackToCreated"); @@ -417,4 +462,22 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { workflowActionBBTasks.updateInstanceId(execution); Mockito.verify(reqMock, Mockito.times(1)).setServiceInstanceId(instanceId); } + + @Test + public void getConfigurationId() { + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("modelInvariantId"); + vnfc.setVnfcName("testVnfcName"); + List<org.onap.aai.domain.yang.Configuration> configurations = + new ArrayList<org.onap.aai.domain.yang.Configuration>(); + org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); + configuration.setConfigurationId("configurationId"); + configuration.setModelCustomizationId("modelCustimizationId"); + configuration.setConfigurationName("testConfigurationName"); + configurations.add(configuration); + doReturn(configurations.get(0).getConfigurationId()).when(workflowActionBBTasks).getConfigurationId(vnfc); + assertEquals(workflowActionBBTasks.getConfigurationId(vnfc), "configurationId"); + } + + } 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 eea885288e..be6fc94890 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 @@ -45,11 +45,9 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.UUID; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; @@ -66,7 +64,6 @@ import org.mockito.Spy; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.L3Network; -import org.onap.aai.domain.yang.L3Networks; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.ServiceInstance; @@ -80,7 +77,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -103,8 +99,6 @@ import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; -import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.beans.RequestProcessingData; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.RequestParameters; @@ -1476,9 +1470,19 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test + public void extractResourceIdAndTypeFromUriResumeTest() { + Resource resource = workflowAction.extractResourceIdAndTypeFromUri( + "http://localhost:9100/onap/so/infra/serviceInstantiation/v7/serviceInstances/4ff87c63-461b-4d83-8121-d351e6db216c/vnfs/eea9b93b-b5b9-4fad-9c35-12d52e4b683f/vfModules/33cb74cd-9cb3-4090-a3c0-1b8c8e235847/resume"); + assertEquals(resource.getResourceId(), "33cb74cd-9cb3-4090-a3c0-1b8c8e235847"); + } + + @Test public void isUriResumeTest() { assertTrue(workflowAction.isUriResume( "http://localhost:9100/onap/so/infra/orchestrationRequests/v7/requests/2f8ab587-ef6a-4456-b7b2-d73f9363dabd/resume")); + assertTrue(workflowAction.isUriResume( + " http://localhost:9100/onap/so/infra/serviceInstantiation/v7/serviceInstances/4ff87c63-461b-4d83-8121-d351e6db216c/vnfs/eea9b93b-b5b9-4fad-9c35-12d52e4b683f/vfModules/33cb74cd-9cb3-4090-a3c0-1b8c8e235847/resume")); + assertFalse(workflowAction.isUriResume("/v6/serviceInstances/123/vnfs/1234/vfmodules/5678/replace")); } |