diff options
Diffstat (limited to 'bpmn')
-rw-r--r-- | bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy (renamed from bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/HandleOrchestrationTask.groovy) | 0 | ||||
-rw-r--r-- | bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy | 75 | ||||
-rw-r--r-- | bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java | 44 |
3 files changed, 92 insertions, 27 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/HandleOrchestrationTask.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy index 89490ff620..89490ff620 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/HandleOrchestrationTask.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy index 6b7944cc6e..46f061d89c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy @@ -159,4 +159,79 @@ class CreateSliceServiceTest extends MsoGroovyTest { assertNotNull(values) } + @Test + void testPrepareDecomposeService() { + when(mockExecution.getVariable("uuiRequest")).thenReturn(uuiRequest) + when(mockExecution.getVariable("serviceProfile")).thenReturn(serviceProfile) + CreateSliceService sliceService = new CreateSliceService() + sliceService.prepareDecomposeService(mockExecution) + + String serviceModelInfoExcept = """{ + "modelInvariantUuid":"123456", + "modelUuid":"123456", + "modelVersion":"" + }""" + Mockito.verify(mockExecution, times(1)).setVariable(eq("ssServiceModelInfo"), captor.capture()) + String serviceModelInfo = captor.getValue() + assertEquals(serviceModelInfoExcept.replaceAll("\\s+", ""), + serviceModelInfo.replaceAll("\\s+", "")) + } + + @Test + void testProcessDecomposition() { + when(mockExecution.getVariable("uuiRequest")).thenReturn(uuiRequest) + when(mockExecution.getVariable("serviceProfile")).thenReturn(serviceProfile) + when(mockExecution.getVariable("nstSolution")).thenReturn(nstSolution) + + CreateSliceService sliceService = new CreateSliceService() + sliceService.processDecomposition(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("subscriptionServiceType"), captor.capture()) + assertEquals(captor.getValue(), "5G") + Mockito.verify(mockExecution, times(1)).setVariable(eq("serviceType"), captor.capture()) + assertEquals(captor.getValue(), "embb") + Mockito.verify(mockExecution, times(1)).setVariable(eq("resourceSharingLevel"), captor.capture()) + assertEquals(captor.getValue(), "shared") + Mockito.verify(mockExecution, times(1)).setVariable(eq("nstModelUuid"), captor.capture()) + assertEquals(captor.getValue(), "aaaaaa") + Mockito.verify(mockExecution, times(1)).setVariable(eq("nstModelInvariantUuid"), captor.capture()) + assertEquals(captor.getValue(), "bbbbbb") + } + + @Test + void testPrepareCreateOrchestrationTask() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("123456") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("test") + when(mockExecution.getVariable("serviceProfile")).thenReturn(serviceProfile) + + CreateSliceService sliceService = new CreateSliceService() + sliceService.prepareCreateOrchestrationTask(mockExecution) + + SliceTaskParams sliceTaskParamsExpect = new SliceTaskParams() + sliceTaskParamsExpect.setServiceId("123456") + sliceTaskParamsExpect.setServiceName("test") + sliceTaskParamsExpect.setServiceProfile(serviceProfile) + String paramJsonExpect = sliceTaskParamsExpect.convertToJson() + + Mockito.verify(mockExecution, times(2)).setVariable(eq("subscriptionServiceType"), captor.capture()) + List allValues = captor.getAllValues() + SliceTaskParams sliceTaskParams = allValues.get(0) + String paramJson = allValues.get(1) + assertEquals(sliceTaskParams.getServiceId(), sliceTaskParams.getServiceId()) + assertEquals(sliceTaskParams.getServiceName(), sliceTaskParams.getServiceName()) + assertEquals(sliceTaskParams.getServiceProfile(), sliceTaskParams.getServiceProfile()) + assertEquals(paramJsonExpect, paramJson) + } + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("operationId")).thenReturn("123456") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + CreateSliceService sliceService = new CreateSliceService() + sliceService.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def catchSyncResponse = captor.getValue() + assertEquals(catchSyncResponse, true) + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index eead1761ea..e01149f981 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -83,7 +83,6 @@ import org.onap.so.serviceinstancebeans.Networks; import org.onap.so.serviceinstancebeans.Pnfs; import org.onap.so.serviceinstancebeans.RelatedInstance; import org.onap.so.serviceinstancebeans.RequestDetails; -import org.onap.so.serviceinstancebeans.RequestInfo; import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.VfModules; @@ -169,18 +168,6 @@ public class WorkflowAction { } public void selectExecutionList(DelegateExecution execution) throws Exception { - final String apiVersion = (String) execution.getVariable(BBConstants.G_APIVERSION); - final String vnfType = (String) execution.getVariable(VNF_TYPE); - String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); - final String createInstanceAction = "createInstance"; - final String serviceType = - Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse(""); - - List<OrchestrationFlow> orchFlows = - (List<OrchestrationFlow>) execution.getVariable(BBConstants.G_ORCHESTRATION_FLOW); - WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution); - List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); - List<Resource> resourceList = new ArrayList<>(); execution.setVariable("sentSyncResponse", false); execution.setVariable("homing", false); execution.setVariable("calledHoming", false); @@ -205,8 +192,9 @@ public class WorkflowAction { WorkflowType resourceType = resource.getResourceType(); execution.setVariable("resourceName", resourceType.toString()); String resourceId = ""; - final String requestAction = (String) execution.getVariable(BBConstants.G_ACTION); - if (resource.isGenerated() && requestAction.equalsIgnoreCase(createInstanceAction) + String requestAction = (String) execution.getVariable(BBConstants.G_ACTION); + WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution); + if (resource.isGenerated() && requestAction.equalsIgnoreCase("createInstance") && sIRequest.getRequestDetails().getRequestInfo().getInstanceName() != null) { resourceId = validateResourceIdInAAI(resource.getResourceId(), resourceType, sIRequest.getRequestDetails().getRequestInfo().getInstanceName(), sIRequest.getRequestDetails(), @@ -214,6 +202,7 @@ public class WorkflowAction { } else { resourceId = resource.getResourceId(); } + String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); if ((serviceInstanceId == null || serviceInstanceId.isEmpty()) && resourceType == WorkflowType.SERVICE) { serviceInstanceId = resourceId; } @@ -232,10 +221,16 @@ public class WorkflowAction { "Could not resume request with request Id: " + requestId + ". No flowsToExecute was found"); } } else { + String vnfType = (String) execution.getVariable(VNF_TYPE); String cloudOwner = getCloudOwner(requestDetails.getCloudConfiguration()); + List<OrchestrationFlow> orchFlows = + (List<OrchestrationFlow>) execution.getVariable(BBConstants.G_ORCHESTRATION_FLOW); + final String apiVersion = (String) execution.getVariable(BBConstants.G_APIVERSION); + final String serviceType = + Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse(""); if (aLaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { - orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, + orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true, cloudOwner, serviceType); } String key = ""; @@ -248,12 +243,12 @@ public class WorkflowAction { } } boolean isConfiguration = isConfiguration(orchFlows); - Resource resourceKey = new Resource(resourceType, key, aLaCarte); + Resource resourceKey = new Resource(resourceType, key, true); if (isConfiguration && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) { List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks( new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) - .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(true) .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds) .setRequestDetails(requestDetails).setExecution(execution)); @@ -269,19 +264,21 @@ public class WorkflowAction { orchFlows = getVfModuleReplaceBuildingBlocks( new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) - .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(true) .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds) .setRequestDetails(requestDetails).setExecution(execution)); } for (OrchestrationFlow orchFlow : orchFlows) { ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, - apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, + apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, requestDetails, false, null, null, false); flowsToExecute.add(ebb); } } else { boolean foundRelated = false; boolean containsService = false; + List<Resource> resourceList = new ArrayList<>(); + List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) { // SERVICE-MACRO-ASSIGN will always get user params with a // service. @@ -440,13 +437,6 @@ public class WorkflowAction { return environment.getProperty(defaultCloudOwner); } - private boolean isSuppressRollback(RequestInfo requestInfo) { - if (requestInfo != null) { - return requestInfo.getSuppressRollback(); - } - return false; - } - protected <T> List<T> getRelatedResourcesInVfModule(String vnfId, String vfModuleId, Class<T> resultClass, AAIObjectType type) { List<T> vnfcs = new ArrayList<>(); |