summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java37
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java59
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java26
4 files changed, 25 insertions, 99 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index e3540ecc58..583e3e172a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -77,7 +77,6 @@ public class AAICreateTasks {
private static final Logger logger = LoggerFactory.getLogger(AAICreateTasks.class);
private static final String networkTypeProvider = "PROVIDER";
- private static final String A_LA_CARTE = "aLaCarte";
private static String NETWORK_COLLECTION_NAME = "networkCollectionName";
private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
private static String HEAT_STACK_ID = "heatStackId";
@@ -107,12 +106,8 @@ public class AAICreateTasks {
public void createServiceInstance(BuildingBlockExecution execution) {
try {
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- if (Boolean.TRUE.equals(alaCarte) && aaiSIResources.checkInstanceServiceNameInUse(serviceInstance)) {
- throw new DuplicateNameException("service-instance", serviceInstance.getServiceInstanceName());
- }
Customer customer = execution.getGeneralBuildingBlock().getCustomer();
aaiSIResources.createServiceInstance(serviceInstance, customer);
} catch (Exception ex) {
@@ -199,11 +194,7 @@ public class AAICreateTasks {
public void createVnf(BuildingBlockExecution execution) {
try {
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- if (Boolean.TRUE.equals(alaCarte) && aaiVnfResources.checkNameInUse(vnf.getVnfName())) {
- throw new DuplicateNameException("generic-vnf", vnf.getVnfName());
- }
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
execution.setVariable("homing", Boolean.TRUE.equals(vnf.isCallHoming()));
@@ -262,10 +253,6 @@ public class AAICreateTasks {
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
CloudRegion cloudRegion = gBBInput.getCloudRegion();
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
- if (Boolean.TRUE.equals(alaCarte) && aaiVolumeGroupResources.checkNameInUse(volumeGroup)) {
- throw new DuplicateNameException("volume-group", volumeGroup.getVolumeGroupName());
- }
aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion);
@@ -278,10 +265,6 @@ public class AAICreateTasks {
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
- if (Boolean.TRUE.equals(alaCarte) && aaiVfModuleResources.checkNameInUse(vfModule)) {
- throw new DuplicateNameException("vf-module", vfModule.getVfModuleName());
- }
int moduleIndex = 0;
if (vfModule.getModelInfoVfModule() != null
&& !Boolean.TRUE.equals(vfModule.getModelInfoVfModule().getIsBaseBoolean())) {
@@ -327,14 +310,9 @@ public class AAICreateTasks {
*/
public void createNetwork(BuildingBlockExecution execution) {
try {
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- if (Boolean.TRUE.equals(alaCarte)
- && aaiNetworkResources.checkNetworkNameInUse(l3network.getNetworkName())) {
- throw new DuplicateNameException("l3Network", l3network.getNetworkName());
- }
// set default to false. ToBe updated by SDNC
l3network.setIsBoundToVpn(false);
// define is bound to vpn flag as true if NEUTRON_NETWORK_TYPE is PROVIDER
@@ -385,16 +363,11 @@ public class AAICreateTasks {
*/
public void createNetworkCollectionInstanceGroup(BuildingBlockExecution execution) {
try {
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
InstanceGroup instanceGroup = serviceInstance.getCollection().getInstanceGroup();
// set name generated for NetworkCollection/NetworkCollectionInstanceGroup in previous step of the BB flow
instanceGroup.setInstanceGroupName(execution.getVariable(NETWORK_COLLECTION_NAME));
- if (Boolean.TRUE.equals(alaCarte)
- && aaiInstanceGroupResources.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName())) {
- throw new DuplicateNameException("instance-group", instanceGroup.getInstanceGroupName());
- }
// put shell in AAI
aaiNetworkResources.createNetworkInstanceGroup(instanceGroup);
} catch (Exception ex) {
@@ -511,12 +484,7 @@ public class AAICreateTasks {
public void createConfiguration(BuildingBlockExecution execution) {
try {
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
- if (Boolean.TRUE.equals(alaCarte)
- && aaiConfigurationResources.checkConfigurationNameInUse(configuration.getConfigurationName())) {
- throw new DuplicateNameException("configuration", configuration.getConfigurationName());
- }
aaiConfigurationResources.createConfiguration(configuration);
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
@@ -525,14 +493,9 @@ public class AAICreateTasks {
public void createInstanceGroupVnf(BuildingBlockExecution execution) {
try {
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
- if (Boolean.TRUE.equals(alaCarte)
- && aaiInstanceGroupResources.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName())) {
- throw new DuplicateNameException("instance-group", instanceGroup.getInstanceGroupName());
- }
aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
index 155455e654..ea0b408e41 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
@@ -108,7 +108,7 @@ public class NamingServiceCreateTasks {
namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName());
namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion());
- namingRequestObject.setNetworkNameValue(execution.getVariable(network.getNetworkName()));
+ namingRequestObject.setNetworkNameValue(network.getNetworkName());
namingRequestObject.setVpnNameValue(vpnBinding.getVpnName());
namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
index b889493d2e..ed3ec759c3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
@@ -60,7 +60,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
-import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
@@ -130,14 +129,6 @@ public class AAICreateTasksTest extends BaseTaskTest {
}
@Test
- public void createServiceInstanceNameInUseExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doReturn(true).when(aaiServiceInstanceResources).checkInstanceServiceNameInUse(serviceInstance);
- execution.setVariable("aLaCarte", Boolean.TRUE);
- aaiCreateTasks.createServiceInstance(execution);
- }
-
- @Test
public void createServiceInstanceExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
@@ -162,14 +153,6 @@ public class AAICreateTasksTest extends BaseTaskTest {
}
@Test
- public void createVolumeGroupDuplicateNameTest() throws Exception {
- expectedException.expect(BpmnError.class);
- execution.setVariable("aLaCarte", Boolean.TRUE);
- doReturn(true).when(aaiVolumeGroupResources).checkNameInUse(volumeGroup);
- aaiCreateTasks.createVolumeGroup(execution);
- }
-
- @Test
public void createVolumeGroupExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
@@ -349,14 +332,6 @@ public class AAICreateTasksTest extends BaseTaskTest {
}
@Test
- public void createVnfDuplicateNameTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doReturn(true).when(aaiVnfResources).checkNameInUse(genericVnf.getVnfName());
- execution.setVariable("aLaCarte", Boolean.TRUE);
- aaiCreateTasks.createVnf(execution);
- }
-
- @Test
public void createVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "notfound");
@@ -386,14 +361,6 @@ public class AAICreateTasksTest extends BaseTaskTest {
}
@Test
- public void createVfModuleDuplicateNameTest() throws Exception {
- expectedException.expect(BpmnError.class);
- execution.setVariable("aLaCarte", Boolean.TRUE);
- doReturn(true).when(aaiVfModuleResources).checkNameInUse(vfModule);
- aaiCreateTasks.createVfModule(execution);
- }
-
- @Test
public void createServiceSubscriptionTest() {
doNothing().when(aaiServiceInstanceResources).createServiceSubscription(customer);
aaiCreateTasks.createServiceSubscription(execution);
@@ -441,14 +408,6 @@ public class AAICreateTasksTest extends BaseTaskTest {
}
@Test
- public void createNetworkNameInUseExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- execution.setVariable("aLaCarte", Boolean.TRUE);
- doReturn(true).when(aaiNetworkResources).checkNetworkNameInUse(network.getNetworkName());
- aaiCreateTasks.createNetwork(execution);
- }
-
- @Test
public void createNetworkExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
@@ -560,15 +519,6 @@ public class AAICreateTasksTest extends BaseTaskTest {
}
@Test
- public void createConfigurationNameInUseExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doReturn(true).when(aaiConfigurationResources)
- .checkConfigurationNameInUse(configuration.getConfigurationName());
- execution.setVariable("aLaCarte", Boolean.TRUE);
- aaiCreateTasks.createConfiguration(execution);
- }
-
- @Test
public void connectVnfToCloudRegionTest() throws Exception {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
@@ -609,15 +559,6 @@ public class AAICreateTasksTest extends BaseTaskTest {
}
@Test
- public void createInstanceGroupVnfNameInUseExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doReturn(true).when(aaiInstanceGroupResources)
- .checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName());
- execution.setVariable("aLaCarte", Boolean.TRUE);
- aaiCreateTasks.createInstanceGroupVnf(execution);
- }
-
- @Test
public void createInstanceGroupVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiInstanceGroupResources)
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
index 44e5e0e707..609d2dabd8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.infrastructure.namingservice.tasks;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
@@ -31,6 +32,7 @@ import static org.mockito.Mockito.when;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
@@ -47,6 +49,8 @@ import org.onap.so.client.aai.AAICommonObjectMapperProvider;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.Relationships;
import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.namingservice.NamingRequestObject;
+import org.onap.so.client.namingservice.NamingServiceConstants;
public class NamingServiceCreateTasksTest extends BaseTaskTest {
@InjectMocks
@@ -106,9 +110,17 @@ public class NamingServiceCreateTasksTest extends BaseTaskTest {
String generatedName = "generatedWanTransportServiceName";
doReturn(generatedName).when(namingServiceResources).generateServiceInstanceName(any());
NamingServiceCreateTasks spy = Mockito.spy(namingServiceCreateTasks);
+ ArgumentCaptor<NamingRequestObject> captor = ArgumentCaptor.forClass(NamingRequestObject.class);
spy.createWanTransportServiceName(execution);
- verify(namingServiceResources, times(1)).generateServiceInstanceName(any());
+ verify(namingServiceResources, times(1)).generateServiceInstanceName(captor.capture());
+ assertTrue(captor.getAllValues().get(0).getExternalKeyValue().startsWith("testServiceInstanceId"));
+ assertEquals(captor.getAllValues().get(0).getNamingTypeValue(), NamingServiceConstants.NAMING_TYPE_SERVICE);
+ assertEquals(captor.getAllValues().get(0).getResourceNameValue(),
+ NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
+ assertEquals(captor.getAllValues().get(0).getPolicyInstanceNameValue(), null);
+ assertTrue(captor.getAllValues().get(0).getServiceModelNameValue().startsWith("testModelName"));
+ assertTrue(captor.getAllValues().get(0).getModelVersionValue().startsWith("testModelVersion"));
assertEquals(generatedName, serviceInstance.getServiceInstanceName());
}
@@ -118,10 +130,20 @@ public class NamingServiceCreateTasksTest extends BaseTaskTest {
.thenReturn(buildL3Network());
when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VPN_ID)))
.thenReturn(buildVpnBinding());
+ ArgumentCaptor<NamingRequestObject> captor = ArgumentCaptor.forClass(NamingRequestObject.class);
String generatedName = "generatedWanTransportServiceName";
doReturn(generatedName).when(namingServiceResources).generateServiceInstanceName(any());
namingServiceCreateTasks.createVpnBondingServiceName(execution);
- verify(namingServiceResources, times(1)).generateServiceInstanceName(any());
+ verify(namingServiceResources, times(1)).generateServiceInstanceName(captor.capture());
+ assertTrue(captor.getAllValues().get(0).getExternalKeyValue().startsWith("testServiceInstanceId"));
+ assertEquals(captor.getAllValues().get(0).getPolicyInstanceNameValue(), null);
+ assertEquals(captor.getAllValues().get(0).getNamingTypeValue(), NamingServiceConstants.NAMING_TYPE_SERVICE);
+ assertTrue(captor.getAllValues().get(0).getServiceModelNameValue().startsWith("testModelName"));
+ assertTrue(captor.getAllValues().get(0).getModelVersionValue().startsWith("testModelVersion"));
+ assertTrue(captor.getAllValues().get(0).getNetworkNameValue().startsWith("testNetworkName"));
+ assertTrue(captor.getAllValues().get(0).getVpnNameValue().startsWith("testVpnName"));
+ assertEquals(captor.getAllValues().get(0).getResourceNameValue(),
+ NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
assertEquals(generatedName, serviceInstance.getServiceInstanceName());
}
}