diff options
Diffstat (limited to 'bpmn')
6 files changed, 153 insertions, 17 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index c91316ee5c..69c1c9f8ac 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -677,7 +677,7 @@ return json.toString() requestInfo.setCallbackUrl(callbackUrl) requestInfo.setSourceId("so") requestInfo.setTimeout(timeOut) - requestInfo.setNumSolutions(100) + requestInfo.setNumSolutions(1) nsiReqBody.setRequestInfo(requestInfo) nsiReqBody.setNSTInfo(nstInfo) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AAISliceUtil.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AAISliceUtil.groovy index b2415e296f..1b09c49124 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AAISliceUtil.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AAISliceUtil.groovy @@ -136,7 +136,7 @@ class AAISliceUtil { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } AAIResultWrapper wrapper = getAAIClient().get(uri, NotFoundException.class) - LOGGER.trace(" *****${PREFIX} Exit queryAAI *****") + LOGGER.trace(" ***** Exit queryAAI *****") return wrapper } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy index a3e245ffea..e4281045bd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy @@ -428,7 +428,8 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST") - serviceInfo.nssiName = allocateAnNssi.nssiName + serviceInfo.nssiName = sliceTaskInfo.suggestNssiId ? sliceTaskInfo.NSSTInfo.name : allocateAnNssi.nssiName + serviceInfo.nssiId = sliceTaskInfo.suggestNssiId nbiRequest.setServiceInfo(serviceInfo) nbiRequest.setEsrInfo(esrInfo) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 91a69b3123..ac959543a2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -374,14 +374,15 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ if (solution != null) { if (execution.getVariable("queryNsiFirst")) { if (solution.get("existingNSI")) { + processSharedNSI(solution, sliceTaskParams, execution) execution.setVariable("needQuerySliceProfile", true) } else { - processNewNSI(solution, sliceTaskParams) + processNewSliceProfiles(solution, sliceTaskParams) execution.setVariable("needQuerySliceProfile", false) } execution.setVariable("queryNsiFirst", false) } else { - processSharedNSI(solution, sliceTaskParams, execution) + processNewSliceProfiles(solution, sliceTaskParams) execution.setVariable("needQuerySliceProfile", false) } } @@ -400,18 +401,17 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ List<String> nssiId = aaiSliceUtil.getNSSIIdList(execution,nsiId) List<ServiceInstance> nssiInstances = aaiSliceUtil.getNSSIListFromAAI(execution, nssiId) - List<Map> sliceProfiles = sharedNSISolution.get("sliceProfiles") as List<Map> - handleSliceProfiles(sliceProfiles, sliceParams) Map<String, Object> nssiSolution = new HashMap<>() for(ServiceInstance instance: nssiInstances){ nssiSolution.put("NSSIId", instance.getServiceInstanceId()) nssiSolution.put("NSSIName", instance.getServiceInstanceName()) - processNssiResult(sliceParams, instance.getEnvironmentContext(), nssiSolution) + SubnetType subnetType = instance.getWorkloadContext() as SubnetType + processNssiResult(sliceParams, subnetType, nssiSolution) } } - private void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) { + private void processNewSliceProfiles(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) { Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map> handleSliceProfiles(sliceProfiles, sliceParams) diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java index cfaa4040c7..fb15ffa2b3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java @@ -21,35 +21,85 @@ package org.onap.so.bpmn.infrastructure.service.level; 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.times; +import static org.mockito.Mockito.verify; import java.util.ArrayList; +import java.util.List; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; import org.junit.Test; -import java.util.List; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants; +import org.onap.so.client.exception.ExceptionBuilder; +@RunWith(MockitoJUnitRunner.class) public class ServiceLevelTest { private static final String EXECUTION_KEY_PNF_NAME_LIST = "pnfNameList"; private static final String EXECUTION_KEY_PNF_COUNTER = "pnfCounter"; + private static final String PARAM_NAME = "param1"; + private static final String SCOPE = "scope1"; + private static final String PNF_NAME = "pnfName1"; + + @Mock + private ExceptionBuilder exceptionBuilderMock; + @InjectMocks + private ServiceLevel testedObject; + + private DelegateExecution execution; + + @Before + public void init() { + execution = new DelegateExecutionFake(); + } @Test public void pnfCounterExecution_success() { // given - String pnfName = "pnfName1"; - DelegateExecution execution = new DelegateExecutionFake(); - execution.setVariable(EXECUTION_KEY_PNF_NAME_LIST, createPnfNameList(pnfName)); + execution.setVariable(EXECUTION_KEY_PNF_NAME_LIST, createPnfNameList()); execution.setVariable(EXECUTION_KEY_PNF_COUNTER, 0); // when - new ServiceLevel().pnfCounterExecution(execution); + testedObject.pnfCounterExecution(execution); // then - assertThat(execution.getVariable(ServiceLevelConstants.PNF_NAME)).isEqualTo(pnfName); + assertThat(execution.getVariable(ServiceLevelConstants.PNF_NAME)).isEqualTo(PNF_NAME); assertThat(execution.getVariable(EXECUTION_KEY_PNF_COUNTER)).isEqualTo(1); } - private List<String> createPnfNameList(String pnfName) { + @Test + public void validateParams_success_paramExistsInExecution() { + // given + execution.setVariable(PARAM_NAME, "anyValue"); + // when + testedObject.validateParamsWithScope(execution, "anyScope", createParamList()); + // then + verify(exceptionBuilderMock, times(0)).buildAndThrowWorkflowException(any(DelegateExecution.class), + eq(ServiceLevelConstants.ERROR_CODE), any(String.class)); + } + + @Test + public void validateParams_exceptionParamDoesNotExistInExecution() { + // when + testedObject.validateParamsWithScope(execution, SCOPE, createParamList()); + // then + verify(exceptionBuilderMock).buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, + "Validation of health check workflow parameters failed for the scope: " + SCOPE); + } + + private List<String> createParamList() { + List<String> params = new ArrayList<>(); + params.add(PARAM_NAME); + return params; + } + + private List<String> createPnfNameList() { List<String> pnfNameList = new ArrayList<>(); - pnfNameList.add(pnfName); + pnfNameList.add(PNF_NAME); return pnfNameList; } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java new file mode 100644 index 0000000000..a9bfde9bab --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2021 Nokia + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * Modifications Copyright (c) 2021 Nokia + * ================================================================================ + * Modifications Copyright (c) 2020 Tech Mahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader; + + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.javatuples.Pair; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; +import java.util.ArrayList; +import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + + +public class VnfEBBLoaderTest { + + private String serviceId; + private String vnfId; + private BBInputSetupUtils bbInputSetupUtils; + private BBInputSetup bbInputSetup; + private WorkflowActionExtractResourcesAAI workflowActionUtils; + private ExceptionBuilder exceptionBuilder; + private DelegateExecution delegateExecution; + private VnfEBBLoader cut; + + private org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI; + private ServiceInstance serviceInstanceMSO; + + @Before + public void setup() { + serviceId = "service123"; + vnfId = "vnf123"; + serviceInstanceAAI = mock(org.onap.aai.domain.yang.ServiceInstance.class); + serviceInstanceMSO = mock(ServiceInstance.class); + bbInputSetupUtils = mock(BBInputSetupUtils.class); + bbInputSetup = mock(BBInputSetup.class); + workflowActionUtils = mock(WorkflowActionExtractResourcesAAI.class); + exceptionBuilder = mock(ExceptionBuilder.class); + delegateExecution = new DelegateExecutionFake(); + } + + @Test + public void traverseAAIVnf_shouldAddServiceToResourceList() throws Exception { + List<Resource> resourceList = new ArrayList<>(); + List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); + doReturn(serviceInstanceAAI).when(bbInputSetupUtils).getAAIServiceInstanceById(serviceId); + doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + cut = new VnfEBBLoader(bbInputSetupUtils, bbInputSetup, workflowActionUtils, exceptionBuilder); + cut.traverseAAIVnf(delegateExecution, resourceList, serviceId, vnfId, aaiResourceIds); + assertEquals(WorkflowType.SERVICE, resourceList.get(0).getResourceType()); + } +} |