aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-03-10 10:56:41 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-03-12 09:54:12 -0400
commitf99e4a56e6b9ec09ece48a7b111c9ec286220264 (patch)
treeaa6b58ca16295b592cb4343da52c3ac6465a0351 /bpmn/MSOCommonBPMN/src/test
parent308c3c2085864e04848e53a589773ff2e6e2c76a (diff)
add instance group support to SO
add create support add delete support added naming service support Change-Id: Iaf4f2bdae8ea55aca71d6e9b818a76e90db0b012 Issue-ID: SO-1616 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java11
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java28
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java125
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java38
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java67
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java66
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json323
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_instanceGroupAddMembers.json27
8 files changed, 674 insertions, 11 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java
index 634e0a6c9b..bc41b168ef 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java
@@ -105,12 +105,18 @@ public class ExtractPojosForBBTest extends BaseTest{
allotedResourcePend.setId("abc");
allotedResourcesPend.add(allotedResourcePend);
lookupKeyMap.put(ResourceKey.ALLOTTED_RESOURCE_ID, allotedResourcePend.getId());
-
+
Configuration configurationPend = new Configuration();
configurationPend.setConfigurationId("abc");
serviceInstancePend.getConfigurations().add(configurationPend);
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, configurationPend.getConfigurationId());
+ List<InstanceGroup> instanceGroupsPend = serviceInstancePend.getInstanceGroups();
+ InstanceGroup instanceGroupPend = new InstanceGroup();
+ instanceGroupPend.setId("test-instance-group-1");
+ instanceGroupsPend.add(instanceGroupPend);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupPend.getId());
+
customer.getServiceSubscription().getServiceInstances().add(serviceInstancePend);
gBBInput.setCustomer(customer);
@@ -136,6 +142,9 @@ public class ExtractPojosForBBTest extends BaseTest{
VpnBondingLink extractVpnBondingLinkPend = extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID, "testVpnBondingLink");
assertEquals(extractVpnBondingLinkPend.getVpnBondingLinkId(), vpnBondingLinkPend.getVpnBondingLinkId());
+
+ InstanceGroup extractInstanceGroupPend = extractPojos.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID, "test-instance-group-1");
+ assertEquals(instanceGroupPend.getId(), extractInstanceGroupPend.getId());
}
@Test
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
index 7e4afb7a12..ff592f5603 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
@@ -659,6 +659,34 @@ public class BBInputSetupMapperLayerTest {
}
@Test
+ public void testmapCatalogConfigurationToFabricConfiguration() {
+ String modelCustUUID = "modelCustomizationUUID";
+ String modelInvariantUUID = "modelInvariantUUID";
+ String modelVersionUUID = "modelUUID";
+ String policyName = "policyName";
+ ModelInfoConfiguration expected = new ModelInfoConfiguration();
+ expected.setModelCustomizationId(modelCustUUID);
+ expected.setModelInvariantId(modelInvariantUUID);
+ expected.setModelVersionId(modelVersionUUID);
+ expected.setPolicyName(policyName);
+
+ VnfVfmoduleCvnfcConfigurationCustomization fabricCustomization = new VnfVfmoduleCvnfcConfigurationCustomization();
+ fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
+ fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
+ fabricCustomization.setPolicyName(policyName);
+ fabricCustomization.setModelCustomizationUUID(modelCustUUID);
+
+ ConfigurationResource configurationResource = new ConfigurationResource();
+ configurationResource.setModelUUID(modelVersionUUID);
+ configurationResource.setModelInvariantUUID(modelInvariantUUID);
+ fabricCustomization.setConfigurationResource(configurationResource);
+
+ ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
public void testMapNameValueUserParams() throws IOException {
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
Map<String,Object> actual = bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index d7c681b938..4b10d513d6 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -93,6 +93,7 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResource;
import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
+import org.onap.so.db.catalog.beans.ConfigurationResource;
import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
import org.onap.so.db.catalog.beans.InstanceGroupType;
import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
@@ -101,6 +102,7 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
@@ -356,13 +358,61 @@ public class BBInputSetupTest {
String resourceId = "123";
String requestAction = "createInstance";
- doReturn(null).when(bbInputSetupMapperLayer).mapAAIGenericVnfIntoGenericVnf(ArgumentMatchers.isNull());
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnf-001");
+
+ doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(SPY_bbInputSetupUtils).getAAIGenericVnf(ArgumentMatchers.isA(String.class));
+ doReturn(null).when(bbInputSetupMapperLayer).mapAAIGenericVnfIntoGenericVnf(ArgumentMatchers.isA(org.onap.aai.domain.yang.GenericVnf.class));
GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction,
resourceId);
-
assertThat(actual, sameBeanAs(expected));
}
+
+ @Test
+ public void testGetGBBCMAddMembersAction() throws Exception {
+ GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockInstanceGroupExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_instanceGroupAddMembers.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String requestAction = "addMembers";
+ String instanceGroupId = "instance-group-001";
+
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setInstanceGroupId(instanceGroupId);
+ executeBB.setWorkflowResourceIds(workflowResourceIds);
+
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
+
+ org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = new org.onap.aai.domain.yang.InstanceGroup();
+ aaiInstanceGroup.setId(instanceGroupId);
+ aaiInstanceGroup.setInstanceGroupName("test instance group 1");
+
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setServiceInstanceId("service-instance-001");
+ aaiServiceInstance.setServiceInstanceName("test service instance 1");
+ Optional<org.onap.aai.domain.yang.ServiceInstance> optSI = Optional.of(aaiServiceInstance);
+
+ org.onap.aai.domain.yang.GenericVnf vnf1 = new org.onap.aai.domain.yang.GenericVnf();
+ vnf1.setVnfId("vnf-001");
+ vnf1.setVnfName("test vnf 1");
+
+ org.onap.aai.domain.yang.GenericVnf vnf2 = new org.onap.aai.domain.yang.GenericVnf();
+ vnf2.setVnfId("vnf-002");
+ vnf2.setVnfName("test vnf 2");
+
+ doReturn(aaiInstanceGroup).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(instanceGroupId);
+ doReturn(optSI).when(SPY_bbInputSetupUtils).getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
+ doReturn(vnf1).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-001");
+ doReturn(vnf2).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-002");
+
+ GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap,
+ requestAction, instanceGroupId);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
@Test
public void testGetGBBALaCarteNonService() throws Exception {
GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
@@ -385,7 +435,7 @@ public class BBInputSetupTest {
doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName",
- serviceInstance, lookupKeyMap, resourceId, vnfType);
+ serviceInstance, lookupKeyMap, resourceId, vnfType, null, null);
doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
executeBB, requestAction, null);
@@ -435,7 +485,7 @@ public class BBInputSetupTest {
doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName",
- serviceInstance, lookupKeyMap, resourceId, vnfType);
+ serviceInstance, lookupKeyMap, resourceId, vnfType, null, null);
doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
@@ -738,7 +788,7 @@ public class BBInputSetupTest {
doReturn(ModelType.network).when(modelInfo).getModelType();
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType);
+ lookupKeyMap, resourceId, vnfType, null, null);
verify(SPY_bbInputSetup, times(1)).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance,
lookupKeyMap, resourceId, null);
assertEquals("NetworkId populated", true, lookupKeyMap.get(ResourceKey.NETWORK_ID).equalsIgnoreCase(resourceId));
@@ -748,7 +798,7 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType);
+ lookupKeyMap, resourceId, vnfType, null, null);
verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId);
assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId));
@@ -758,7 +808,7 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbName, serviceInstance,
lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType);
+ lookupKeyMap, resourceId, vnfType, null, null);
verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(modelInfo, service, bbName, serviceInstance,
lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null);
assertEquals("VolumeGroupId populated", true, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId));
@@ -768,7 +818,7 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap,
resourceId, relatedInstanceList, instanceName, null, cloudConfiguration);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType);
+ lookupKeyMap, resourceId, vnfType, null, null);
verify(SPY_bbInputSetup, times(1)).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap,
resourceId, relatedInstanceList, instanceName, null, cloudConfiguration);
assertEquals("VfModuleId populated", true, lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId));
@@ -966,6 +1016,21 @@ public class BBInputSetupTest {
}
@Test
+ public void testPopulateInstanceGroup() throws Exception {
+ ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
+ Service service = Mockito.mock(Service.class);
+ List<InstanceGroup> instanceGroups = Mockito.spy(new ArrayList<>());
+ ServiceInstance serviceInstance = Mockito.spy(new ServiceInstance());
+ serviceInstance.setServiceInstanceId("si-001");
+ serviceInstance.setServiceInstanceName("test service instance");
+ serviceInstance.setInstanceGroups(instanceGroups);
+
+ SPY_bbInputSetup.populateInstanceGroup(modelInfo, service, serviceInstance, "instance-group-001", "test instance group");
+ verify(SPY_bbInputSetup, times(1)).mapCatalogInstanceGroup(isA(InstanceGroup.class), isA(ModelInfo.class), isA(Service.class));
+ verify(instanceGroups, times(1)).add(isA(InstanceGroup.class));
+ }
+
+ @Test
public void testIsVlanTagging() throws Exception {
boolean expected = true;
Service service = Mockito.mock(Service.class);
@@ -1186,6 +1251,43 @@ public class BBInputSetupTest {
assertEquals(modelInfoNetwork, network.getModelInfoNetwork());
}
+
+ @Test
+ public void testPopulateFabricConfiguration() throws JsonParseException, JsonMappingException, IOException {
+ String instanceName = "configurationName";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("configurationId");
+ configuration.setConfigurationName("configurationName");
+ serviceInstance.getConfigurations().add(configuration);
+ String resourceId = "configurationId";
+ // Mock service
+ Service service = mapper.readValue(
+ new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+ String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
+ ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
+ configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
+ configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
+ configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
+
+ VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new VnfVfmoduleCvnfcConfigurationCustomization();
+ ConfigurationResource configurationResource = new ConfigurationResource();
+ configurationResource.setModelUUID("modelUUID");
+ configurationResource.setModelInvariantUUID("modelInvariantUUID");
+ vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
+
+ doReturn(null).when(SPY_bbInputSetup).findConfigurationResourceCustomization(modelInfo, service);
+ doReturn(vnfVfmoduleCvnfcConfigurationCustomization).when(SPY_bbInputSetup).findVnfVfmoduleCvnfcConfigurationCustomization("vfModuleCustomizationUUID","vnfResourceCustomizationUUID","cvnfcCustomizationUUID");
+
+ SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
+ instanceName, configResourceKeys);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
+ }
@Test
public void testPopulateGenericVnf() throws JsonParseException, JsonMappingException, IOException {
@@ -1717,6 +1819,7 @@ public class BBInputSetupTest {
String vfModuleId = "vfModuleId";
String volumeGroupId = "volumeGroupId";
String configurationId = "configurationId";
+ String instanceGroupId = "instancegroupId";
expected.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);
expected.put(ResourceKey.NETWORK_ID, networkId);
@@ -1724,6 +1827,7 @@ public class BBInputSetupTest {
expected.put(ResourceKey.VF_MODULE_ID, vfModuleId);
expected.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupId);
expected.put(ResourceKey.CONFIGURATION_ID, configurationId);
+ expected.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId(serviceInstanceId);
@@ -1732,7 +1836,8 @@ public class BBInputSetupTest {
workflowResourceIds.setVfModuleId(vfModuleId);
workflowResourceIds.setVolumeGroupId(volumeGroupId);
workflowResourceIds.setConfigurationId(configurationId);
-
+ workflowResourceIds.setInstanceGroupId(instanceGroupId);
+
SPY_bbInputSetup.populateLookupKeyMapWithIds(workflowResourceIds, actual);
assertThat(actual, sameBeanAs(expected));
@@ -2602,4 +2707,4 @@ public class BBInputSetupTest {
assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
}
-}
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
index d1d66ae28d..54e513e7d9 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
@@ -44,6 +44,7 @@ import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Configuration;
@@ -58,6 +59,8 @@ import org.onap.aai.domain.yang.VolumeGroups;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException;
import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
@@ -636,6 +639,41 @@ public class BBInputSetupUtilsTest {
}
@Test
+ public void getRelatedServiceInstanceFromInstanceGroupTest() throws Exception {
+ Optional<ServiceInstances> expected = Optional.of(new ServiceInstances());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ serviceInstance.setServiceInstanceName("serviceInstanceName");
+ expected.get().getServiceInstance().add(serviceInstance);
+
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class));
+ Optional<ServiceInstance> actual = this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
+ assertEquals(actual.get().getServiceInstanceId(), expected.get().getServiceInstance().get(0).getServiceInstanceId());
+ }
+
+ @Test
+ public void getRelatedServiceInstanceFromInstanceGroupMultipleTest() throws Exception {
+ expectedException.expect(MultipleObjectsFoundException.class);
+ Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances());
+ ServiceInstance si1 = Mockito.mock(ServiceInstance.class);
+ ServiceInstance si2 = Mockito.mock(ServiceInstance.class);
+ serviceInstances.get().getServiceInstance().add(si1);
+ serviceInstances.get().getServiceInstance().add(si2);
+
+ doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class));
+ this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
+ }
+
+ @Test
+ public void getRelatedServiceInstanceFromInstanceGroupNotFoundTest() throws Exception {
+ expectedException.expect(NoServiceInstanceFoundException.class);
+ Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances());
+
+ doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class));
+ this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
+ }
+
+ @Test
public void getRelatedVnfByNameFromServiceInstanceTest() throws Exception {
Optional<GenericVnfs> expected = Optional.of(new GenericVnfs());
GenericVnf vnf = new GenericVnf();
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java
new file mode 100644
index 0000000000..1cf70d050a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.servicedecomposition.tasks.exceptions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException;
+
+public class MultipleObjectsFoundExceptionTest {
+ private static final String MESSAGE = "message";
+ private static final Throwable CAUSE = new Throwable();
+ private MultipleObjectsFoundException MultipleObjectsFoundException;
+
+ @Test
+ public void defaultConstructorTest() {
+ MultipleObjectsFoundException = new MultipleObjectsFoundException();
+ assertEquals(null, MultipleObjectsFoundException.getMessage());
+ assertEquals(null, MultipleObjectsFoundException.getCause());
+ }
+
+ @Test
+ public void messageConstructorTest() {
+ MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE);
+ assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
+ assertEquals(null, MultipleObjectsFoundException.getCause());
+ }
+
+ @Test
+ public void causeConstructorTest() {
+ MultipleObjectsFoundException = new MultipleObjectsFoundException(CAUSE);
+ assertEquals(CAUSE.toString(), MultipleObjectsFoundException.getMessage());
+ assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
+ }
+
+ @Test
+ public void messageAndCauseConstructorTest() {
+ MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE, CAUSE);
+ assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
+ assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
+ }
+
+ @Test
+ public void messageAndCauseAndFlagsConstructorTest() {
+ MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE, CAUSE, true, true);
+ assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
+ assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java
new file mode 100644
index 0000000000..344481dbed
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.servicedecomposition.tasks.exceptions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class NoServiceInstanceFoundExceptionTest {
+ private static final String MESSAGE = "message";
+ private static final Throwable CAUSE = new Throwable();
+ private NoServiceInstanceFoundException NoObjectFoundException;
+
+ @Test
+ public void defaultConstructorTest() {
+ NoObjectFoundException = new NoServiceInstanceFoundException();
+ assertEquals(null, NoObjectFoundException.getMessage());
+ assertEquals(null, NoObjectFoundException.getCause());
+ }
+
+ @Test
+ public void messageConstructorTest() {
+ NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE);
+ assertEquals(MESSAGE, NoObjectFoundException.getMessage());
+ assertEquals(null, NoObjectFoundException.getCause());
+ }
+
+ @Test
+ public void causeConstructorTest() {
+ NoObjectFoundException = new NoServiceInstanceFoundException(CAUSE);
+ assertEquals(CAUSE.toString(), NoObjectFoundException.getMessage());
+ assertEquals(CAUSE, NoObjectFoundException.getCause());
+ }
+
+ @Test
+ public void messageAndCauseConstructorTest() {
+ NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE, CAUSE);
+ assertEquals(MESSAGE, NoObjectFoundException.getMessage());
+ assertEquals(CAUSE, NoObjectFoundException.getCause());
+ }
+
+ @Test
+ public void messageAndCauseAndFlagsConstructorTest() {
+ NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE, CAUSE, true, true);
+ assertEquals(MESSAGE, NoObjectFoundException.getMessage());
+ assertEquals(CAUSE, NoObjectFoundException.getCause());
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json
new file mode 100644
index 0000000000..f55717fc91
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json
@@ -0,0 +1,323 @@
+{
+ "requestContext": {
+ "product-family-id": null,
+ "source": "VID",
+ "requestor-id": "az2016",
+ "subscription-service-type": null,
+ "user-params": {
+
+ },
+ "action": "addMembers",
+ "callback-url": null,
+ "service-uri": null,
+ "mso-request-id": "requestId",
+ "requestParameters": {
+
+ },
+ "configurationParameters": []
+ },
+ "orchContext": {
+ "is-rollback-enabled": true
+ },
+ "userInput": null,
+ "tenant": {
+ },
+ "cloudRegion": {
+ "lcp-cloud-region-id": null,
+ "cloud-owner": null,
+ "tenant-id": null,
+ "complex": null,
+ "cloud-region-version": null
+ },
+ "customer": {
+ "global-customer-id": null,
+ "subscriber-name": null,
+ "subscriber-type": null,
+ "subscriber-common-site-id": null,
+ "service-subscription": {
+ "service-type": null,
+ "temp-ub-sub-account-id": null,
+ "service-instances": [
+ {
+ "service-instance-id": "service-instance-001",
+ "service-instance-name": "test service instance 1",
+ "orchestration-status": null,
+ "owning-entity": null,
+ "project": null,
+ "collection": null,
+ "vnfs": [],
+ "pnfs": [],
+ "allotted-resources": [],
+ "networks": [],
+ "vpn-bonding-links": [],
+ "vhn-portal-url": null,
+ "service-instance-location-id": null,
+ "selflink": null,
+ "metadata": null,
+ "configurations": [],
+ "solution-info": null,
+ "model-info-service-instance": null,
+ "instance-groups": [
+ {
+ "id": "instance-group-001",
+ "description": null,
+ "resource-version": null,
+ "instance-group-name": "test instance group 1",
+ "orchestration-status": "INVENTORIED",
+ "model-info-instance-group": null,
+ "instance-group-function": null,
+ "vnfs": [
+ {
+ "vnf-id": "vnf-001",
+ "vnf-name": "test vnf 1",
+ "vnf-type": null,
+ "orchestration-status": null,
+ "vf-modules": [],
+ "volume-groups": [],
+ "line-of-business": null,
+ "platform": null,
+ "cascaded": null,
+ "cloud-params": {
+
+ },
+ "cloud-context": null,
+ "solution": null,
+ "vnf-name-2": null,
+ "service-id": null,
+ "regional-resource-zone": null,
+ "prov-status": null,
+ "operational-status": null,
+ "equipment-role": null,
+ "management-option": null,
+ "ipv4-oam-address": null,
+ "ipv4-loopback0-address": null,
+ "nm-lan-v6-address": null,
+ "management-v6-address": null,
+ "vcpu": null,
+ "vcpu-units": null,
+ "vmemory": null,
+ "vmemory-units": null,
+ "vdisk": null,
+ "vdisk-units": null,
+ "in-maint": null,
+ "is-closed-loop-disabled": null,
+ "summary-status": null,
+ "encrypted-access-flag": null,
+ "as-number": null,
+ "regional-resource-subzone": null,
+ "self-link": null,
+ "ipv4-oam-gateway-address": null,
+ "ipv4-oam-gateway-address-prefix-length": null,
+ "vlan-id-outer": null,
+ "nm-profile-name": null,
+ "l-interfaces": [],
+ "lag-interfaces": [],
+ "license": null,
+ "entitlements": [],
+ "model-info-generic-vnf": null,
+ "instance-groups": [],
+ "call-homing": null,
+ "nf-function": null,
+ "nf-role": null
+ },
+ {
+ "vnf-id": "vnf-002",
+ "vnf-name": "test vnf 2",
+ "vnf-type": null,
+ "orchestration-status": null,
+ "vf-modules": [],
+ "volume-groups": [],
+ "line-of-business": null,
+ "platform": null,
+ "cascaded": null,
+ "cloud-params": {
+
+ },
+ "cloud-context": null,
+ "solution": null,
+ "vnf-name-2": null,
+ "service-id": null,
+ "regional-resource-zone": null,
+ "prov-status": null,
+ "operational-status": null,
+ "equipment-role": null,
+ "management-option": null,
+ "ipv4-oam-address": null,
+ "ipv4-loopback0-address": null,
+ "nm-lan-v6-address": null,
+ "management-v6-address": null,
+ "vcpu": null,
+ "vcpu-units": null,
+ "vmemory": null,
+ "vmemory-units": null,
+ "vdisk": null,
+ "vdisk-units": null,
+ "in-maint": null,
+ "is-closed-loop-disabled": null,
+ "summary-status": null,
+ "encrypted-access-flag": null,
+ "as-number": null,
+ "regional-resource-subzone": null,
+ "self-link": null,
+ "ipv4-oam-gateway-address": null,
+ "ipv4-oam-gateway-address-prefix-length": null,
+ "vlan-id-outer": null,
+ "nm-profile-name": null,
+ "l-interfaces": [],
+ "lag-interfaces": [],
+ "license": null,
+ "entitlements": [],
+ "model-info-generic-vnf": null,
+ "instance-groups": [],
+ "call-homing": null,
+ "nf-function": null,
+ "nf-role": null
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "vpn-bindings": []
+ },
+ "serviceInstance": {
+ "service-instance-id": "service-instance-001",
+ "service-instance-name": "test service instance 1",
+ "orchestration-status": null,
+ "owning-entity": null,
+ "project": null,
+ "collection": null,
+ "vnfs": [],
+ "pnfs": [],
+ "allotted-resources": [],
+ "networks": [],
+ "vpn-bonding-links": [],
+ "vhn-portal-url": null,
+ "service-instance-location-id": null,
+ "selflink": null,
+ "metadata": null,
+ "configurations": [],
+ "solution-info": null,
+ "model-info-service-instance": null,
+ "instance-groups": [
+ {
+ "id": "instance-group-001",
+ "description": null,
+ "resource-version": null,
+ "instance-group-name": "test instance group 1",
+ "orchestration-status": "INVENTORIED",
+ "model-info-instance-group": null,
+ "instance-group-function": null,
+ "vnfs": [
+ {
+ "vnf-id": "vnf-001",
+ "vnf-name": "test vnf 1",
+ "vnf-type": null,
+ "orchestration-status": null,
+ "vf-modules": [],
+ "volume-groups": [],
+ "line-of-business": null,
+ "platform": null,
+ "cascaded": null,
+ "cloud-params": {
+
+ },
+ "cloud-context": null,
+ "solution": null,
+ "vnf-name-2": null,
+ "service-id": null,
+ "regional-resource-zone": null,
+ "prov-status": null,
+ "operational-status": null,
+ "equipment-role": null,
+ "management-option": null,
+ "ipv4-oam-address": null,
+ "ipv4-loopback0-address": null,
+ "nm-lan-v6-address": null,
+ "management-v6-address": null,
+ "vcpu": null,
+ "vcpu-units": null,
+ "vmemory": null,
+ "vmemory-units": null,
+ "vdisk": null,
+ "vdisk-units": null,
+ "in-maint": null,
+ "is-closed-loop-disabled": null,
+ "summary-status": null,
+ "encrypted-access-flag": null,
+ "as-number": null,
+ "regional-resource-subzone": null,
+ "self-link": null,
+ "ipv4-oam-gateway-address": null,
+ "ipv4-oam-gateway-address-prefix-length": null,
+ "vlan-id-outer": null,
+ "nm-profile-name": null,
+ "l-interfaces": [],
+ "lag-interfaces": [],
+ "license": null,
+ "entitlements": [],
+ "model-info-generic-vnf": null,
+ "instance-groups": [],
+ "call-homing": null,
+ "nf-function": null,
+ "nf-role": null
+ },
+ {
+ "vnf-id": "vnf-002",
+ "vnf-name": "test vnf 2",
+ "vnf-type": null,
+ "orchestration-status": null,
+ "vf-modules": [],
+ "volume-groups": [],
+ "line-of-business": null,
+ "platform": null,
+ "cascaded": null,
+ "cloud-params": {
+
+ },
+ "cloud-context": null,
+ "solution": null,
+ "vnf-name-2": null,
+ "service-id": null,
+ "regional-resource-zone": null,
+ "prov-status": null,
+ "operational-status": null,
+ "equipment-role": null,
+ "management-option": null,
+ "ipv4-oam-address": null,
+ "ipv4-loopback0-address": null,
+ "nm-lan-v6-address": null,
+ "management-v6-address": null,
+ "vcpu": null,
+ "vcpu-units": null,
+ "vmemory": null,
+ "vmemory-units": null,
+ "vdisk": null,
+ "vdisk-units": null,
+ "in-maint": null,
+ "is-closed-loop-disabled": null,
+ "summary-status": null,
+ "encrypted-access-flag": null,
+ "as-number": null,
+ "regional-resource-subzone": null,
+ "self-link": null,
+ "ipv4-oam-gateway-address": null,
+ "ipv4-oam-gateway-address-prefix-length": null,
+ "vlan-id-outer": null,
+ "nm-profile-name": null,
+ "l-interfaces": [],
+ "lag-interfaces": [],
+ "license": null,
+ "entitlements": [],
+ "model-info-generic-vnf": null,
+ "instance-groups": [],
+ "call-homing": null,
+ "nf-function": null,
+ "nf-role": null
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_instanceGroupAddMembers.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_instanceGroupAddMembers.json
new file mode 100644
index 0000000000..96684b6680
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_instanceGroupAddMembers.json
@@ -0,0 +1,27 @@
+{
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "az2016"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "vnf-001",
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "vnf-002",
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": []
+ }
+} \ No newline at end of file