aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java14
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java79
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java72
4 files changed, 155 insertions, 19 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java
index fb95ae3993..11707c4149 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,9 +27,15 @@ import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class AAIDeleteServiceInstance implements JavaDelegate {
+ private static final Logger logger = LoggerFactory.getLogger(AAIDeleteServiceInstance.class);
+ private static final String ERROR_MESSAGE =
+ "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI.";
+
ExceptionUtil exceptionUtil = new ExceptionUtil();
public void execute(DelegateExecution execution) throws Exception {
@@ -41,8 +47,8 @@ public class AAIDeleteServiceInstance implements JavaDelegate {
aaiRC.delete(serviceInstanceURI);
execution.setVariable("GENDS_SuccessIndicator", true);
} catch (Exception ex) {
- String msg = "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI."
- + ex.getMessage();
+ logger.debug(ERROR_MESSAGE, ex);
+ String msg = ERROR_MESSAGE + ex.getMessage();
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java
index 2d69351744..f7b0c662db 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java
@@ -7,9 +7,9 @@
* 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.
@@ -30,17 +30,70 @@ public class AAIServiceInstance {
String environmentContext;
String workloadContext;
- public AAIServiceInstance(String serviceInstanceName, String serviceType, String serviceRole,
- String orchestrationStatus, String modelInvariantUuid, String modelVersionId, String environmentContext,
- String workloadContext) {
- this.serviceInstanceName = serviceInstanceName;
- this.serviceType = serviceType;
- this.serviceRole = serviceRole;
- this.orchestrationStatus = orchestrationStatus;
- this.modelInvariantUuid = modelInvariantUuid;
- this.modelVersionId = modelVersionId;
- this.environmentContext = environmentContext;
- this.workloadContext = workloadContext;
+ public class AAIServiceInstanceBuilder {
+ private String serviceInstanceName;
+ private String serviceType;
+ private String serviceRole;
+ private String orchestrationStatus;
+ private String modelInvariantUuid;
+ private String modelVersionId;
+ private String environmentContext;
+ private String workloadContext;
+
+ public AAIServiceInstanceBuilder setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setModelInvariantUuid(String modelInvariantUuid) {
+ this.modelInvariantUuid = modelInvariantUuid;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setEnvironmentContext(String environmentContext) {
+ this.environmentContext = environmentContext;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ return this;
+ }
+
+ public AAIServiceInstance createAAIServiceInstance() {
+ return new AAIServiceInstance(this);
+ }
+ }
+
+ public AAIServiceInstance(AAIServiceInstanceBuilder aaiServiceInstanceBuilder) {
+ this.serviceInstanceName = aaiServiceInstanceBuilder.serviceInstanceName;
+ this.serviceType = aaiServiceInstanceBuilder.serviceType;
+ this.serviceRole = aaiServiceInstanceBuilder.serviceRole;
+ this.orchestrationStatus = aaiServiceInstanceBuilder.orchestrationStatus;
+ this.modelInvariantUuid = aaiServiceInstanceBuilder.modelInvariantUuid;
+ this.modelVersionId = aaiServiceInstanceBuilder.modelVersionId;
+ this.environmentContext = aaiServiceInstanceBuilder.environmentContext;
+ this.workloadContext = aaiServiceInstanceBuilder.workloadContext;
}
public String getServiceInstanceName() {
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 80c6f0b969..2284c4af1a 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
@@ -431,7 +431,12 @@ public class WorkflowAction {
execution.setVariable("isRollbackComplete", false);
} catch (Exception ex) {
- buildAndThrowException(execution, "Exception while setting execution list. ", ex);
+ if (!(execution.hasVariable("WorkflowException")
+ || execution.hasVariable("WorkflowExceptionExceptionMessage"))) {
+ buildAndThrowException(execution, "Exception while setting execution list. ", ex);
+ } else {
+ throw ex;
+ }
}
}
@@ -537,7 +542,7 @@ public class WorkflowAction {
if (configurations.size() > 1) {
String multipleRelationshipsError =
"Multiple relationships exist from VNFC " + vnfc.getVnfcName() + " to Configurations";
- buildAndThrowException(dataObj.getExecution(), multipleRelationshipsError,
+ buildAndThrowException(dataObj.getExecution(), "Exception in getConfigBuildingBlock: ",
new Exception(multipleRelationshipsError));
}
for (org.onap.aai.domain.yang.Configuration configuration : configurations) {
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 8e47c34cb0..4fdd97d95a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -41,6 +41,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
@@ -228,6 +229,77 @@ public class WorkflowActionTest extends BaseTaskTest {
}
@Test
+ public void selectExecutionListExceptionAlreadyBuiltTest() throws Exception {
+ DelegateExecution delegateExecution = new DelegateExecutionFake();
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ delegateExecution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ delegateExecution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ delegateExecution.setVariable("bpmnRequest", bpmnRequest);
+ delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("apiVersion", "7");
+ delegateExecution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
+ doAnswer(invocation -> {
+ DelegateExecutionFake execution = invocation.getArgument(0);
+ execution.setVariable("WorkflowException", "exception");
+ execution.setVariable("WorkflowExceptionErrorMessage", "errorMessage");
+ throw new BpmnError("WorkflowException");
+ }).when(exceptionUtil).buildAndThrowWorkflowException(delegateExecution, 7000,
+ "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations");
+
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule);
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
+
+ List<org.onap.aai.domain.yang.Configuration> configurations =
+ new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ configuration.setConfigurationId("configurationId");
+ configuration.setModelCustomizationId("modelCustimizationId");
+ configuration.setConfigurationName("testConfigurationName");
+ configurations.add(configuration);
+ org.onap.aai.domain.yang.Configuration configuration1 = new org.onap.aai.domain.yang.Configuration();
+ configuration1.setConfigurationId("configurationId");
+ configuration1.setModelCustomizationId("modelCustimizationId");
+ configuration1.setConfigurationName("testConfigurationName");
+ configurations.add(configuration1);
+ doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any());
+
+ doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(any());
+
+ thrown.expect(BpmnError.class);
+ SPY_workflowAction.selectExecutionList(delegateExecution);
+ assertEquals(
+ "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations",
+ delegateExecution.getVariable("WorkflowException"));
+ }
+
+ @Test
public void selectExecutionListDuplicateNameExceptionTest() throws Exception {
String gAction = "createInstance";
execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");