summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorPlummer, Brittany <brittany.plummer@att.com>2020-01-09 17:14:13 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-01-09 17:14:14 -0500
commitb41b7f7b49f12d420f63d710916fb0fe8146e1b3 (patch)
treeae1a4f6f5a4bbd13d92cfa86a9754b30ef3692d0 /bpmn/so-bpmn-tasks
parent9d77758d706d13c1c2ea46ada1837d757adbf9ba (diff)
move population of instance names in requestdb
Removed saving instanceName in BBInputSetup Removed test for setting instanceName in BBInputSetup Moved saving instanceName to workflowaction Started adding tests for setting instanceName Added unit tests for setting instanceName Updated last modified by from apih to bpmn Updated access modifier for method no longer needed Removed requestId parameter no longer used Updated test to match parameter changes in BBInputSetup Added volumeGroup lookup by vnf and volumeGroup id Issue-ID: SO-2595 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ib1bbc53d00ae0257f2678756a1e8f9291d8e7fa2
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java55
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java107
2 files changed, 161 insertions, 1 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
index 39aa9d6c41..9d45272a60 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
@@ -23,10 +23,17 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.UUID;
import javax.persistence.EntityNotFoundException;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.InstanceGroup;
+import org.onap.aai.domain.yang.L3Network;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.Vnfc;
+import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.so.bpmn.common.DelegateExecutionImpl;
import org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner;
import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner;
@@ -357,6 +364,8 @@ public class WorkflowActionBBTasks {
} else if (resourceType == WorkflowType.INSTANCE_GROUP) {
request.setInstanceGroupId(resourceId);
}
+ setInstanceName(resourceId, resourceType, request);
+ request.setLastModifiedBy("CamundaBPMN");
requestDbclient.updateInfraActiveRequests(request);
} catch (Exception ex) {
logger.error("Exception in updateInstanceId", ex);
@@ -461,4 +470,50 @@ public class WorkflowActionBBTasks {
configBB.setConfigurationResourceKeys(configurationResourceKeys);
return configBB;
}
+
+ protected void setInstanceName(String resourceId, WorkflowType resourceType, InfraActiveRequests request) {
+ logger.debug("Setting instanceName in infraActiveRequest");
+ try {
+ if (resourceType == WorkflowType.SERVICE && request.getServiceInstanceName() == null) {
+ ServiceInstance service = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
+ if (service != null) {
+ request.setServiceInstanceName(service.getServiceInstanceName());
+ }
+ } else if (resourceType == WorkflowType.VNF && request.getVnfName() == null) {
+ GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(resourceId);
+ if (vnf != null) {
+ request.setVnfName(vnf.getVnfName());
+ }
+ } else if (resourceType == WorkflowType.VFMODULE && request.getVfModuleName() == null) {
+ VfModule vfModule = bbInputSetupUtils.getAAIVfModule(request.getVnfId(), resourceId);
+ if (vfModule != null) {
+ request.setVfModuleName(vfModule.getVfModuleName());
+ }
+ } else if (resourceType == WorkflowType.VOLUMEGROUP && request.getVolumeGroupName() == null) {
+ Optional<VolumeGroup> volumeGroup =
+ bbInputSetupUtils.getRelatedVolumeGroupByIdFromVnf(request.getVnfId(), resourceId);
+ if (volumeGroup.isPresent()) {
+ request.setVolumeGroupName(volumeGroup.get().getVolumeGroupName());
+ }
+ } else if (resourceType == WorkflowType.NETWORK && request.getNetworkName() == null) {
+ L3Network network = bbInputSetupUtils.getAAIL3Network(resourceId);
+ if (network != null) {
+ request.setNetworkName(network.getNetworkName());
+ }
+ } else if (resourceType == WorkflowType.CONFIGURATION && request.getConfigurationName() == null) {
+ org.onap.aai.domain.yang.Configuration configuration =
+ bbInputSetupUtils.getAAIConfiguration(resourceId);
+ if (configuration != null) {
+ request.setConfigurationName(configuration.getConfigurationName());
+ }
+ } else if (resourceType == WorkflowType.INSTANCE_GROUP && request.getInstanceGroupName() == null) {
+ InstanceGroup instanceGroup = bbInputSetupUtils.getAAIInstanceGroup(resourceId);
+ if (instanceGroup != null) {
+ request.setInstanceGroupName(instanceGroup.getInstanceGroupName());
+ }
+ }
+ } catch (Exception ex) {
+ logger.error("Exception in setInstanceName", ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
index ac7d82cd51..4991fa59ee 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
@@ -21,14 +21,18 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
@@ -40,17 +44,25 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
+import org.onap.aai.domain.yang.Configuration;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.InstanceGroup;
+import org.onap.aai.domain.yang.L3Network;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner;
import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
-import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
import org.springframework.core.env.Environment;
public class WorkflowActionBBTasksTest extends BaseTaskTest {
@@ -479,5 +491,98 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
assertEquals(workflowActionBBTasks.getConfigurationId(vnfc), "configurationId");
}
+ @Test
+ public void setServiceInstanceNameTest() {
+ String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
+ WorkflowType resourceType = WorkflowType.SERVICE;
+ InfraActiveRequests request = new InfraActiveRequests();
+ ServiceInstance service = new ServiceInstance();
+ service.setServiceInstanceName("serviceInstanceName");
+ doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById(resourceId);
+
+ workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
+ assertEquals("serviceInstanceName", request.getServiceInstanceName());
+ }
+
+ @Test
+ public void setVnfNameTest() {
+ String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
+ WorkflowType resourceType = WorkflowType.VNF;
+ InfraActiveRequests request = new InfraActiveRequests();
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfName("vnfName");
+ doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf(resourceId);
+
+ workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
+ assertEquals("vnfName", request.getVnfName());
+ }
+ @Test
+ public void setVfModuleNameTest() {
+ String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
+ WorkflowType resourceType = WorkflowType.VFMODULE;
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setVnfId("ae5cc3e8-c13c-4d88-aaf6-694ab4977b0e");
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleName("vfModuleName");
+ doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("ae5cc3e8-c13c-4d88-aaf6-694ab4977b0e", resourceId);
+
+ workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
+ assertEquals("vfModuleName", request.getVfModuleName());
+ }
+
+ @Test
+ public void setNetworkNameTest() {
+ String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
+ WorkflowType resourceType = WorkflowType.NETWORK;
+ InfraActiveRequests request = new InfraActiveRequests();
+ L3Network network = new L3Network();
+ network.setNetworkName("networkName");
+ doReturn(network).when(bbSetupUtils).getAAIL3Network(resourceId);
+
+ workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
+ assertEquals("networkName", request.getNetworkName());
+ }
+
+ @Test
+ public void setConfigurationNameTest() {
+ String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
+ WorkflowType resourceType = WorkflowType.CONFIGURATION;
+ InfraActiveRequests request = new InfraActiveRequests();
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationName("configurationName");
+ doReturn(configuration).when(bbSetupUtils).getAAIConfiguration(resourceId);
+
+ workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
+ assertEquals("configurationName", request.getConfigurationName());
+ }
+
+ @Test
+ public void setInstanceGroupNameTest() {
+ String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
+ WorkflowType resourceType = WorkflowType.INSTANCE_GROUP;
+ InfraActiveRequests request = new InfraActiveRequests();
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setInstanceGroupName("instanceGroupName");
+ doReturn(instanceGroup).when(bbSetupUtils).getAAIInstanceGroup(resourceId);
+
+ workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
+ assertEquals("instanceGroupName", request.getInstanceGroupName());
+ }
+
+ @Test
+ public void setVolumeGroupNameTest() {
+ String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
+ WorkflowType resourceType = WorkflowType.VOLUMEGROUP;
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setVnfId("4aa72c90-21eb-4465-8847-997e27af6c3e");
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+ Optional<VolumeGroup> returnVolumeGroup = Optional.of(volumeGroup);
+
+ doReturn(returnVolumeGroup).when(bbSetupUtils).getRelatedVolumeGroupByIdFromVnf(request.getVnfId(), resourceId);
+ workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
+
+ assertEquals("volumeGroupName", request.getVolumeGroupName());
+ }
}