From 42e2d3904b8a7f7b98740344b504439852b68c0c Mon Sep 17 00:00:00 2001 From: Zhuoyao Huang <10112215@zte.com.cn> Date: Tue, 9 Apr 2019 20:46:05 +0800 Subject: Service instance modification extend update interface for service instance modification on CCVPN use case extension Issue-ID: SO-1393 Change-Id: Ib21843be32738de0197185906ba38c61f1095f24 Signed-off-by: Zhuoyao Huang <10112215@zte.com.cn> --- .../scripts/DoCompareServiceInstanceData.groovy | 270 ++++++++++++++++++ .../scripts/UpdateCustomE2EServiceInstance.groovy | 1 + .../DoCompareServiceInstanceDataTest.groovy | 301 +++++++++++++++++++++ .../process/UpdateCustomE2EServiceInstance.bpmn | 229 +++++++++++----- .../subprocess/DoCompareServiceInstanceData.bpmn | 241 +++++++++++++++++ .../subprocess/DoUpdateE2EServiceInstance.bpmn | 1 + 6 files changed, 972 insertions(+), 71 deletions(-) create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceDataTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareServiceInstanceData.bpmn (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy new file mode 100644 index 0000000000..a1f68f9b06 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy @@ -0,0 +1,270 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * 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.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory +import org.slf4j.Logger +import org.slf4j.LoggerFactory +/** + * This groovy class supports the DoCompareServiceInstanceData.bpmn process. + * + * Inputs: + * @param - serviceInstanceData-original + * @param - serviceInstanceId + * @param - uuiRequest + * @param - model-invariant-id-original + * @param - model-version-id-original + * @param - msoRequestId + * @param - isDebugLogEnabled + * + * Outputs: + * @param - addResourceList + * @param - delResourceList + * @param - uuiRequest-add + * @param - uuiRequest-del + * + */ +public class DoCompareServiceInstanceData extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final Logger logger = LoggerFactory.getLogger( DoCompareServiceInstanceData.class); + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + logger.info("INFO"," ***** preProcessRequest *****", isDebugEnabled) + try { + checkInput("serviceInstanceData-original", execution, isDebugEnabled) + checkInput("serviceInstanceId", execution, isDebugEnabled) + checkInput("uuiRequest", execution, isDebugEnabled) + checkInput("model-invariant-id-original", execution, isDebugEnabled) + checkInput("model-version-id-original", execution, isDebugEnabled) + checkInput("msoRequestId", execution, isDebugEnabled) + } catch (Exception ex){ + String msg = "Exception in preProcessRequest " + ex.getMessage() + logger.info("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.info("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled) + } + + private void checkInput(String inputName, DelegateExecution execution, isDebugEnabled) { + String msg + Object inputValue = execution.getVariable(inputName) + if (inputValue == null) { + msg = "Input" + inputName + "is null" + logger.info("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } + + + public void prepareDecomposeService_Original(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + logger.debug( " ***** Inside prepareDecomposeService_Original of update generic e2e service ***** ") + String modelInvariantUuid = execution.getVariable("model-invariant-id-original") + String modelUuid = execution.getVariable("model-version-id-original") + //here modelVersion is not set, we use modelUuid to decompose the service. + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + + execution.setVariable("serviceModelInfo_Original", serviceModelInfo) + + logger.debug( " ***** Completed prepareDecomposeService_Original of update generic e2e service ***** ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. Unexpected Error from method prepareDecomposeService_Original() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void processDecomposition_Original(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + logger.debug( " ***** Inside processDecomposition_Original() of update generic e2e service flow ***** ") + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + execution.setVariable("serviceDecomposition_Original", serviceDecomposition) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. processDecomposition_Original() - " + ex.getMessage() + logger.debug( exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void doCompareUuiRquestInput(DelegateExecution execution) { + + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + logger.info("INFO", "======== Start doCompareUuiRquestInput Process ======== ", isDebugEnabled) + + String uuiRequest_Target = execution.getVariable("uuiRequest") + Map serviceParametersObject_Target = getServiceParametersObject(uuiRequest_Target) + Map serviceRequestInputs_Target = (Map) serviceParametersObject_Target.get("requestInputs") + List resources_Target = (List) serviceParametersObject_Target.get("resources") + + String uuiRequest_Original = ((ServiceInstance) execution.getVariable("serviceInstanceData-original")).getInputParameters() + Map serviceParametersObject_Original = getServiceParametersObject(uuiRequest_Original) + Map serviceRequestInputs_Original = (Map) serviceParametersObject_Original.get("requestInputs") + List resources_Original = (List) serviceParametersObject_Original.get("resources") + + logger.info("INFO", "uuiRequest is: " + uuiRequest_Target, isDebugEnabled) + + //the resources which are included by resources_Target but resources_Original are the resources going to be added + ArrayList resourceList_Add = findResourceListIncluded(resources_Target, resources_Original) + HashMap serviceRequestInputs_Add = getServiceRequestInputsIncluded(resourceList_Add, serviceRequestInputs_Target, serviceParametersObject_Target) + String uuiRequest_add = loadUuiRequestJsonString(uuiRequest_Target, resourceList_Add, serviceRequestInputs_Add) + execution.setVariable("uuiRequest", uuiRequest_add) + logger.info("INFO", "uuiRequest will be changed to: " + uuiRequest_add, isDebugEnabled) + + //the resources which are included by resources_Original but resources_Target are the resources going to be deleted + ArrayList resourceList_Del = findResourceListIncluded(resources_Original, resources_Target) + HashMap serviceRequestInputs_Del = getServiceRequestInputsIncluded(resourceList_Del, serviceRequestInputs_Original, serviceParametersObject_Original) + String uuiRequest_del = loadUuiRequestJsonString(uuiRequest_Original, resourceList_Del, serviceRequestInputs_Del) + execution.setVariable("uuiRequest-del", uuiRequest_del) + logger.info("INFO", "uuiRequest-del: " + uuiRequest_del, isDebugEnabled) + + List addResourceList = findResourceList(resourceList_Add, execution) + execution.setVariable("addResourceList", addResourceList) + logger.info("INFO", "addResourceList: " + addResourceList, isDebugEnabled) + + List delResourceList = findResourceList(resourceList_Del, execution) + execution.setVariable("delResourceList", delResourceList) + logger.info("INFO", "delResourceList: " + delResourceList, isDebugEnabled) + + logger.info("INFO", "======== COMPLETED doCompareUuiRquestInput Process ======== ", isDebugEnabled) + } + + private List findResourceList(ArrayList uuiResourceList, DelegateExecution execution) { + HashSet addResourceCustomizationUuidSet = getCustomizationUuidSet(uuiResourceList) + Set resourceSet = new HashSet<>() + ServiceDecomposition serviceDecomposition_Original = execution.getVariable("serviceDecomposition_Original") + List allSR_original = serviceDecomposition_Original.getServiceResources() + for (Resource resource : allSR_original) { + if (addResourceCustomizationUuidSet.contains(resource.getModelInfo().getModelCustomizationUuid())) { + resourceSet.add(resource) + } + } + List resourceList = new ArrayList(resourceSet) + resourceList + } + + private HashSet getCustomizationUuidSet(ArrayList resourceList_Add) { + Set addRsourceCustomizationUuidSet = new HashSet<>() + for (Map resourceAdded : resourceList_Add) { + addRsourceCustomizationUuidSet.add(resourceAdded.get("rsourceCustomizationUuid")) + } + addRsourceCustomizationUuidSet + } + + private String loadUuiRequestJsonString(String uuiRequest_Target, ArrayList resourceList_Add, HashMap serviceRequestInputs_Add) { + Map uuiObject = ServicePluginFactory.getInstance().getJsonObject(uuiRequest_Target, Map.class) + Map serviceObject = (Map) uuiObject.get("service") + Map serviceParametersObject = (Map) serviceObject.get("parameters") + serviceParametersObject.put("resources", resourceList_Add) + serviceParametersObject.put("requestInputs", serviceRequestInputs_Add) + String uuiRequest_add = ServicePluginFactory.getInstance().getJsonString(serviceObject) + uuiRequest_add + } + + private HashMap getServiceRequestInputsIncluded(ArrayList resourceList_Add, Map serviceRequestInputs_Target, Map serviceParametersObject_Target) { + ArrayList newResourceNames = getNewResourceNames(resourceList_Add) + Map serviceRequestInputs_Add = new HashMap() + for (String inputKey : serviceRequestInputs_Target.keySet()) { + String resourceName = (inputKey.split("_"))[0] + if (newResourceNames.contains(resourceName)) { + serviceRequestInputs_Add.put(inputKey, serviceParametersObject_Target.get(inputKey)) + } + } + serviceRequestInputs_Add + } + + private ArrayList getNewResourceNames(ArrayList addResourceList) { + Set newResourceNames = new ArrayList() + for (Object resourceObject : addResourceList) { + Map resourceAdded = (Map) resourceObject + String resName = new String(resourceAdded.get("resourceName")) + normalizeName(resName) + newResourceNames.add(resName) + } + newResourceNames + } + + private void normalizeName(String resName) { + resName.replaceAll("_", "") + resName.replaceAll(" ", "") + resName.toLowerCase() + } + + private ArrayList findResourceListIncluded(List resources_Target, List resources_Original) { + List addResourceList = new ArrayList() + for (Object resource_Target : resources_Target) { + Map resourceObject_Target = (Map) resource_Target + boolean isNewResourceInstance = isNewResourceInstance(resourceObject_Target, resources_Original) + if (isNewResourceInstance) { + addResourceList.add(resource_Target) + } + } + addResourceList + } + + private boolean isNewResourceInstance(Map resourceObject_Target, List resources_Original) { + String resourceIndex_Target = null + if (resourceObject_Target.keySet().contains("resourceIndex")) { + resourceIndex_Target = resourceObject_Target.get("resourceIndex") + } + String resourceName_Target = resourceObject_Target.get("resourceName") + boolean isNewResourceInstance = true + for (Object resource_Original : resources_Original) { + Map resourceObject_Original = (Map) resource_Original + String resourceIndex_Original = null + if (resourceObject_Original.keySet().contains("resourceIndex")) { + resourceIndex_Original = resourceObject_Original.get("resourceIndex") + } + String resourceName_Original = resourceObject_Original.get("resourceName") + if (resourceName_Target.equals(resourceName_Original)) { + if (resourceIndex_Target != null && resourceIndex_Original != null) { + if (resourceIndex_Target.equals(resourceIndex_Original)) { + isNewResourceInstance = false + } + } else { + isNewResourceInstance = false + } + } + } + isNewResourceInstance + } + + private Map getServiceParametersObject(String uuiRequest_Target) { + Map uuiObject = ServicePluginFactory.getInstance().getJsonObject(uuiRequest_Target, Map.class) + Map serviceObject = (Map) uuiObject.get("service") + Map serviceParametersObject = (Map) serviceObject.get("parameters") + serviceParametersObject + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy index 1168b20220..8e554e286d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy @@ -189,6 +189,7 @@ public class UpdateCustomE2EServiceInstance extends AbstractServiceTaskProcessor JSONObject ob = new JSONObject(wrapper.getJson()) JSONArray ar = ob.getJSONObject("relationship-list").getJSONArray("relationship") + execution.setVariable("serviceInstanceData-original", si.get()) execution.setVariable("serviceRelationShip", ar.toString()) 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 new file mode 100644 index 0000000000..afbace76d6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceDataTest.groovy @@ -0,0 +1,301 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.ServiceDecomposition + +import static com.shazam.shazamcrest.MatcherAssert.assertThat +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when +/** + * Copyright 2018 ZTE Corporation. + * + * 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. + */ +class DoCompareServiceInstanceDataTest extends MsoGroovyTest { + + + public static final String uuiSoString = "{\n" + + " \"service\":{\n" + + " \"name\":\"SiteService\",\n" + + " \"description\":\"SiteService\",\n" + + " \"serviceInvariantUuid\":\"5c13f3fb-2744-4635-9f1f-c59c92dc8f70\",\n" + + " \"serviceUuid\":\"3a76b1f5-fb0d-4b6b-82d5-0e8a4ebc3838\",\n" + + " \"globalSubscriberId\":\"test_custormer\",\n" + + " \"serviceType\":\"example-service-type\",\n" + + " \"parameters\":{\n" + + " \"locationConstraints\":[\n" + + "\n" + + " ],\n" + + " \"resources\":[\n" + + " {\n" + + " \"resourceIndex\":\"1\",\n" + + " \"resourceName\":\"sdwanvpnresource\",\n" + + " \"resourceInvariantUuid\":\"0c0e1cbe-6e01-4f9e-8c45-a9700ebc14df\",\n" + + " \"resourceUuid\":\"4ad2d390-5c51-45f5-9710-b467a4ec7a73\",\n" + + " \"resourceCustomizationUuid\":\"66590e07-0777-415c-af44-36347cf3ddd3\",\n" + + " \"parameters\":{\n" + + " \"locationConstraints\":[\n" + + "\n" + + " ],\n" + + " \"resources\":[\n" + + "\n" + + " ],\n" + + " \"requestInputs\":{\n" + + "\n" + + " }\n" + + " }\n" + + " },\n" + + " {\n" + + " \"resourceIndex\":\"1\",\n" + + " \"resourceName\":\"sdwansiteresource\",\n" + + " \"resourceInvariantUuid\":\"97a3e552-08c4-4697-aeeb-d8d3e09ce58e\",\n" + + " \"resourceUuid\":\"63d8e1af-32dc-4c71-891d-e3f7b6a976d2\",\n" + + " \"resourceCustomizationUuid\":\"205456e7-3dc0-40c4-8cb0-28e6c1877042\",\n" + + " \"parameters\":{\n" + + " \"locationConstraints\":[\n" + + "\n" + + " ],\n" + + " \"resources\":[\n" + + "\n" + + " ],\n" + + " \"requestInputs\":{\n" + + "\n" + + " }\n" + + " }\n" + + " },\n" + + " {\n" + + " \"resourceIndex\":\"2\",\n" + + " \"resourceName\":\"sdwansiteresource\",\n" + + " \"resourceInvariantUuid\":\"97a3e552-08c4-4697-aeeb-d8d3e09ce58e\",\n" + + " \"resourceUuid\":\"63d8e1af-32dc-4c71-891d-e3f7b6a976d2\",\n" + + " \"resourceCustomizationUuid\":\"205456e7-3dc0-40c4-8cb0-28e6c1877042\",\n" + + " \"parameters\":{\n" + + " \"locationConstraints\":[\n" + + "\n" + + " ],\n" + + " \"resources\":[\n" + + "\n" + + " ],\n" + + " \"requestInputs\":{\n" + + "\n" + + " }\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"requestInputs\":{\n" + + " \"sdwanvpnresource_list\":[\n" + + " {\n" + + " \"sdwanvpn_topology\":\"hub_spoke\",\n" + + " \"sdwanvpn_name\":\"defaultvpn\",\n" + + " \"sdwansitelan_list\":[\n" + + " {\n" + + " \"role\":\"Hub\",\n" + + " \"portType\":\"GE\",\n" + + " \"portSwitch\":\"layer3-port\",\n" + + " \"vlanId\":\"\",\n" + + " \"ipAddress\":\"192.168.10.1\",\n" + + " \"deviceName\":\"vCPE\",\n" + + " \"portNumer\":\"0/0/1\"\n" + + " },\n" + + " {\n" + + " \"role\":\"Hub\",\n" + + " \"portType\":\"GE\",\n" + + " \"portSwitch\":\"layer2-port\",\n" + + " \"vlanId\":\"55\",\n" + + " \"ipAddress\":\"192.168.11.1\",\n" + + " \"deviceName\":\"CPE_Beijing\",\n" + + " \"portNumer\":\"0/0/1\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"sdwansiteresource_list\":[\n" + + " {\n" + + " \"sdwansite_emails\":\"chenchuanyu@huawei.com\",\n" + + " \"sdwansite_address\":\"Huawei Public Cloud\",\n" + + " \"sdwansite_description\":\"DC Site\",\n" + + " \"sdwansite_role\":\"dsvpn_hub\",\n" + + " \"sdwansite_postcode\":\"20000\",\n" + + " \"sdwansite_type\":\"single_gateway\",\n" + + " \"sdwansite_latitude\":\"\",\n" + + " \"sdwansite_controlPoint\":\"\",\n" + + " \"sdwansite_longitude\":\"\",\n" + + " \"sdwansitewan_list\":[\n" + + " {\n" + + " \"providerIpAddress\":\"\",\n" + + " \"portType\":\"GE\",\n" + + " \"inputBandwidth\":\"1000\",\n" + + " \"ipAddress\":\"\",\n" + + " \"name\":\"10000\",\n" + + " \"transportNetworkName\":\"internet\",\n" + + " \"outputBandwidth\":\"10000\",\n" + + " \"deviceName\":\"vCPE\",\n" + + " \"portNumber\":\"0/0/0\",\n" + + " \"ipMode\":\"DHCP\",\n" + + " \"publicIP\":\"119.3.7.113\"\n" + + " }\n" + + " ],\n" + + " \"sdwandevice_list\":[\n" + + " {\n" + + " \"esn\":\"XXXXXXX\",\n" + + " \"vendor\":\"Huawei\",\n" + + " \"name\":\"vCPE\",\n" + + " \"type\":\"AR1000V\",\n" + + " \"version\":\"1.0\",\n" + + " \"class\":\"VNF\",\n" + + " \"systemIp\":\"20.20.20.1\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"sdwansite_emails\":\"chenchuanyu@huawei.com\",\n" + + " \"sdwansite_address\":\"Huawei Public Cloud\",\n" + + " \"sdwansite_description\":\"DC Site\",\n" + + " \"sdwansite_role\":\"dsvpn_hub\",\n" + + " \"sdwansite_postcode\":\"20000\",\n" + + " \"sdwansite_type\":\"single_gateway\",\n" + + " \"sdwansite_latitude\":\"\",\n" + + " \"sdwansite_controlPoint\":\"\",\n" + + " \"sdwansite_longitude\":\"\",\n" + + " \"sdwansitewan_list\":[\n" + + " {\n" + + " \"providerIpAddress\":\"\",\n" + + " \"portType\":\"GE\",\n" + + " \"inputBandwidth\":\"1000\",\n" + + " \"ipAddress\":\"172.18.1.2/24\",\n" + + " \"name\":\"10000\",\n" + + " \"transportNetworkName\":\"internet\",\n" + + " \"outputBandwidth\":\"10000\",\n" + + " \"deviceName\":\"CPE_Beijing\",\n" + + " \"portNumber\":\"0/0/0\",\n" + + " \"ipMode\":\"Static\",\n" + + " \"publicIP\":\"\"\n" + + " }\n" + + " ],\n" + + " \"sdwandevice_list\":[\n" + + " {\n" + + " \"esn\":\"XXXXXXX\",\n" + + " \"vendor\":\"Huawei\",\n" + + " \"name\":\"CPE_Beijing\",\n" + + " \"type\":\"AR161\",\n" + + " \"version\":\"1.0\",\n" + + " \"class\":\"PNF\",\n" + + " \"systemIp\":\"20.20.20.2\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " }\n" + + " }\n" + + " }\n" + + "}" + + @Before + void setUp() { + super.init("DoCompareServiceInstanceData") + } + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + mockData() + DoCompareServiceInstanceData csi = new DoCompareServiceInstanceData() + csi.preProcessRequest(mockExecution) + } + + @Test(expected = BpmnError.class) + void testPreProcessRequestException() { + DoCompareServiceInstanceData csi = new DoCompareServiceInstanceData() + csi.preProcessRequest(mockExecution) + } + + @Test + void testPrepareDecomposeService_Original() { + mockData() + DoCompareServiceInstanceData csi = new DoCompareServiceInstanceData() + csi.prepareDecomposeService_Original(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + String serviceModelInfo = getServiceModelInfo() + assertThat(captor.getValue(), sameBeanAs(serviceModelInfo)) + } + + @Test + void testProcessDecomposition_Original() { + mockData() + DoCompareServiceInstanceData csi = new DoCompareServiceInstanceData() + csi.processDecomposition_Original(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + ServiceDecomposition serviceDecomposition = getServiceDecomposition() + assertThat(captor.getValue(), sameBeanAs(serviceDecomposition)) + } + + @Test + void testDoCompareUuiRquestInput() { + mockData() + DoCompareServiceInstanceData csi = new DoCompareServiceInstanceData() + csi.doCompareUuiRquestInput(mockExecution) + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + } + + private String getServiceModelInfo() { + String modelInvariantUuid = mockExecution.getVariable("model-invariant-id-original") + String modelUuid = mockExecution.getVariable("model-version-id-original") + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + serviceModelInfo + } + + private void mockData() { + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") + when(mockExecution.getVariable("model-version-id-original")).thenReturn("12345") + when(mockExecution.getVariable("model-invariant-id-original")).thenReturn("12345") + when(mockExecution.getVariable("uuiRequest")).thenReturn(uuiSoString) + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("1234") + when(mockExecution.getVariable("serviceInstanceData-original")).thenReturn(getExpectedServiceInstance()) + when(mockExecution.getVariable("serviceDecomposition")).thenReturn(getServiceDecomposition()) + when(mockExecution.getVariable("serviceDecomposition_Original")).thenReturn(getServiceDecomposition()) + } + + private ServiceDecomposition getServiceDecomposition() { + ServiceDecomposition decomposition = new ServiceDecomposition() + List allSR_original = new ArrayList<>() + decomposition.setAllottedResources(allSR_original) + return decomposition + } + + private ServiceInstance getExpectedServiceInstance() { + ServiceInstance expectedServiceInstanceData = new ServiceInstance() + expectedServiceInstanceData.setServiceInstanceId("1234") + expectedServiceInstanceData.setServiceInstanceName("volte-service") + expectedServiceInstanceData.setServiceType("E2E Service") + expectedServiceInstanceData.setServiceRole("E2E Service") + expectedServiceInstanceData.setInputParameters(uuiSoString) + return expectedServiceInstanceData + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn index e2488fda6a..345e0bbb28 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn @@ -45,6 +45,7 @@ ex.processJavaException(execution)]]> + SequenceFlow_04qwbbf SequenceFlow_0klbpxx @@ -192,7 +193,7 @@ csi.postCompareModelVersions(execution)]]> SequenceFlow_03i6zhx - SequenceFlow_1pdv4qj + SequenceFlow_16jngfs @@ -210,11 +211,10 @@ ddsi.preCompareModelVersions(execution)]]> - SequenceFlow_1pdv4qj + SequenceFlow_1bvnbfu SequenceFlow_0xhbobd - SequenceFlow_0secadm @@ -315,14 +315,54 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> + + SequenceFlow_16jngfs + SequenceFlow_1bvnbfu + SequenceFlow_1po82kn + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1po82kn + SequenceFlow_0gqpsvb + + + + SequenceFlow_0qe8uv2 + + + + + SequenceFlow_0gqpsvb + SequenceFlow_0qe8uv2 + + - + - + @@ -338,7 +378,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> - + @@ -350,7 +390,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> - + @@ -365,10 +405,10 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> - - + + - + @@ -485,49 +525,42 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> - + - + - + - + - - + + - - - - - - - - + - - + + - + - + - + - - + + - + @@ -537,10 +570,10 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> - - + + - + @@ -551,58 +584,58 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> - + - + - + - + - - + + - + - - + + - + - + - + - + - - + + - + - + - + - - + + - + @@ -626,42 +659,96 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> - + - - + + - + - + - + - - + + - + - - + + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareServiceInstanceData.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareServiceInstanceData.bpmn new file mode 100644 index 0000000000..6e5032a2eb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareServiceInstanceData.bpmn @@ -0,0 +1,241 @@ + + + + + SequenceFlow_1rebkae + SequenceFlow_1lkpfe2 + + + + + SequenceFlow_1rebkae + + + + SequenceFlow_1lkpfe2 + + + + + SequenceFlow_19sogyb + + + + SequenceFlow_17mr4jl + + + SequenceFlow_19sogyb + SequenceFlow_17mr4jl + + + + + + + SequenceFlow_1o9916j + + + + SequenceFlow_08zjjzw + + + + SequenceFlow_1wudpuj + SequenceFlow_08zjjzw + + + + + + + + + + + + SequenceFlow_04ciw70 + SequenceFlow_1wudpuj + + + SequenceFlow_1fgkvpr + SequenceFlow_04ciw70 + + + + SequenceFlow_1fgkvpr + + + + + + + + SequenceFlow_1chfao3 + + + SequenceFlow_1chfao3 + SequenceFlow_1o9916j + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn index 785db75fa1..002e382451 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn @@ -186,6 +186,7 @@ dcsi.preProcessAAIPUT(execution)]]> + SequenceFlow_0ur34hv SequenceFlow_0w4t4ao -- cgit 1.2.3-korg