diff options
Diffstat (limited to 'bpmn')
26 files changed, 2200 insertions, 163 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Customer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Customer.java index 30492ddf61..d7b58bac46 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Customer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Customer.java @@ -46,6 +46,10 @@ public class Customer implements Serializable, ShallowCopy<Customer> { private String subscriberCommonSiteId; @JsonProperty("service-subscription") private ServiceSubscription serviceSubscription; + @JsonProperty("customer-latitude") + private String customerLatitude; + @JsonProperty("customer-longitude") + private String customerLongitude; @JsonProperty("vpn-bindings") private List<VpnBinding> vpnBindings = new ArrayList<>(); @@ -89,6 +93,22 @@ public class Customer implements Serializable, ShallowCopy<Customer> { this.serviceSubscription = serviceSubscription; } + public String getCustomerLatitude() { + return customerLatitude; + } + + public void setCustomerLatitude(String customerLatitude) { + this.customerLatitude = customerLatitude; + } + + public String getCustomerLongitude() { + return customerLongitude; + } + + public void setCustomerLongitude(String customerLongitude) { + this.customerLongitude = customerLongitude; + } + public List<VpnBinding> getVpnBindings() { return vpnBindings; } 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 <class>DoCompareServiceInstanceData.bpmn</class> 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<String, Object> serviceParametersObject_Target = getServiceParametersObject(uuiRequest_Target) + Map<String, Object> serviceRequestInputs_Target = (Map<String, Object>) serviceParametersObject_Target.get("requestInputs") + List<Object> resources_Target = (List<Object>) serviceParametersObject_Target.get("resources") + + String uuiRequest_Original = ((ServiceInstance) execution.getVariable("serviceInstanceData-original")).getInputParameters() + Map<String, Object> serviceParametersObject_Original = getServiceParametersObject(uuiRequest_Original) + Map<String, Object> serviceRequestInputs_Original = (Map<String, Object>) serviceParametersObject_Original.get("requestInputs") + List<Object> resources_Original = (List<Object>) 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<Object> resourceList_Add = findResourceListIncluded(resources_Target, resources_Original) + HashMap<String, Object> 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<Object> resourceList_Del = findResourceListIncluded(resources_Original, resources_Target) + HashMap<String, Object> 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<Resource> addResourceList = findResourceList(resourceList_Add, execution) + execution.setVariable("addResourceList", addResourceList) + logger.info("INFO", "addResourceList: " + addResourceList, isDebugEnabled) + + List<Resource> delResourceList = findResourceList(resourceList_Del, execution) + execution.setVariable("delResourceList", delResourceList) + logger.info("INFO", "delResourceList: " + delResourceList, isDebugEnabled) + + logger.info("INFO", "======== COMPLETED doCompareUuiRquestInput Process ======== ", isDebugEnabled) + } + + private List<Resource> findResourceList(ArrayList<Object> uuiResourceList, DelegateExecution execution) { + HashSet<String> addResourceCustomizationUuidSet = getCustomizationUuidSet(uuiResourceList) + Set<Resource> resourceSet = new HashSet<>() + ServiceDecomposition serviceDecomposition_Original = execution.getVariable("serviceDecomposition_Original") + List<Resource> allSR_original = serviceDecomposition_Original.getServiceResources() + for (Resource resource : allSR_original) { + if (addResourceCustomizationUuidSet.contains(resource.getModelInfo().getModelCustomizationUuid())) { + resourceSet.add(resource) + } + } + List<Resource> resourceList = new ArrayList<String>(resourceSet) + resourceList + } + + private HashSet<String> getCustomizationUuidSet(ArrayList<Object> resourceList_Add) { + Set<String> addRsourceCustomizationUuidSet = new HashSet<>() + for (Map<String, Object> resourceAdded : resourceList_Add) { + addRsourceCustomizationUuidSet.add(resourceAdded.get("rsourceCustomizationUuid")) + } + addRsourceCustomizationUuidSet + } + + private String loadUuiRequestJsonString(String uuiRequest_Target, ArrayList<Object> resourceList_Add, HashMap<String, Object> serviceRequestInputs_Add) { + Map<String, Object> uuiObject = ServicePluginFactory.getInstance().getJsonObject(uuiRequest_Target, Map.class) + Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service") + Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters") + serviceParametersObject.put("resources", resourceList_Add) + serviceParametersObject.put("requestInputs", serviceRequestInputs_Add) + String uuiRequest_add = ServicePluginFactory.getInstance().getJsonString(serviceObject) + uuiRequest_add + } + + private HashMap<String, Object> getServiceRequestInputsIncluded(ArrayList<Object> resourceList_Add, Map<String, Object> serviceRequestInputs_Target, Map<String, Object> serviceParametersObject_Target) { + ArrayList<String> newResourceNames = getNewResourceNames(resourceList_Add) + Map<String, Object> serviceRequestInputs_Add = new HashMap<String, Object>() + 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<String> getNewResourceNames(ArrayList<Object> addResourceList) { + Set<String> newResourceNames = new ArrayList<String>() + for (Object resourceObject : addResourceList) { + Map<String, Object> resourceAdded = (Map<String, Object>) 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<Object> findResourceListIncluded(List<Object> resources_Target, List<Object> resources_Original) { + List<Object> addResourceList = new ArrayList<Object>() + for (Object resource_Target : resources_Target) { + Map<String, Object> resourceObject_Target = (Map<String, Object>) resource_Target + boolean isNewResourceInstance = isNewResourceInstance(resourceObject_Target, resources_Original) + if (isNewResourceInstance) { + addResourceList.add(resource_Target) + } + } + addResourceList + } + + private boolean isNewResourceInstance(Map<String, Object> resourceObject_Target, List<Object> 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<String, Object> resourceObject_Original = (Map<String, Object>) 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<String, Object> getServiceParametersObject(String uuiRequest_Target) { + Map<String, Object> uuiObject = ServicePluginFactory.getInstance().getJsonObject(uuiRequest_Target, Map.class) + Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service") + Map<String, Object> serviceParametersObject = (Map<String, Object>) 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/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java new file mode 100644 index 0000000000..267ddbf6a7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf; + +import org.springframework.context.ApplicationEvent; + +public class PnfNotificationEvent extends ApplicationEvent { + + private String pnfCorrelationId; + + /** + * Create a new ApplicationEvent. + * + * @param source the object on which the event initially occurred (never {@code null}) + */ + public PnfNotificationEvent(Object source, String pnfCorrelationId) { + super(source); + this.pnfCorrelationId = pnfCorrelationId; + } + + public String getPnfCorrelationId() { + return pnfCorrelationId; + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java index 5cbd530a93..e2dc375cd1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java @@ -23,14 +23,20 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent; import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; @Component -public class InformDmaapClient implements JavaDelegate { +public class InformDmaapClient implements JavaDelegate, ApplicationListener<PnfNotificationEvent> { + private Logger logger = LoggerFactory.getLogger(getClass()); private DmaapClient dmaapClient; + private DelegateExecution execution; @Override public void execute(DelegateExecution execution) { @@ -38,10 +44,19 @@ public class InformDmaapClient implements JavaDelegate { RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); dmaapClient.registerForUpdate(pnfCorrelationId, () -> runtimeService.createMessageCorrelation("WorkflowMessage") .processInstanceBusinessKey(execution.getProcessBusinessKey()).correlateWithResult()); + this.execution = execution; } @Autowired public void setDmaapClient(DmaapClient dmaapClient) { this.dmaapClient = dmaapClient; } + + @Override + public void onApplicationEvent(PnfNotificationEvent event) { + logger.info("Received application event for pnfCorrelationId: {}", event.getPnfCorrelationId()); + RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); + runtimeService.createMessageCorrelation("WorkflowMessage") + .processInstanceBusinessKey(execution.getProcessBusinessKey()).correlateWithResult(); + } } 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 3de0f38b70..2869111485 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 @@ -35,9 +35,11 @@ import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; +import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -53,8 +55,11 @@ public class PnfEventReadyDmaapClient implements DmaapClient { private volatile ScheduledThreadPoolExecutor executor; private volatile boolean dmaapThreadListenerIsRunning; + private ApplicationEventPublisher applicationEventPublisher; + @Autowired - public PnfEventReadyDmaapClient(Environment env) { + public PnfEventReadyDmaapClient(Environment env, ApplicationEventPublisher applicationEventPublisher) { + this.applicationEventPublisher = applicationEventPublisher; httpClient = HttpClientBuilder.create().build(); pnfCorrelationIdToThreadMap = new ConcurrentHashMap<>(); topicListenerDelayInSeconds = env.getProperty("pnf.dmaap.topicListenerDelayInSeconds", Integer.class); @@ -130,13 +135,9 @@ public class PnfEventReadyDmaapClient implements DmaapClient { } private void informAboutPnfReadyIfPnfCorrelationIdFound(String pnfCorrelationId) { - Runnable runnable = unregister(pnfCorrelationId); - if (runnable != null) { - logger.debug("dmaap listener gets pnf ready event for pnfCorrelationId: {}", pnfCorrelationId); - // runnable.run(); - runnable = null; - } + unregister(pnfCorrelationId); + PnfNotificationEvent pnfNotificationEvent = new PnfNotificationEvent(this, pnfCorrelationId); + applicationEventPublisher.publishEvent(pnfNotificationEvent); } } - } 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<ExecutionEntity> 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<Resource> 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-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java index 446c73dda1..96c3db0ccc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java @@ -27,12 +27,14 @@ import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder; import org.junit.Before; import org.junit.Test; import org.mockito.InOrder; +import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; public class InformDmaapClientTest { + @Before public void setUp() throws Exception { informDmaapClient = new InformDmaapClient(); @@ -71,6 +73,19 @@ public class InformDmaapClientTest { inOrder.verify(messageCorrelationBuilder).correlateWithResult(); } + @Test + public void onApplicationEvent_validPnfNotificationEvent_expectedOutput() { + + PnfNotificationEvent pnfNotificationEvent = new PnfNotificationEvent(this, "testPnfCorrelationId"); + + informDmaapClient.execute(delegateExecution); + informDmaapClient.onApplicationEvent(pnfNotificationEvent); + + InOrder inOrder = inOrder(messageCorrelationBuilder); + inOrder.verify(messageCorrelationBuilder).processInstanceBusinessKey("testBusinessKey"); + inOrder.verify(messageCorrelationBuilder).correlateWithResult(); + } + private DelegateExecution mockDelegateExecution() { DelegateExecution delegateExecution = mock(DelegateExecution.class); when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID))) 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 ca3373e8cb..9f31e2a5df 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 @@ -25,8 +25,10 @@ package org.onap.so.bpmn.infrastructure.pnf.dmaap; import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; @@ -47,9 +49,12 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent; import org.onap.so.bpmn.infrastructure.pnf.dmaap.PnfEventReadyDmaapClient.DmaapTopicListenerThread; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.env.Environment; @RunWith(MockitoJUnitRunner.class) @@ -80,6 +85,9 @@ public class PnfEventReadyDmaapClientTest { private Runnable threadMockToNotifyCamundaFlow; private ScheduledThreadPoolExecutor executorMock; + @Mock + private ApplicationEventPublisher applicationEventPublisher; + @Before public void init() throws NoSuchFieldException, IllegalAccessException { when(env.getProperty(eq("pnf.dmaap.port"), eq(Integer.class))).thenReturn(PORT); @@ -91,7 +99,7 @@ public class PnfEventReadyDmaapClientTest { when(env.getProperty(eq("pnf.dmaap.consumerGroup"))).thenReturn(CONSUMER_GROUP); when(env.getProperty(eq("pnf.dmaap.topicListenerDelayInSeconds"), eq(Integer.class))) .thenReturn(TOPIC_LISTENER_DELAY_IN_SECONDS); - testedObject = new PnfEventReadyDmaapClient(env); + testedObject = new PnfEventReadyDmaapClient(env, applicationEventPublisher); testedObjectInnerClassThread = testedObject.new DmaapTopicListenerThread(); httpClientMock = mock(HttpClient.class); threadMockToNotifyCamundaFlow = mock(Runnable.class); @@ -123,7 +131,10 @@ public class PnfEventReadyDmaapClientTest { assertEquals(captor1.getValue().getURI().getPath(), "/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + ""); - // verify(threadMockToNotifyCamundaFlow).run(); + /** + * Two PNF returned from HTTP request. + */ + verify(applicationEventPublisher, times(2)).publishEvent(any(PnfNotificationEvent.class)); verify(executorMock).shutdown(); } 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)]]></bpmn:script> <camunda:in source="addResourceList" target="addResourceList" /> <camunda:in source="delResourceList" target="delResourceList" /> <camunda:in source="serviceRelationShip" target="serviceRelationShip" /> + <camunda:in source="uuiRequest-del" target="uuiRequest-del" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_04qwbbf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0klbpxx</bpmn:outgoing> @@ -192,7 +193,7 @@ csi.postCompareModelVersions(execution)]]></bpmn:script> </bpmn:scriptTask> <bpmn:scriptTask id="ScriptTask_0hixtxc" name="Prepare for Compare Model Versions" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_03i6zhx</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1pdv4qj</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_16jngfs</bpmn:outgoing> <bpmn:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new UpdateCustomE2EServiceInstance() ddsi.preCompareModelVersions(execution)]]></bpmn:script> @@ -210,11 +211,10 @@ ddsi.preCompareModelVersions(execution)]]></bpmn:script> <camunda:out source="addResourceList" target="addResourceList" /> <camunda:out source="delResourceList" target="delResourceList" /> </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_1pdv4qj</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1bvnbfu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0xhbobd</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_03i6zhx" sourceRef="ScriptTask_0cx1y0g" targetRef="ScriptTask_0hixtxc" /> - <bpmn:sequenceFlow id="SequenceFlow_1pdv4qj" sourceRef="ScriptTask_0hixtxc" targetRef="CallActivity_1rkoyc5" /> <bpmn:sequenceFlow id="SequenceFlow_0xhbobd" sourceRef="CallActivity_1rkoyc5" targetRef="ScriptTask_11y3uq6" /> <bpmn:exclusiveGateway id="ExclusiveGateway_0mc34qe" name="HasResourcetoUpdate?" default="SequenceFlow_1n8h3zt"> <bpmn:incoming>SequenceFlow_0secadm</bpmn:incoming> @@ -315,14 +315,54 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("hasResourcetoUpdate") == true}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1n8h3zt" name="No" sourceRef="ExclusiveGateway_0mc34qe" targetRef="ScriptTask_04a0t3p" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0o2r7np" name="IsServiceInstanceModification?" default="SequenceFlow_1bvnbfu"> + <bpmn:incoming>SequenceFlow_16jngfs</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1bvnbfu</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1po82kn</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_16jngfs" sourceRef="ScriptTask_0hixtxc" targetRef="ExclusiveGateway_0o2r7np" /> + <bpmn:sequenceFlow id="SequenceFlow_1bvnbfu" name="No" sourceRef="ExclusiveGateway_0o2r7np" targetRef="CallActivity_1rkoyc5" /> + <bpmn:sequenceFlow id="SequenceFlow_1po82kn" name="Yes" sourceRef="ExclusiveGateway_0o2r7np" targetRef="Task_1ktxr5y"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("model-version-id-original") == execution.getVariable("model-version-id-target") && execution.getVariable("model-invariant-id-original") == execution.getVariable("model-invariant-id-target")}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:callActivity id="Task_1ktxr5y" name="Call DoCompareServiceInstanceData" calledElement="DoCompareServiceInstanceData"> + <bpmn:extensionElements> + <camunda:in source="serviceInstanceData-original" target="serviceInstanceData-original" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="uuiRequest" target="uuiRequest" /> + <camunda:out source="addResourceList" target="addResourceList" /> + <camunda:out source="delResourceList" target="delResourceList" /> + <camunda:out source="uuiRequest" target="uuiRequest" /> + <camunda:out source="uuiRequest-del" target="uuiRequest-del" /> + <camunda:in source="model-invariant-id-original" target="model-invariant-id-original" /> + <camunda:in source="model-version-id-original" target="model-version-id-original" /> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1po82kn</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0gqpsvb</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_0gqpsvb" sourceRef="Task_1ktxr5y" targetRef="Task_1xbq4e3" /> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_01jy2z3" name="GoToOperStatusInit"> + <bpmn:incoming>SequenceFlow_0qe8uv2</bpmn:incoming> + <bpmn:linkEventDefinition name="StartOperStatusInit" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="SequenceFlow_0qe8uv2" sourceRef="Task_1xbq4e3" targetRef="IntermediateThrowEvent_01jy2z3" /> + <bpmn:scriptTask id="Task_1xbq4e3" name="Post for Compare Service Instance Data" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0gqpsvb</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0qe8uv2</bpmn:outgoing> + <bpmn:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def csi = new UpdateCustomE2EServiceInstance() +csi.postCompareModelVersions(execution)]]></bpmn:script> + </bpmn:scriptTask> </bpmn:process> <bpmn:error id="Error_0nbdy47" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="UpdateCustomE2EServiceInstance"> <bpmndi:BPMNShape id="StartEvent_00qj6ro_di" bpmnElement="StartEvent_00qj6ro"> - <dc:Bounds x="-6" y="180" width="36" height="36" /> + <dc:Bounds x="-6" y="135" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-24" y="221" width="73" height="24" /> + <dc:Bounds x="-25" y="176" width="75" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_0ka59nc_di" bpmnElement="SubProcess_0ka59nc" isExpanded="true"> @@ -338,7 +378,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1s09c7d_di" bpmnElement="ScriptTask_1s09c7d"> - <dc:Bounds x="147" y="158" width="100" height="80" /> + <dc:Bounds x="107" y="113" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0ttvn8r_di" bpmnElement="ScriptTask_0ttvn8r"> <dc:Bounds x="782" y="585" width="100" height="80" /> @@ -350,7 +390,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> <dc:Bounds x="-61" y="908" width="1322" height="164" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0xupxj9_di" bpmnElement="ScriptTask_0xupxj9"> - <dc:Bounds x="451" y="337" width="100" height="80" /> + <dc:Bounds x="451" y="362" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_0aqn64l_di" bpmnElement="ExclusiveGateway_0aqn64l" isMarkerVisible="true"> <dc:Bounds x="639" y="600" width="50" height="50" /> @@ -365,10 +405,10 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0s2spoq_di" bpmnElement="SequenceFlow_0s2spoq"> - <di:waypoint xsi:type="dc:Point" x="30" y="198" /> - <di:waypoint xsi:type="dc:Point" x="147" y="198" /> + <di:waypoint xsi:type="dc:Point" x="30" y="153" /> + <di:waypoint xsi:type="dc:Point" x="107" y="153" /> <bpmndi:BPMNLabel> - <dc:Bounds x="43.5" y="177" width="90" height="12" /> + <dc:Bounds x="23.5" y="132" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0klbpxx_di" bpmnElement="SequenceFlow_0klbpxx"> @@ -485,49 +525,42 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0cx1y0g_di" bpmnElement="ScriptTask_0cx1y0g"> - <dc:Bounds x="364" y="158" width="100" height="80" /> + <dc:Bounds x="251" y="113" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_11y3uq6_di" bpmnElement="ScriptTask_11y3uq6"> - <dc:Bounds x="959" y="158" width="100" height="80" /> + <dc:Bounds x="959" y="113" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0hixtxc_di" bpmnElement="ScriptTask_0hixtxc"> - <dc:Bounds x="563" y="158" width="100" height="80" /> + <dc:Bounds x="422" y="113" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_1rkoyc5_di" bpmnElement="CallActivity_1rkoyc5"> - <dc:Bounds x="782" y="158" width="100" height="80" /> + <dc:Bounds x="782" y="113" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_03i6zhx_di" bpmnElement="SequenceFlow_03i6zhx"> - <di:waypoint xsi:type="dc:Point" x="464" y="198" /> - <di:waypoint xsi:type="dc:Point" x="563" y="198" /> + <di:waypoint xsi:type="dc:Point" x="351" y="153" /> + <di:waypoint xsi:type="dc:Point" x="422" y="153" /> <bpmndi:BPMNLabel> - <dc:Bounds x="468.5" y="177" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1pdv4qj_di" bpmnElement="SequenceFlow_1pdv4qj"> - <di:waypoint xsi:type="dc:Point" x="663" y="198" /> - <di:waypoint xsi:type="dc:Point" x="782" y="198" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="677.5" y="177" width="90" height="12" /> + <dc:Bounds x="341.5" y="132" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0xhbobd_di" bpmnElement="SequenceFlow_0xhbobd"> - <di:waypoint xsi:type="dc:Point" x="882" y="198" /> - <di:waypoint xsi:type="dc:Point" x="959" y="198" /> + <di:waypoint xsi:type="dc:Point" x="882" y="153" /> + <di:waypoint xsi:type="dc:Point" x="959" y="153" /> <bpmndi:BPMNLabel> - <dc:Bounds x="875.5" y="177" width="90" height="12" /> + <dc:Bounds x="876" y="132" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0mc34qe_di" bpmnElement="ExclusiveGateway_0mc34qe" isMarkerVisible="true"> - <dc:Bounds x="639" y="352" width="50" height="50" /> + <dc:Bounds x="639" y="377" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="622" y="324" width="85" height="24" /> + <dc:Bounds x="622" y="349" width="85" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0az1n4y_di" bpmnElement="SequenceFlow_0az1n4y"> - <di:waypoint xsi:type="dc:Point" x="247" y="198" /> - <di:waypoint xsi:type="dc:Point" x="364" y="198" /> + <di:waypoint xsi:type="dc:Point" x="207" y="153" /> + <di:waypoint xsi:type="dc:Point" x="251" y="153" /> <bpmndi:BPMNLabel> - <dc:Bounds x="260.5" y="177" width="90" height="12" /> + <dc:Bounds x="184" y="132" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateCatchEvent_0m01dm3_di" bpmnElement="IntermediateCatchEvent_0m01dm3"> @@ -537,10 +570,10 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0secadm_di" bpmnElement="SequenceFlow_0secadm"> - <di:waypoint xsi:type="dc:Point" x="551" y="377" /> - <di:waypoint xsi:type="dc:Point" x="639" y="377" /> + <di:waypoint xsi:type="dc:Point" x="551" y="402" /> + <di:waypoint xsi:type="dc:Point" x="639" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="550" y="356" width="90" height="12" /> + <dc:Bounds x="550" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_04qwbbf_di" bpmnElement="SequenceFlow_04qwbbf"> @@ -551,58 +584,58 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1jvqhkf_di" bpmnElement="EndEvent_1jvqhkf"> - <dc:Bounds x="1192" y="359" width="36" height="36" /> + <dc:Bounds x="1192" y="384" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1200" y="404" width="19" height="12" /> + <dc:Bounds x="1200" y="429" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_16sgdqw_di" bpmnElement="ScriptTask_16sgdqw"> - <dc:Bounds x="97" y="337" width="100" height="80" /> + <dc:Bounds x="97" y="362" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0qjpd5v_di" bpmnElement="ServiceTask_0qjpd5v"> - <dc:Bounds x="274" y="337" width="100" height="80" /> + <dc:Bounds x="274" y="362" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1e3vtyq_di" bpmnElement="SequenceFlow_1e3vtyq"> - <di:waypoint xsi:type="dc:Point" x="197" y="377" /> - <di:waypoint xsi:type="dc:Point" x="274" y="377" /> + <di:waypoint xsi:type="dc:Point" x="197" y="402" /> + <di:waypoint xsi:type="dc:Point" x="274" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="235.5" y="356" width="0" height="12" /> + <dc:Bounds x="191" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_12dou7o_di" bpmnElement="SequenceFlow_12dou7o"> - <di:waypoint xsi:type="dc:Point" x="374" y="377" /> - <di:waypoint xsi:type="dc:Point" x="451" y="377" /> + <di:waypoint xsi:type="dc:Point" x="374" y="402" /> + <di:waypoint xsi:type="dc:Point" x="451" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="412.5" y="356" width="0" height="12" /> + <dc:Bounds x="368" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0mj3kf2_di" bpmnElement="ServiceTask_0mj3kf2"> - <dc:Bounds x="959" y="337" width="100" height="80" /> + <dc:Bounds x="959" y="362" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateThrowEvent_08mk8h9_di" bpmnElement="IntermediateThrowEvent_08mk8h9"> - <dc:Bounds x="1192" y="180" width="36" height="36" /> + <dc:Bounds x="1192" y="135" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1175" y="220" width="86" height="24" /> + <dc:Bounds x="1175" y="175" width="86" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0t7zinj_di" bpmnElement="SequenceFlow_0t7zinj"> - <di:waypoint xsi:type="dc:Point" x="1059" y="198" /> - <di:waypoint xsi:type="dc:Point" x="1192" y="198" /> + <di:waypoint xsi:type="dc:Point" x="1059" y="153" /> + <di:waypoint xsi:type="dc:Point" x="1192" y="153" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1125.5" y="177" width="0" height="12" /> + <dc:Bounds x="1081" y="132" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateCatchEvent_14w7v9s_di" bpmnElement="IntermediateCatchEvent_14w7v9s"> - <dc:Bounds x="-6" y="359" width="36" height="36" /> + <dc:Bounds x="-6" y="384" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-29" y="421" width="88" height="24" /> + <dc:Bounds x="-29" y="446" width="88" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1bddzne_di" bpmnElement="SequenceFlow_1bddzne"> - <di:waypoint xsi:type="dc:Point" x="30" y="377" /> - <di:waypoint xsi:type="dc:Point" x="97" y="377" /> + <di:waypoint xsi:type="dc:Point" x="30" y="402" /> + <di:waypoint xsi:type="dc:Point" x="97" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="63.5" y="356" width="0" height="12" /> + <dc:Bounds x="19" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_14kqo0r_di" bpmnElement="ScriptTask_14kqo0r"> @@ -626,42 +659,96 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_04a0t3p_di" bpmnElement="ScriptTask_04a0t3p"> - <dc:Bounds x="782" y="337" width="100" height="80" /> + <dc:Bounds x="782" y="362" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1wzk6tu_di" bpmnElement="SequenceFlow_1wzk6tu"> - <di:waypoint xsi:type="dc:Point" x="882" y="377" /> - <di:waypoint xsi:type="dc:Point" x="959" y="377" /> + <di:waypoint xsi:type="dc:Point" x="882" y="402" /> + <di:waypoint xsi:type="dc:Point" x="959" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="920.5" y="356" width="0" height="12" /> + <dc:Bounds x="876" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_1k72hze_di" bpmnElement="IntermediateThrowEvent_1k72hze"> - <dc:Bounds x="646" y="447" width="36" height="36" /> + <dc:Bounds x="646" y="472" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="631" y="487" width="76" height="12" /> + <dc:Bounds x="631" y="512" width="76" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0kvl23y_di" bpmnElement="SequenceFlow_0kvl23y"> - <di:waypoint xsi:type="dc:Point" x="1059" y="377" /> - <di:waypoint xsi:type="dc:Point" x="1192" y="377" /> + <di:waypoint xsi:type="dc:Point" x="1059" y="402" /> + <di:waypoint xsi:type="dc:Point" x="1192" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1125.5" y="356" width="0" height="12" /> + <dc:Bounds x="1081" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0zmd4rt_di" bpmnElement="SequenceFlow_0zmd4rt"> - <di:waypoint xsi:type="dc:Point" x="664" y="402" /> - <di:waypoint xsi:type="dc:Point" x="664" y="447" /> + <di:waypoint xsi:type="dc:Point" x="664" y="427" /> + <di:waypoint xsi:type="dc:Point" x="664" y="472" /> <bpmndi:BPMNLabel> - <dc:Bounds x="670" y="419" width="19" height="12" /> + <dc:Bounds x="670" y="444" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1n8h3zt_di" bpmnElement="SequenceFlow_1n8h3zt"> - <di:waypoint xsi:type="dc:Point" x="689" y="377" /> - <di:waypoint xsi:type="dc:Point" x="782" y="377" /> + <di:waypoint xsi:type="dc:Point" x="689" y="402" /> + <di:waypoint xsi:type="dc:Point" x="782" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="729" y="356" width="14" height="12" /> + <dc:Bounds x="729" y="381" width="14" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0o2r7np_di" bpmnElement="ExclusiveGateway_0o2r7np" isMarkerVisible="true"> + <dc:Bounds x="628.6452095808384" y="128.09730538922156" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="611" y="182" width="88" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_16jngfs_di" bpmnElement="SequenceFlow_16jngfs"> + <di:waypoint xsi:type="dc:Point" x="522" y="153" /> + <di:waypoint xsi:type="dc:Point" x="629" y="153" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="575.5" y="132" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1bvnbfu_di" bpmnElement="SequenceFlow_1bvnbfu"> + <di:waypoint xsi:type="dc:Point" x="679" y="153" /> + <di:waypoint xsi:type="dc:Point" x="782" y="153" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="724" y="132" width="14" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1po82kn_di" bpmnElement="SequenceFlow_1po82kn"> + <di:waypoint xsi:type="dc:Point" x="654" y="178" /> + <di:waypoint xsi:type="dc:Point" x="654" y="267" /> + <di:waypoint xsi:type="dc:Point" x="782" y="267" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="660" y="217" width="19" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_0vnoaee_di" bpmnElement="Task_1ktxr5y"> + <dc:Bounds x="782" y="227" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0gqpsvb_di" bpmnElement="SequenceFlow_0gqpsvb"> + <di:waypoint xsi:type="dc:Point" x="882" y="267" /> + <di:waypoint xsi:type="dc:Point" x="959" y="267" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="920.5" y="246" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateThrowEvent_01jy2z3_di" bpmnElement="IntermediateThrowEvent_01jy2z3"> + <dc:Bounds x="1192" y="249" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1175" y="289" width="86" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0qe8uv2_di" bpmnElement="SequenceFlow_0qe8uv2"> + <di:waypoint xsi:type="dc:Point" x="1059" y="267" /> + <di:waypoint xsi:type="dc:Point" x="1192" y="267" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1125.5" y="246" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_179xmbe_di" bpmnElement="Task_1xbq4e3"> + <dc:Bounds x="959" y="227" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> + <bpmn2:process id="DoCompareServiceInstanceData" name="DoCompareServiceInstanceData" isExecutable="true"> + <bpmn2:scriptTask id="ScriptTask_04rn9mp" name="DoCompareServiceInstanceData" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1rebkae</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1lkpfe2</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def csi = new DoCompareServiceInstanceData() +csi.doCompareUuiRquestInput(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_1rebkae" sourceRef="StartEvent_0jhv664" targetRef="ScriptTask_04rn9mp" /> + <bpmn2:intermediateCatchEvent id="StartEvent_0jhv664" name="StartCompare"> + <bpmn2:outgoing>SequenceFlow_1rebkae</bpmn2:outgoing> + <bpmn2:linkEventDefinition name="StartCompare" /> + </bpmn2:intermediateCatchEvent> + <bpmn2:endEvent id="EndEvent_0x8im5g"> + <bpmn2:incoming>SequenceFlow_1lkpfe2</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1lkpfe2" sourceRef="ScriptTask_04rn9mp" targetRef="EndEvent_0x8im5g" /> + <bpmn2:subProcess id="SubProcess_0roysbg" name="Sub-process for UnexpectedErrors" triggeredByEvent="true"> + <bpmn2:startEvent id="StartEvent_0xtpw6j"> + <bpmn2:outgoing>SequenceFlow_19sogyb</bpmn2:outgoing> + <bpmn2:errorEventDefinition /> + </bpmn2:startEvent> + <bpmn2:endEvent id="EndEvent_05a2pr9"> + <bpmn2:incoming>SequenceFlow_17mr4jl</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:scriptTask id="ScriptTask_0xk9fk3" name="Log / Print Unexpected Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_19sogyb</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_17mr4jl</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_19sogyb" name="" sourceRef="StartEvent_0xtpw6j" targetRef="ScriptTask_0xk9fk3" /> + <bpmn2:sequenceFlow id="SequenceFlow_17mr4jl" name="" sourceRef="ScriptTask_0xk9fk3" targetRef="EndEvent_05a2pr9" /> + </bpmn2:subProcess> + <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_0se5nzs" name="GoTo Decompose_Service_Original"> + <bpmn2:incoming>SequenceFlow_1o9916j</bpmn2:incoming> + <bpmn2:linkEventDefinition name="Decompose_Service_Original" /> + </bpmn2:intermediateThrowEvent> + <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_0b436w1" name="GoTo StartCompare"> + <bpmn2:incoming>SequenceFlow_08zjjzw</bpmn2:incoming> + <bpmn2:linkEventDefinition name="StartCompare" /> + </bpmn2:intermediateThrowEvent> + <bpmn2:scriptTask id="ScriptTask_1d9qb54" name="PostProcess Decompose Service " scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1wudpuj</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_08zjjzw</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi= new DoCompareServiceInstanceData() +dcsi.processDecomposition_Original(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:callActivity id="CallActivity_1fc56sd" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn2:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo_Original" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_04ciw70</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1wudpuj</bpmn2:outgoing> + </bpmn2:callActivity> + <bpmn2:scriptTask id="ScriptTask_1i06996" name="Prepare Decompose Service " scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1fgkvpr</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_04ciw70</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi= new DoCompareServiceInstanceData() +dcsi.prepareDecomposeService_Original(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_1m9q0j7" name="Decompose_Service_Original"> + <bpmn2:outgoing>SequenceFlow_1fgkvpr</bpmn2:outgoing> + <bpmn2:linkEventDefinition name="Decompose_Service_Original" /> + </bpmn2:intermediateCatchEvent> + <bpmn2:sequenceFlow id="SequenceFlow_08zjjzw" sourceRef="ScriptTask_1d9qb54" targetRef="IntermediateThrowEvent_0b436w1" /> + <bpmn2:sequenceFlow id="SequenceFlow_1wudpuj" sourceRef="CallActivity_1fc56sd" targetRef="ScriptTask_1d9qb54" /> + <bpmn2:sequenceFlow id="SequenceFlow_04ciw70" sourceRef="ScriptTask_1i06996" targetRef="CallActivity_1fc56sd" /> + <bpmn2:sequenceFlow id="SequenceFlow_1fgkvpr" sourceRef="IntermediateCatchEvent_1m9q0j7" targetRef="ScriptTask_1i06996" /> + <bpmn2:startEvent id="StartEvent_13da9hl" name="Start Flow"> + <bpmn2:outgoing>SequenceFlow_1chfao3</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:scriptTask id="ScriptTask_0nie46r" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1chfao3</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1o9916j</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCompareServiceInstanceData() +dcsi.preProcessRequest(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_1chfao3" name="" sourceRef="StartEvent_13da9hl" targetRef="ScriptTask_0nie46r" /> + <bpmn2:sequenceFlow id="SequenceFlow_1o9916j" sourceRef="ScriptTask_0nie46r" targetRef="IntermediateThrowEvent_0se5nzs" /> + </bpmn2:process> + <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCompareServiceInstanceData"> + <bpmndi:BPMNShape id="ScriptTask_04rn9mp_di" bpmnElement="ScriptTask_04rn9mp"> + <dc:Bounds x="426" y="426" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1rebkae_di" bpmnElement="SequenceFlow_1rebkae"> + <di:waypoint xsi:type="dc:Point" x="10" y="466" /> + <di:waypoint xsi:type="dc:Point" x="426" y="466" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="173" y="445" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateCatchEvent_05z1jyy_di" bpmnElement="StartEvent_0jhv664"> + <dc:Bounds x="-26" y="448" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-42" y="488" width="68" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0x8im5g_di" bpmnElement="EndEvent_0x8im5g"> + <dc:Bounds x="1040" y="448" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1013" y="488" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1lkpfe2_di" bpmnElement="SequenceFlow_1lkpfe2"> + <di:waypoint xsi:type="dc:Point" x="526" y="466" /> + <di:waypoint xsi:type="dc:Point" x="1040" y="466" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="738" y="445" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="SubProcess_0roysbg_di" bpmnElement="SubProcess_0roysbg" isExpanded="true"> + <dc:Bounds x="221" y="751" width="467" height="193" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_0xtpw6j_di" bpmnElement="StartEvent_0xtpw6j"> + <dc:Bounds x="289" y="818" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="172" y="859" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05a2pr9_di" bpmnElement="EndEvent_05a2pr9"> + <dc:Bounds x="582" y="818" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="465" y="859" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0xk9fk3_di" bpmnElement="ScriptTask_0xk9fk3"> + <dc:Bounds x="393" y="796" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_19sogyb_di" bpmnElement="SequenceFlow_19sogyb"> + <di:waypoint xsi:type="dc:Point" x="325" y="836" /> + <di:waypoint xsi:type="dc:Point" x="393" y="836" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="224" y="821" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_17mr4jl_di" bpmnElement="SequenceFlow_17mr4jl"> + <di:waypoint xsi:type="dc:Point" x="493" y="836" /> + <di:waypoint xsi:type="dc:Point" x="582" y="836" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="405" y="821" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0se5nzs_di" bpmnElement="IntermediateThrowEvent_0se5nzs"> + <dc:Bounds x="1047" y="83" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1021" y="124" width="88" height="36" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0b436w1_di" bpmnElement="IntermediateThrowEvent_0b436w1"> + <dc:Bounds x="1047" y="311" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1032" y="352" width="68" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1d9qb54_di" bpmnElement="ScriptTask_1d9qb54"> + <dc:Bounds x="711" y="290" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1fc56sd_di" bpmnElement="CallActivity_1fc56sd"> + <dc:Bounds x="426" y="290" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1i06996_di" bpmnElement="ScriptTask_1i06996"> + <dc:Bounds x="144" y="290" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_1m9q0j7_di" bpmnElement="IntermediateCatchEvent_1m9q0j7"> + <dc:Bounds x="-26" y="312" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-50" y="348" width="88" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08zjjzw_di" bpmnElement="SequenceFlow_08zjjzw"> + <di:waypoint xsi:type="dc:Point" x="811" y="330" /> + <di:waypoint xsi:type="dc:Point" x="1047" y="329" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="929" y="308.5" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1wudpuj_di" bpmnElement="SequenceFlow_1wudpuj"> + <di:waypoint xsi:type="dc:Point" x="526" y="330" /> + <di:waypoint xsi:type="dc:Point" x="711" y="330" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="618.5" y="309" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_04ciw70_di" bpmnElement="SequenceFlow_04ciw70"> + <di:waypoint xsi:type="dc:Point" x="244" y="330" /> + <di:waypoint xsi:type="dc:Point" x="426" y="330" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="245" y="309" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1fgkvpr_di" bpmnElement="SequenceFlow_1fgkvpr"> + <di:waypoint xsi:type="dc:Point" x="10" y="330" /> + <di:waypoint xsi:type="dc:Point" x="144" y="330" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-13" y="309" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_13da9hl_di" bpmnElement="StartEvent_13da9hl"> + <dc:Bounds x="-20" y="83" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-26" y="124" width="50" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0nie46r_di" bpmnElement="ScriptTask_0nie46r"> + <dc:Bounds x="340" y="61" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1chfao3_di" bpmnElement="SequenceFlow_1chfao3"> + <di:waypoint xsi:type="dc:Point" x="16" y="101" /> + <di:waypoint xsi:type="dc:Point" x="181" y="101" /> + <di:waypoint xsi:type="dc:Point" x="181" y="101" /> + <di:waypoint xsi:type="dc:Point" x="340" y="101" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="196" y="95" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1o9916j_di" bpmnElement="SequenceFlow_1o9916j"> + <di:waypoint xsi:type="dc:Point" x="440" y="101" /> + <di:waypoint xsi:type="dc:Point" x="1047" y="101" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="743.5" y="80" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions> 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)]]></bpmn2:script> <camunda:in source="operationType" target="operationType" /> <camunda:in source="operationId" target="operationId" /> <camunda:in source="serviceDecomposition_Original" target="serviceDecomposition" /> + <camunda:in source="uuiRequest-del" target="uuiRequest-del" /> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_0ur34hv</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0w4t4ao</bpmn2:outgoing> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java index abab08bdf3..b0517ace3d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -1,16 +1,21 @@ -/* +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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 * - * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix - * Foundation. ================================================================================ 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 * - * 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. + * 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. * - * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.process; @@ -25,10 +30,8 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static org.assertj.core.api.Assertions.fail; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import com.google.protobuf.Struct; -import com.google.protobuf.Value; import java.io.IOException; import java.util.List; -import java.util.Map; import java.util.UUID; import org.camunda.bpm.engine.runtime.Execution; import org.camunda.bpm.engine.runtime.ProcessInstance; @@ -114,6 +117,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { if (!execution.isSuspended() && !execution.isEnded()) { try { + runtimeService.signal(execution.getId()); } catch (Exception e) { logger.info(e.getMessage(), e); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java index 2524fc7892..2696313daf 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019 Intel Corp. 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. @@ -21,6 +21,7 @@ package org.onap.so.bpmn.buildingblock; import org.apache.commons.lang.SerializationUtils; +import org.apache.commons.lang.exception.ExceptionUtils; import org.camunda.bpm.engine.delegate.BpmnError; import java.util.ArrayList; import org.json.JSONArray; @@ -38,7 +39,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.generalobjects.License; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; import org.onap.so.bpmn.servicedecomposition.homingobjects.Candidate; import org.onap.so.bpmn.servicedecomposition.homingobjects.CandidateType; import org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionCandidates; @@ -49,13 +49,14 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.oof.OofClient; import org.onap.so.client.oof.OofValidator; +import org.onap.so.client.oof.beans.LicenseDemand; +import org.onap.so.client.oof.beans.LicenseInfo; import org.onap.so.client.oof.beans.ModelInfo; import org.onap.so.client.oof.beans.OofRequest; import org.onap.so.client.oof.beans.OofRequestParameters; import org.onap.so.client.oof.beans.PlacementDemand; import org.onap.so.client.oof.beans.PlacementInfo; import org.onap.so.client.oof.beans.RequestInfo; -import org.onap.so.client.oof.beans.ResourceModelInfo; import org.onap.so.client.oof.beans.ServiceInfo; import org.onap.so.client.oof.beans.SubscriberInfo; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -85,7 +86,7 @@ public class OofHomingV2 { @Autowired private Environment env; @Autowired - private OofClient client; + private OofClient oofClient; @Autowired private OofValidator oofValidator; @Autowired @@ -98,7 +99,6 @@ public class OofHomingV2 { private static final String RESOURCE_MODULE_NAME = "resourceModuleName"; private static final String RESOURCE_MODEL_INFO = "resourceModelInfo"; private static final String IDENTIFIER_TYPE = "identifierType"; - private static final String INVENTORY_TYPE = "inventoryType"; private static final String SOLUTIONS = "solutions"; private static final String RESOURCE_MISSING_DATA = "Resource does not contain: "; private static final String SERVICE_MISSING_DATA = "Service Instance does not contain: "; @@ -111,12 +111,11 @@ public class OofHomingV2 { * @param execution */ public void callOof(BuildingBlockExecution execution) { - logger.trace("Started Sniro Homing Call Sniro"); + logger.trace("Started Oof Homing Call Oof"); try { GeneralBuildingBlock bb = execution.getGeneralBuildingBlock(); RequestContext requestContext = bb.getRequestContext(); - RequestParameters requestParams = requestContext.getRequestParameters(); String requestId = requestContext.getMsoRequestId(); ServiceInstance serviceInstance = bb.getCustomer().getServiceSubscription().getServiceInstances().get(0); @@ -127,28 +126,24 @@ public class OofHomingV2 { timeout = env.getProperty("oof.timeout", "PT30M"); } - OofRequest request = new OofRequest(); + OofRequest oofRequest = new OofRequest(); RequestInfo requestInfo = (RequestInfo) buildRequestInfo(requestId, timeout); - request.setRequestInformation(requestInfo); + oofRequest.setRequestInformation(requestInfo); ServiceInfo serviceInfo = buildServiceInfo(serviceInstance); - request.setServiceInformation(serviceInfo); + oofRequest.setServiceInformation(serviceInfo); - PlacementInfo placementInfo = buildPlacementInfo(customer, requestParams); + PlacementInfo placementInfo = buildPlacementInfo(customer); - ArrayList<PlacementDemand> placementDemands = buildPlacementDemands(serviceInstance); - placementInfo.setPlacementDemands(placementDemands); - request.setPlacementInformation(placementInfo); + placementInfo = buildPlacementDemands(serviceInstance, placementInfo); + oofRequest.setPlacementInformation(placementInfo); - JSONObject licenseInfo = new JSONObject(); + LicenseInfo licenseInfo = buildLicenseInfo(serviceInstance); + oofRequest.setLicenseInformation(licenseInfo); - JSONArray licenseDemands = buildLicenseDemands(serviceInstance); - licenseInfo.put("licenseDemands", licenseDemands); - request.setLicenseInformation(licenseInfo.toString()); - - if (placementDemands.size() > 0 || licenseDemands.length() > 0) { - client.postDemands(request); + if (!placementInfo.getPlacementDemands().isEmpty() || !licenseInfo.getLicenseDemands().isEmpty()) { + oofClient.postDemands(oofRequest); } else { logger.debug(SERVICE_MISSING_DATA + " resources eligible for homing or licensing"); throw new BpmnError(UNPROCESSABLE, @@ -162,12 +157,15 @@ public class OofHomingV2 { logger.trace("Completed Oof Homing Call Oof"); } catch (BpmnError e) { + logger.debug(" Error - while preparing oof request: " + e.getStackTrace()); exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage()); } catch (BadResponseException e) { + logger.debug(" Error - while preparing oof request: " + e.getStackTrace()); exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage()); } catch (Exception e) { - exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, - "Internal Error - occurred while preparing oof request: " + e.getMessage()); + logger.debug(" Error - while preparing oof request: " + e.getStackTrace()); + exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while " + + "preparing oof request: " + e + " Stack:" + ExceptionUtils.getFullStackTrace(e)); } } @@ -240,6 +238,10 @@ public class OofHomingV2 { requestInfo.setSourceId("mso"); requestInfo.setRequestType("create"); requestInfo.setTimeout(timeoutSeconds); + requestInfo.setNumSolutions(1); + ArrayList optimizers = new ArrayList(); + optimizers.add("placement"); + requestInfo.setOptimizers(optimizers); } else { throw new BpmnError(UNPROCESSABLE, "Request Context does not contain: requestId"); } @@ -270,7 +272,7 @@ public class OofHomingV2 { * Builds initial section of placement info for the homing/licensing request * */ - private PlacementInfo buildPlacementInfo(Customer customer, RequestParameters requestParams) { + private PlacementInfo buildPlacementInfo(Customer customer) { PlacementInfo placementInfo = new PlacementInfo(); if (customer != null) { logger.debug("Adding subscriber to placement information"); @@ -279,22 +281,11 @@ public class OofHomingV2 { subscriberInfo.setSubscriberName(customer.getSubscriberName()); subscriberInfo.setSubscriberCommonSiteId(customer.getSubscriberCommonSiteId()); placementInfo.setSubscriberInfo(subscriberInfo); - if (requestParams != null) { - logger.debug("Adding request parameters to placement information"); - OofRequestParameters oofRequestParams = new OofRequestParameters(); - for (Map requestParam : requestParams.getUserParams()) { - if (requestParam.containsKey("customerLatitude")) { - oofRequestParams.setCustomerLatitude(requestParam.get("customerLatitude").toString()); - } - if (requestParam.containsKey("customerLongitude")) { - oofRequestParams.setCustomerLongitude(requestParam.get("customerLongitude").toString()); - } - if (requestParam.containsKey("customerName")) { - oofRequestParams.setCustomerName(requestParam.get("customerName").toString()); - } - } - placementInfo.setRequestParameters(oofRequestParams); - } + OofRequestParameters oofRequestParams = new OofRequestParameters(); + oofRequestParams.setCustomerLatitude(customer.getCustomerLatitude()); + oofRequestParams.setCustomerLongitude(customer.getCustomerLongitude()); + oofRequestParams.setCustomerName(customer.getSubscriberName()); + placementInfo.setRequestParameters(oofRequestParams); } else { throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + "customer"); } @@ -306,9 +297,8 @@ public class OofHomingV2 { * Builds the placement demand list for the homing/licensing request * */ - private ArrayList<PlacementDemand> buildPlacementDemands(ServiceInstance serviceInstance) { + private PlacementInfo buildPlacementDemands(ServiceInstance serviceInstance, PlacementInfo placementInfo) { logger.trace("Building placement information demands"); - ArrayList<PlacementDemand> placementDemands = new ArrayList(); List<AllottedResource> allottedResourceList = serviceInstance.getAllottedResources(); if (!allottedResourceList.isEmpty()) { @@ -319,7 +309,7 @@ public class OofHomingV2 { } PlacementDemand demand = buildDemand(ar.getId(), ar.getModelInfoAllottedResource()); // addCandidates(ar, demand); - placementDemands.add(demand); + placementInfo.getPlacementDemands().add(demand); } } List<VpnBondingLink> vpnBondingLinkList = serviceInstance.getVpnBondingLinks(); @@ -333,42 +323,43 @@ public class OofHomingV2 { } PlacementDemand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy()); // addCandidates(sp, demand); - placementDemands.add(demand); + placementInfo.getPlacementDemands().add(demand); } } } - return placementDemands; + return placementInfo; } /** * Builds the license demand list for the homing/licensing request * */ - private JSONArray buildLicenseDemands(ServiceInstance serviceInstance) { + private LicenseInfo buildLicenseInfo(ServiceInstance serviceInstance) { logger.trace("Building license information"); - JSONArray licenseDemands = new JSONArray(); + LicenseInfo licenseInfo = new LicenseInfo(); List<GenericVnf> vnfList = serviceInstance.getVnfs(); if (!vnfList.isEmpty()) { logger.debug("Adding vnfs to license demands list"); for (GenericVnf vnf : vnfList) { - JSONObject demand = buildLicenseDemand(vnf.getVnfId(), vnf.getModelInfoGenericVnf()); - licenseDemands.put(demand); + LicenseDemand demand = buildLicenseDemand(vnf.getVnfId(), vnf.getModelInfoGenericVnf()); + licenseInfo.getLicenseDemands().add(demand); } } - return licenseDemands; + return licenseInfo; } /** * Builds a single license demand object * */ - private JSONObject buildLicenseDemand(String id, ModelInfoMetadata metadata) { + private LicenseDemand buildLicenseDemand(String id, ModelInfoMetadata metadata) { logger.debug("Building demand for service or resource: " + id); - JSONObject demand = new JSONObject(); + LicenseDemand demand = new LicenseDemand(); if (isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())) { - demand.put(SERVICE_RESOURCE_ID, id); - demand.put(RESOURCE_MODULE_NAME, metadata.getModelInstanceName()); - demand.put(RESOURCE_MODEL_INFO, buildModelInfo(metadata)); + + demand.setServiceResourceId(id); + demand.setResourceModuleName(metadata.getModelInstanceName()); + demand.setResourceModelInfo(buildModelInfo(metadata)); } else { throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName"); } @@ -385,7 +376,7 @@ public class OofHomingV2 { if (isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())) { placementDemand.setServiceResourceId(id); placementDemand.setResourceModuleName(metadata.getModelInstanceName()); - placementDemand.setResourceModelInfo((ResourceModelInfo) buildModelInfo(metadata)); + placementDemand.setResourceModelInfo(buildModelInfo(metadata)); } else { throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName"); } @@ -525,11 +516,11 @@ public class OofHomingV2 { JSONArray assignments = placement.getJSONArray("assignmentInfo"); Map<String, String> assignmentsMap = jsonUtils.entryArrayToMap(assignments.toString(), "key", "value"); solutionInfo.setRehome(Boolean.parseBoolean(assignmentsMap.get("isRehome"))); - String type = placement.getString(INVENTORY_TYPE); + String type = identifierType; ServiceInstance si = new ServiceInstance(); CloudRegion cloud = setCloud(assignmentsMap); - if (type.equals("service")) { + if (type.equals("serviceInstanceId")) { if (identifierType.equals(CandidateType.SERVICE_INSTANCE_ID.toString())) { solutionInfo.setHomed(true); si.setServiceInstanceId(identifierValue); @@ -556,7 +547,7 @@ public class OofHomingV2 { logger.debug(invalidMessage + IDENTIFIER_TYPE); throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE); } - } else if (type.equals("cloud")) { + } else if (type.equals("cloudRegionId")) { if (identifierType.equals(CandidateType.CLOUD_REGION_ID.toString())) { logger.debug("Resources has been homed to a cloud region"); cloud.setLcpCloudRegionId(identifierValue); @@ -567,9 +558,6 @@ public class OofHomingV2 { logger.debug(invalidMessage + IDENTIFIER_TYPE); throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE); } - } else { - logger.debug(invalidMessage + INVENTORY_TYPE); - throw new BpmnError(UNPROCESSABLE, invalidMessage + INVENTORY_TYPE); } si.setSolutionInfo(solutionInfo); return si; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/LicenseDemand.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/LicenseDemand.java new file mode 100644 index 0000000000..e64a5450b5 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/LicenseDemand.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import java.io.Serializable; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"resourceModuleName", "serviceResourceId", "tenantId", "resourceModelInfo"}) +@JsonRootName("licenseDemand") +public class LicenseDemand implements Serializable { + + private static final long serialVersionUID = -759180997599143791L; + + @JsonProperty("resourceModuleName") + private String resourceModuleName; + @JsonProperty("serviceResourceId") + private String serviceResourceId; + @JsonProperty("tenantId") + private String tenantId; + @JsonProperty("resourceModelInfo") + private ResourceModelInfo resourceModelInfo; + + @JsonProperty("resourceModuleName") + public String getResourceModuleName() { + return resourceModuleName; + } + + @JsonProperty("resourceModuleName") + public void setResourceModuleName(String resourceModuleName) { + this.resourceModuleName = resourceModuleName; + } + + @JsonProperty("serviceResourceId") + public String getServiceResourceId() { + return serviceResourceId; + } + + @JsonProperty("serviceResourceId") + public void setServiceResourceId(String serviceResourceId) { + this.serviceResourceId = serviceResourceId; + } + + @JsonProperty("tenantId") + public String getTenantId() { + return tenantId; + } + + @JsonProperty("tenantId") + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + @JsonProperty("resourceModelInfo") + public ResourceModelInfo getResourceModelInfo() { + return resourceModelInfo; + } + + @JsonProperty("resourceModelInfo") + public void setResourceModelInfo(ResourceModelInfo resourceModelInfo) { + this.resourceModelInfo = resourceModelInfo; + } + + public void setResourceModelInfo(ModelInfo modelInfo) { + ResourceModelInfo localResourceModelInfo = new ResourceModelInfo(); + localResourceModelInfo.setModelVersionId(modelInfo.getModelVersionId()); + localResourceModelInfo.setModelVersionId(modelInfo.getModelVersionId()); + localResourceModelInfo.setModelVersion(modelInfo.getModelVersion()); + localResourceModelInfo.setModelName(modelInfo.getModelName()); + localResourceModelInfo.setModelType(modelInfo.getModelType()); + localResourceModelInfo.setModelInvariantId(modelInfo.getModelInvariantId()); + localResourceModelInfo.setModelCustomizationName(modelInfo.getModelCustomizationName()); + this.resourceModelInfo = localResourceModelInfo; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/LicenseInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/LicenseInfo.java new file mode 100644 index 0000000000..74ff9339d3 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/LicenseInfo.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import java.io.Serializable; +import java.util.ArrayList; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonRootName("licenseInfo") +public class LicenseInfo implements Serializable { + + private static final long serialVersionUID = -759180997599143791L; + + @JsonProperty("licenseDemands") + private ArrayList<LicenseDemand> licenseDemands = new ArrayList<>(); + + + @JsonProperty("licenseDemands") + public ArrayList<LicenseDemand> getLicenseDemands() { + return licenseDemands; + } + + @JsonProperty("licenseDemands") + public void setLicenseDemands(ArrayList<LicenseDemand> licenseDemands) { + this.licenseDemands = licenseDemands; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java index e3c29fe04d..f8896240ba 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java @@ -46,7 +46,7 @@ public class OofRequest implements Serializable { private PlacementInfo placementInformation; @JsonProperty("licenseInfo") - private String licenseInformation; + private LicenseInfo licenseInformation; public RequestInfo getRequestInformation() { @@ -73,11 +73,11 @@ public class OofRequest implements Serializable { this.placementInformation = placementInformation; } - public String getLicenseInformation() { + public LicenseInfo getLicenseInformation() { return licenseInformation; } - public void setLicenseInformation(String licenseInformation) { + public void setLicenseInformation(LicenseInfo licenseInformation) { this.licenseInformation = licenseInformation; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java index 73c100df6d..631b3707d4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java @@ -82,4 +82,16 @@ public class PlacementDemand implements Serializable { this.resourceModelInfo = resourceModelInfo; } + public void setResourceModelInfo(ModelInfo modelInfo) { + ResourceModelInfo localResourceModelInfo = new ResourceModelInfo(); + localResourceModelInfo.setModelVersionId(modelInfo.getModelVersionId()); + localResourceModelInfo.setModelVersionId(modelInfo.getModelVersionId()); + localResourceModelInfo.setModelVersion(modelInfo.getModelVersion()); + localResourceModelInfo.setModelName(modelInfo.getModelName()); + localResourceModelInfo.setModelType(modelInfo.getModelType()); + localResourceModelInfo.setModelInvariantId(modelInfo.getModelInvariantId()); + localResourceModelInfo.setModelCustomizationName(modelInfo.getModelCustomizationName()); + this.resourceModelInfo = localResourceModelInfo; + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java index 0eb14d991a..7519e8c87e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java @@ -39,7 +39,7 @@ public class PlacementInfo implements Serializable { @JsonProperty("subscriberInfo") private SubscriberInfo subscriberInfo; @JsonProperty("placementDemands") - private ArrayList<PlacementDemand> placementDemands = null; + private ArrayList<PlacementDemand> placementDemands = new ArrayList<>(); @JsonProperty("requestParameters") public OofRequestParameters getRequestParameters() { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java index 3bb8fb70f2..43e4ce3ebd 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java @@ -23,9 +23,11 @@ import java.io.IOException; import java.io.InputStream; import org.junit.Before; import org.junit.runner.RunWith; +import org.onap.so.bpmn.buildingblock.OofHomingV2; import org.onap.so.bpmn.buildingblock.SniroHomingV2; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.client.appc.ApplicationControllerAction; +import org.onap.so.client.oof.OofClient; import org.onap.so.client.orchestration.SDNOHealthCheckResources; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sniro.SniroClient; @@ -63,6 +65,12 @@ public abstract class BaseIntegrationTest extends TestDataSetup { @SpyBean protected SniroClient sniroClient; + @SpyBean + protected OofHomingV2 oofHoming; + + @SpyBean + protected OofClient oofClient; + @MockBean protected ApplicationControllerAction appCClient; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/OofHomingV2IT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/OofHomingV2IT.java new file mode 100644 index 0000000000..e066058796 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/OofHomingV2IT.java @@ -0,0 +1,594 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. & Intel Corp. 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.flowspecific.tasks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.onap.so.BaseIntegrationTest; +import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; +import org.onap.so.bpmn.servicedecomposition.homingobjects.Candidate; +import org.onap.so.bpmn.servicedecomposition.homingobjects.CandidateType; +import org.onap.so.client.exception.BadResponseException; +import org.onap.so.client.oof.beans.OofRequest; +import org.skyscreamer.jsonassert.JSONAssert; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +public class OofHomingV2IT extends BaseIntegrationTest { + + private ServiceInstance serviceInstance; + + private RequestContext requestContext; + + private Customer customer; + + private static final String RESOURCE_PATH = "__files/BuildingBlocks/OofHoming/"; + + + String mockResponse = + "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"homing request accepted\", \"requestStatus\": \"accepted\"}"; + + @Before + public void before() { + serviceInstance = setServiceInstance(); + customer = setCustomer(); + customer.setGlobalCustomerId("testCustomerId"); + customer.setSubscriberName("testCustomerName"); + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + customer.setCustomerLatitude("customerLatitude"); + customer.setCustomerLongitude("customerLongitude"); + + requestContext = setRequestContext(); + requestContext.setMsoRequestId("requestId"); + + RequestParameters params = new RequestParameters(); + params.setaLaCarte(false); + params.setSubscriptionServiceType("testSubscriptionServiceType"); + requestContext.setRequestParameters(params); + } + + public void beforeVpnBondingLink(String id) { + VpnBondingLink bondingLink = new VpnBondingLink(); + bondingLink.setVpnBondingLinkId("testVpnBondingId" + id); + bondingLink.getServiceProxies().add(setServiceProxy("1", "transport")); + ServiceProxy sp2 = setServiceProxy("2", "infrastructure"); + Candidate requiredCandidate = new Candidate(); + requiredCandidate.setIdentifierType(CandidateType.VNF_ID); + List<String> c = new ArrayList<String>(); + c.add("testVnfId"); + requiredCandidate.setIdentifiers(c); + sp2.addRequiredCandidates(requiredCandidate); + bondingLink.getServiceProxies().add(sp2); + serviceInstance.getVpnBondingLinks().add(bondingLink); + + } + + public void beforeAllottedResource() { + serviceInstance.getAllottedResources().add(setAllottedResource("1")); + serviceInstance.getAllottedResources().add(setAllottedResource("2")); + serviceInstance.getAllottedResources().add(setAllottedResource("3")); + } + + public void beforeVnf() { + setGenericVnf(); + } + + @Test + public void testCallOof_success_1VpnLink() throws BadResponseException, IOException { + beforeVpnBondingLink("1"); + + wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( + aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); + + oofHoming.callOof(execution); + + String request = readResourceFile(RESOURCE_PATH + "oofRequest1Vpn.json"); + request = request.replace("28080", wireMockPort); + + ArgumentCaptor<OofRequest> argument = ArgumentCaptor.forClass(OofRequest.class); + verify(oofClient, times(1)).postDemands(argument.capture()); + JSONAssert.assertEquals(request, argument.getValue().toJsonString(), false); + } + + @Test + public void testCallOof_success_3VpnLink() throws JsonProcessingException, BadResponseException { + beforeVpnBondingLink("1"); + beforeVpnBondingLink("2"); + beforeVpnBondingLink("3"); + + wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( + aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); + + oofHoming.callOof(execution); + + String request = readResourceFile(RESOURCE_PATH + "oofRequest3Vpn.json"); + request = request.replace("28080", wireMockPort); + + ArgumentCaptor<OofRequest> argument = ArgumentCaptor.forClass(OofRequest.class); + verify(oofClient, times(1)).postDemands(argument.capture()); + JSONAssert.assertEquals(request, argument.getValue().toJsonString(), false); + } + + @Test + public void testCallOof_success_3Allotteds() throws BadResponseException, JsonProcessingException { + beforeAllottedResource(); + + wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( + aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); + + oofHoming.callOof(execution); + + String request = readResourceFile(RESOURCE_PATH + "oofRequest3Ar.json"); + request = request.replace("28080", wireMockPort); + + ArgumentCaptor<OofRequest> argument = ArgumentCaptor.forClass(OofRequest.class); + verify(oofClient, times(1)).postDemands(argument.capture()); + JSONAssert.assertEquals(request, argument.getValue().toJsonString(), false); + } + + @Test + public void testCallOof_success_1Vnf() throws JsonProcessingException, BadResponseException { + beforeVnf(); + + wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( + aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); + + oofHoming.callOof(execution); + + ArgumentCaptor<OofRequest> argument = ArgumentCaptor.forClass(OofRequest.class); + verify(oofClient, times(1)).postDemands(argument.capture()); + // TODO assertEquals(request, argument.getValue().toJsonString()); + } + + @Test + public void testCallOof_success_3Allotteds1Vnf() throws JsonProcessingException, BadResponseException { + beforeAllottedResource(); + beforeVnf(); + + wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( + aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); + + oofHoming.callOof(execution); + + verify(oofClient, times(1)).postDemands(isA(OofRequest.class)); + } + + @Test + public void testProcessSolution_success_1VpnLink_1Solution() { + beforeVpnBondingLink("1"); + + JSONObject asyncResponse = new JSONObject(); + asyncResponse.put("transactionId", "transactionId").put("requestId", "testRequestId").put("requestState", + "completed"); + JSONArray solution1 = new JSONArray(); + solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1") + .put("solution", + new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", + new JSONArray().put("testServiceInstanceId1"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1")))); + solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2") + .put("solution", + new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", + new JSONArray().put("testServiceInstanceId2"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "secondaryPnfName").put("value", + "testSecondaryPnfName2")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2")))); + + asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)) + .put("licenseSolutions", new JSONArray())); + + oofHoming.processSolution(execution, asyncResponse.toString()); + + ServiceInstance si = + execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0); + + assertFalse(si.getVpnBondingLinks().isEmpty()); + VpnBondingLink link = si.getVpnBondingLinks().get(0); + assertNotNull(link); + assertFalse(link.getServiceProxies().isEmpty()); + + assertEquals("testServiceInstanceId1", + link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId()); + assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo()); + assertEquals("testVnfHostName1", + link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName()); + + assertEquals("testServiceInstanceId2", + link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId()); + assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo()); + assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty()); + assertEquals("testPrimaryPnfName2", + link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName()); + assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole()); + assertEquals("testSecondaryPnfName2", + link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName()); + assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole()); + } + + @Test + public void testProcessSolution_success_1VpnLink_2Solutions() { + beforeVpnBondingLink("1"); + + JSONObject asyncResponse = new JSONObject(); + asyncResponse.put("transactionId", "transactionId").put("requestId", "testRequestId").put("requestState", + "completed"); + JSONArray solution1 = new JSONArray(); + solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1") + .put("solution", + new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", + new JSONArray().put("testServiceInstanceId1"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1")))); + solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2") + .put("solution", + new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", + new JSONArray().put("testServiceInstanceId2"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "secondaryPnfName").put("value", + "testSecondaryPnfName2")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2")))); + + JSONArray solution2 = new JSONArray(); + solution2.put(new JSONObject().put("serviceResourceId", "testProxyId1") + .put("solution", + new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", + new JSONArray().put("testServiceInstanceId3"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName3")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli3")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId3")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId3")))); + solution2.put(new JSONObject().put("serviceResourceId", "testProxyId2") + .put("solution", + new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", + new JSONArray().put("testServiceInstanceId4"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName4")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli4")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "secondaryPnfName").put("value", + "testSecondaryPnfName4")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId4")))); + + asyncResponse.put("solutions", + new JSONObject().put("placementSolutions", new JSONArray().put(solution1).put(solution2)) + .put("licenseSolutions", new JSONArray())); + + oofHoming.processSolution(execution, asyncResponse.toString()); + + ServiceInstance si = + execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0); + + assertFalse(si.getVpnBondingLinks().isEmpty()); + VpnBondingLink link = si.getVpnBondingLinks().get(0); + VpnBondingLink link2 = si.getVpnBondingLinks().get(1); + assertNotNull(link); + assertFalse(link.getServiceProxies().isEmpty()); + + assertEquals("testServiceInstanceId1", + link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId()); + assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo()); + assertEquals("testVnfHostName1", + link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName()); + + assertEquals("testServiceInstanceId2", + link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId()); + assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo()); + assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty()); + assertEquals("testPrimaryPnfName2", + link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName()); + assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole()); + assertEquals("testSecondaryPnfName2", + link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName()); + assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole()); + + assertNotNull(link2); + assertFalse(link2.getServiceProxies().isEmpty()); + + assertEquals("testServiceInstanceId3", + link2.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId()); + assertNotNull(link2.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo()); + assertEquals("testVnfHostName3", + link2.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName()); + + assertEquals("testServiceInstanceId4", + link2.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId()); + assertNotNull(link2.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo()); + assertFalse(link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty()); + assertEquals("testPrimaryPnfName4", + link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName()); + assertEquals("primary", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole()); + assertEquals("testSecondaryPnfName4", + link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName()); + assertEquals("secondary", + link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole()); + + } + + @Test + public void testProcessSolution_success_3VpnLink_2Solutions() { + // TODO + } + + @Test + public void testProcessSolution_success_3Allotteds_1Solution() { + beforeAllottedResource(); + + JSONObject asyncResponse = new JSONObject(); + asyncResponse.put("transactionId", "transactionId").put("requestId", "testRequestId").put("requestState", + "completed"); + JSONArray solution1 = new JSONArray(); + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1") + .put("solution", + new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", + new JSONArray().put("testServiceInstanceId1"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1")))); + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2") + .put("solution", + new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", + new JSONArray().put("testServiceInstanceId2"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2")))); + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3") + .put("solution", + new JSONObject().put("identifierType", "cloudRegionId").put("identifiers", + new JSONArray().put("testCloudRegionId3"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")))); + + asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)) + .put("licenseSolutions", new JSONArray())); + + oofHoming.processSolution(execution, asyncResponse.toString()); + + ServiceInstance si = + execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0); + + assertFalse(si.getAllottedResources().isEmpty()); + AllottedResource ar = si.getAllottedResources().get(0); + assertNotNull(ar); + assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId()); + assertNotNull(ar.getParentServiceInstance().getSolutionInfo()); + assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName()); + + AllottedResource ar2 = si.getAllottedResources().get(1); + assertNotNull(ar2); + assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId()); + assertNotNull(ar2.getParentServiceInstance().getSolutionInfo()); + assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName()); + + AllottedResource ar3 = si.getAllottedResources().get(2); + assertNotNull(ar3); + assertNotNull(ar3.getParentServiceInstance().getSolutionInfo()); + assertEquals("testCloudRegionId3", + ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId()); + } + + @Test + public void testProcessSolution_success_3Allotteds1Vnf_1Solution() { + beforeVnf(); + beforeAllottedResource(); + + JSONObject asyncResponse = new JSONObject(); + asyncResponse.put("transactionId", "transactionId").put("requestId", "testRequestId").put("requestState", + "completed"); + JSONArray solution1 = new JSONArray(); + JSONArray licenseSolution = new JSONArray(); + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1") + .put("solution", + new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", + new JSONArray().put("testServiceInstanceId1"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1")))); + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2") + .put("solution", + new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", + new JSONArray().put("testServiceInstanceId2"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2")))); + solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3") + .put("solution", + new JSONObject().put("identifierType", "cloudRegionId").put("identifiers", + new JSONArray().put("testCloudRegionId3"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")))); + + licenseSolution.put(new JSONObject().put("serviceResourceId", "testVnfId1") + .put("entitlementPoolUUID", + new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e") + .put("j1d563e8-e714-4393-8f99-cc480144a05e")) + .put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e") + .put("b1d563e8-e714-4393-8f99-cc480144a05e"))); + + asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)) + .put("licenseSolutions", licenseSolution)); + + oofHoming.processSolution(execution, asyncResponse.toString()); + + ServiceInstance si = + execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0); + + assertFalse(si.getAllottedResources().isEmpty()); + AllottedResource ar = si.getAllottedResources().get(0); + assertNotNull(ar); + assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId()); + assertNotNull(ar.getParentServiceInstance().getSolutionInfo()); + assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName()); + + AllottedResource ar2 = si.getAllottedResources().get(1); + assertNotNull(ar2); + assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId()); + assertNotNull(ar2.getParentServiceInstance().getSolutionInfo()); + assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName()); + + AllottedResource ar3 = si.getAllottedResources().get(2); + assertNotNull(ar3); + assertNotNull(ar3.getParentServiceInstance().getSolutionInfo()); + assertEquals("testCloudRegionId3", + ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId()); + + GenericVnf vnf = si.getVnfs().get(0); + assertNotNull(vnf); + assertNotNull(vnf.getLicense()); + assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size()); + assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0)); + + } + + @Test + public void testProcessSolution_success_1Vnf_1Solution() { + beforeVnf(); + + JSONObject asyncResponse = new JSONObject(); + asyncResponse.put("transactionId", "transactionId").put("requestId", "testRequestId").put("requestState", + "completed"); + JSONArray licenseSolution = new JSONArray(); + + licenseSolution.put(new JSONObject().put("serviceResourceId", "testVnfId1") + .put("entitlementPoolUUID", + new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e") + .put("j1d563e8-e714-4393-8f99-cc480144a05e")) + .put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e") + .put("b1d563e8-e714-4393-8f99-cc480144a05e"))); + + asyncResponse.put("solutions", new JSONObject().put("licenseSolutions", licenseSolution)); + + oofHoming.processSolution(execution, asyncResponse.toString()); + + ServiceInstance si = + execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0); + + GenericVnf vnf = si.getVnfs().get(0); + assertNotNull(vnf); + assertNotNull(vnf.getLicense()); + assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size()); + assertEquals(2, vnf.getLicense().getLicenseKeyGroupUuids().size()); + assertEquals("f1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getEntitlementPoolUuids().get(0)); + assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0)); + + + } + + @Test(expected = BpmnError.class) + public void testCallOof_error_0Resources() throws BadResponseException, JsonProcessingException { + + oofHoming.callOof(execution); + + verify(oofClient, times(0)).postDemands(isA(OofRequest.class)); + } + + @Test(expected = BpmnError.class) + public void testCallOof_error_badResponse() throws BadResponseException, JsonProcessingException { + beforeAllottedResource(); + + mockResponse = + "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}"; + wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( + aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); + + oofHoming.callOof(execution); + + verify(oofClient, times(1)).postDemands(isA(OofRequest.class)); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java index ce7d557254..3ae0db627a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java @@ -27,6 +27,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.onap.so.client.exception.BadResponseException; +import org.onap.so.client.oof.beans.LicenseInfo; import org.onap.so.client.oof.beans.ModelInfo; import org.onap.so.client.oof.beans.OofRequest; import org.onap.so.client.oof.beans.OofRequestParameters; @@ -36,6 +37,7 @@ import org.onap.so.client.oof.beans.RequestInfo; import org.onap.so.client.oof.beans.ResourceModelInfo; import org.onap.so.client.oof.beans.ServiceInfo; import org.onap.so.client.oof.beans.SubscriberInfo; +import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.beans.factory.annotation.Autowired; import com.fasterxml.jackson.core.JsonProcessingException; import java.util.ArrayList; @@ -114,7 +116,7 @@ public class OofClientTestIT extends BaseIntegrationTest { oofRequest.setRequestInformation(requestInfo); oofRequest.setPlacementInformation(placementInfo); oofRequest.setServiceInformation(serviceInfo); - oofRequest.setLicenseInformation(""); + oofRequest.setLicenseInformation(new LicenseInfo()); wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); @@ -122,7 +124,7 @@ public class OofClientTestIT extends BaseIntegrationTest { client.postDemands(oofRequest); String oofRequestOutput = oofRequest.toJsonString(); - assertEquals("{\n" + " \"requestInfo\" : {\n" + " \"transactionId\" : \"transactionId\",\n" + JSONAssert.assertEquals("{\n" + " \"requestInfo\" : {\n" + " \"transactionId\" : \"transactionId\",\n" + " \"requestId\" : \"requestId\",\n" + " \"callbackUrl\" : \"callBackUrl\",\n" + " \"sourceId\" : \"sourceId\",\n" + " \"requestType\" : \"requestType\",\n" + " \"numSolutions\" : 1,\n" + " \"optimizers\" : [ \"optimizer1\", \"optimizer2\" ],\n" @@ -147,7 +149,8 @@ public class OofClientTestIT extends BaseIntegrationTest { + " \"modelInvariantId\" : \"invarianteId\",\n" + " \"modelVersionId\" : \"versionId\",\n" + " \"modelName\" : \"modelName\",\n" + " \"modelVersion\" : \"version\",\n" + " \"modelCustomizationName\" : \"modelCustomizationName\"\n" + " }\n" + " } ]\n" - + " },\n" + " \"licenseInfo\" : \"\"\n" + "}", oofRequestOutput); + + " },\n" + " \"licenseInfo\" : { \n" + " \"licenseDemands\" : [ ]\n" + "}\n" + "}", + oofRequestOutput, false); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest1Vpn.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest1Vpn.json new file mode 100644 index 0000000000..99ce7fb2bf --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest1Vpn.json @@ -0,0 +1,58 @@ +{ + "requestInfo":{ + "transactionId":"requestId", + "requestId":"requestId", + "callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/OofResponse/requestId", + "sourceId":"mso", + "requestType":"create", + "numSolutions":1, + "optimizers":[ "placement" ], + "timeout":1800 + }, + "serviceInfo":{ + "serviceInstanceId":"testServiceInstanceId1", + "serviceName":"testServiceType1", + "modelInfo":{ + "modelInvariantId":"testModelInvariantUUID1", + "modelVersionId":"testModelUUID1", + "modelName":"testModelName1", + "modelVersion":"testModelVersion1" + } + }, + "placementInfo":{ + "requestParameters":{ + "customerLatitude":"customerLatitude", + "customerLongitude":"customerLongitude", + "customerName":"testCustomerName" + }, + "subscriberInfo":{ + "globalSubscriberId":"testCustomerId", + "subscriberName":"testCustomerName" + }, + "placementDemands":[ + { + "resourceModuleName":"testProxyInstanceName1", + "serviceResourceId":"testProxyId1", + "resourceModelInfo":{ + "modelInvariantId":"testProxyModelInvariantUuid1", + "modelVersionId":"testProxyModelUuid1", + "modelName":"testProxyModelName1", + "modelVersion":"testProxyModelVersion1" + } + }, + { + "resourceModuleName":"testProxyInstanceName2", + "serviceResourceId":"testProxyId2", + "resourceModelInfo":{ + "modelInvariantId":"testProxyModelInvariantUuid2", + "modelVersionId":"testProxyModelUuid2", + "modelName":"testProxyModelName2", + "modelVersion":"testProxyModelVersion2" + } + } + ] + }, + "licenseInfo":{ + "licenseDemands" : [ ] + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest1VpnOpt.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest1VpnOpt.json new file mode 100644 index 0000000000..d149b328df --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest1VpnOpt.json @@ -0,0 +1,61 @@ +{ + "requestInfo" : { + "transactionId" : "requestId", + "requestId" : "requestId", + "callbackUrl" : "http://localhost:28080/mso/WorkflowMesssage/OofResponse/requestId", + "sourceId" : "mso", + "requestType" : "create", + "numSolutions" : 1, + "optimizers" : [ "placement" ], + "timeout" : 1800 + }, + "serviceInfo" : { + "serviceInstanceId" : "serviceInstanceId", + "serviceName" : "serviceName", + "modelInfo" : { + "modelType" : "modelType-Service", + "modelInvariantId" : "modelInvariantId-Service", + "modelVersionId" : "modelVersionId-Service", + "modelName" : "modelName-Service", + "modelVersion" : "modelVersion-Service", + "modelCustomizationName" : "modelCustomizationName-Service" + } + }, + "placementInfo" : { + "requestParameters" : { + "customerLatitude" : "customerLatitude", + "customerLongitude" : "customerLongitude", + "customerName" : "customerName" + }, + "subscriberInfo" : { + "globalSubscriberId" : "globalSubscriberId", + "subscriberName" : "subscriberName" + }, + "placementDemands" : [ { + "serviceResourceId" : "testProxyId1", + "resourceModuleName" : "testProxyInstanceName1", + "resourceModelInfo" : { + "modelName" : "testProxyModelName1", + "modelVersionId" : "testProxyModelUuid1", + "modelVersion" : "testProxyModelVersion1", + "modelInvariantId" : "testProxyModelInvariantUuid1" + } + }, { + "serviceResourceId" : "testProxyId2", + "resourceModuleName" : "testProxyInstanceName2", + "resourceModelInfo" : { + "modelName" : "testProxyModelName2", + "modelVersionId" : "testProxyModelUuid2", + "modelVersion" : "testProxyModelVersion2", + "modelInvariantId" : "testProxyModelInvariantUuid2" + }, + "requiredCandidates" : [ { + "identifierType" : "vnfId", + "identifiers" : [ "testVnfId" ] + } ] + } ] + }, + "licenseInfo" : { + "licenseDemands" : [ ] + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest3Ar.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest3Ar.json new file mode 100644 index 0000000000..9b251aac9a --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest3Ar.json @@ -0,0 +1,67 @@ +{ + "requestInfo" : { + "transactionId" : "requestId", + "requestId" : "requestId", + "callbackUrl" : "http://localhost:28080/mso/WorkflowMesssage/OofResponse/requestId", + "sourceId" : "mso", + "requestType" : "create", + "numSolutions" : 1, + "optimizers" : [ "placement" ], + "timeout" : 1800 + }, + "serviceInfo" : { + "serviceInstanceId" : "testServiceInstanceId1", + "serviceName" : "testServiceType1", + "modelInfo" : { + "modelInvariantId" : "testModelInvariantUUID1", + "modelVersionId" : "testModelUUID1", + "modelName" : "testModelName1", + "modelVersion" : "testModelVersion1" + } + }, + "placementInfo" : { + "requestParameters": { + "customerLatitude": "customerLatitude", + "customerLongitude": "customerLongitude", + "customerName": "testCustomerName" + }, + "subscriberInfo": { + "globalSubscriberId" : "testCustomerId", + "subscriberName" : "testCustomerName" + }, + "placementDemands": [ + { + "serviceResourceId": "testAllottedResourceId1", + "resourceModuleName": "testAllottedModelInstanceName1", + "resourceModelInfo": { + "modelName": "testAllottedModelName1", + "modelVersionId": "testAllottedModelUuid1", + "modelVersion": "testAllottedModelVersion1", + "modelInvariantId": "testAllottedModelInvariantUuid1" + } + }, + { + "serviceResourceId": "testAllottedResourceId2", + "resourceModuleName": "testAllottedModelInstanceName2", + "resourceModelInfo": { + "modelName": "testAllottedModelName2", + "modelVersionId": "testAllottedModelUuid2", + "modelVersion": "testAllottedModelVersion2", + "modelInvariantId": "testAllottedModelInvariantUuid2" + } + }, + { + "serviceResourceId": "testAllottedResourceId3", + "resourceModuleName": "testAllottedModelInstanceName3", + "resourceModelInfo": { + "modelName": "testAllottedModelName3", + "modelVersionId": "testAllottedModelUuid3", + "modelVersion": "testAllottedModelVersion3", + "modelInvariantId": "testAllottedModelInvariantUuid3" + } + } ] + }, + "licenseInfo" : { + "licenseDemands" : [ ] + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest3Vpn.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest3Vpn.json new file mode 100644 index 0000000000..e3a735df00 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofRequest3Vpn.json @@ -0,0 +1,91 @@ +{ + "requestInfo" : { + "transactionId" : "requestId", + "requestId" : "requestId", + "callbackUrl" : "http://localhost:28080/mso/WorkflowMesssage/OofResponse/requestId", + "sourceId" : "mso", + "requestType" : "create", + "numSolutions" : 1, + "optimizers" : [ "placement" ], + "timeout" : 1800 + }, + "serviceInfo" : { + "serviceInstanceId" : "testServiceInstanceId1", + "serviceName" : "testServiceType1", + "modelInfo":{ + "modelInvariantId":"testModelInvariantUUID1", + "modelVersionId":"testModelUUID1", + "modelName":"testModelName1", + "modelVersion":"testModelVersion1" + } + }, + "placementInfo" : { + "requestParameters" : { + "customerLatitude" : "customerLatitude", + "customerLongitude" : "customerLongitude", + "customerName" : "testCustomerName" + }, + "subscriberInfo" : { + "globalSubscriberId" : "testCustomerId", + "subscriberName" : "testCustomerName" + }, + "placementDemands" : [ { + "resourceModuleName" : "testProxyInstanceName1", + "serviceResourceId" : "testProxyId1", + "resourceModelInfo" : { + "modelInvariantId" : "testProxyModelInvariantUuid1", + "modelVersionId" : "testProxyModelUuid1", + "modelName" : "testProxyModelName1", + "modelVersion" : "testProxyModelVersion1" + } + }, { + "resourceModuleName" : "testProxyInstanceName2", + "serviceResourceId" : "testProxyId2", + "resourceModelInfo" : { + "modelInvariantId" : "testProxyModelInvariantUuid2", + "modelVersionId" : "testProxyModelUuid2", + "modelName" : "testProxyModelName2", + "modelVersion" : "testProxyModelVersion2" + } + }, { + "resourceModuleName" : "testProxyInstanceName1", + "serviceResourceId" : "testProxyId1", + "resourceModelInfo" : { + "modelInvariantId" : "testProxyModelInvariantUuid1", + "modelVersionId" : "testProxyModelUuid1", + "modelName" : "testProxyModelName1", + "modelVersion" : "testProxyModelVersion1" + } + }, { + "resourceModuleName" : "testProxyInstanceName2", + "serviceResourceId" : "testProxyId2", + "resourceModelInfo" : { + "modelInvariantId" : "testProxyModelInvariantUuid2", + "modelVersionId" : "testProxyModelUuid2", + "modelName" : "testProxyModelName2", + "modelVersion" : "testProxyModelVersion2" + } + }, { + "resourceModuleName" : "testProxyInstanceName1", + "serviceResourceId" : "testProxyId1", + "resourceModelInfo" : { + "modelInvariantId" : "testProxyModelInvariantUuid1", + "modelVersionId" : "testProxyModelUuid1", + "modelName" : "testProxyModelName1", + "modelVersion" : "testProxyModelVersion1" + } + }, { + "resourceModuleName" : "testProxyInstanceName2", + "serviceResourceId" : "testProxyId2", + "resourceModelInfo" : { + "modelInvariantId" : "testProxyModelInvariantUuid2", + "modelVersionId" : "testProxyModelUuid2", + "modelName" : "testProxyModelName2", + "modelVersion" : "testProxyModelVersion2" + } + } ] + }, + "licenseInfo" : { + "licenseDemands" : [ ] + } +} |