aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java10
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java17
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java8
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java9
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java104
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java10
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java34
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundException.java47
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundException.java47
-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
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteInstanceGroupBB.bpmn62
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java8
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteInstanceGroupBBTest.java53
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java91
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java110
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java10
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java17
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java19
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java11
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java33
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java21
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java33
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java74
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationAction.java2
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java1
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomization.java1
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java13
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepository.java8
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest.java11
47 files changed, 1439 insertions, 183 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java
index b08b93eb87..89f4824492 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java
@@ -170,6 +170,14 @@ public class CvnfcCatalogDbQueryTest {
} else {
Assert.fail("No linked VnfVfmoduleCvnfcConfigurationCustomization found for CvnfcCustomization");
}
+
+ VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomizationFound = client.
+ getVnfVfmoduleCvnfcConfigurationCustomizationByVnfCustomizationUuidAndVfModuleCustomizationUuidAndCvnfcCustomizationUuid(
+ "6912dd02-2b16-11e9-b210-d663bd873d93",
+ "bdbf984a-2b16-11e9-b210-d663bd873d93",
+ "0c042562-2bac-11e9-b210-d663bd873d93");
+ assertNotNull(vnfVfmoduleCvnfcConfigurationCustomizationFound);
+ System.out.println(vnfVfmoduleCvnfcConfigurationCustomizationFound.getModelCustomizationUUID());
}
protected CvnfcCustomization setUpCvnfcCustomization(String id){
@@ -198,4 +206,4 @@ public class CvnfcCatalogDbQueryTest {
vnfcCustomization.setDescription("testVnfcCustomizationDescription");
return vnfcCustomization;
}
-}
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java
index deb8c8e393..7a58f6db6b 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java
@@ -30,6 +30,7 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.onap.so.bpmn.servicedecomposition.ShallowCopy;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
+import org.onap.so.db.catalog.beans.OrchestrationStatus;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
@@ -48,10 +49,14 @@ public class InstanceGroup implements Serializable, ShallowCopy<InstanceGroup>
private String resourceVersion;
@JsonProperty("instance-group-name")
private String instanceGroupName;
+ @JsonProperty("orchestration-status")
+ private OrchestrationStatus orchestrationStatus = OrchestrationStatus.PRECREATED;
@JsonProperty("model-info-instance-group")
private ModelInfoInstanceGroup modelInfoInstanceGroup;
@JsonProperty("instance-group-function")
private String instanceGroupFunction;
+ @JsonProperty("vnfs")
+ private List<GenericVnf> vnfs = new ArrayList<>();
public String getId() {
return id;
@@ -76,6 +81,12 @@ public class InstanceGroup implements Serializable, ShallowCopy<InstanceGroup>
}
public void setInstanceGroupName(String instanceGroupName) {
this.instanceGroupName = instanceGroupName;
+ }
+ public OrchestrationStatus getOrchestrationStatus() {
+ return orchestrationStatus;
+ }
+ public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
}
public ModelInfoInstanceGroup getModelInfoInstanceGroup() {
return modelInfoInstanceGroup;
@@ -89,6 +100,12 @@ public class InstanceGroup implements Serializable, ShallowCopy<InstanceGroup>
public void setInstanceGroupFunction(String instanceGroupFunction) {
this.instanceGroupFunction = instanceGroupFunction;
}
+ public List<GenericVnf> getVnfs() {
+ return vnfs;
+ }
+ public void setVnfs(List<GenericVnf> vnfs) {
+ this.vnfs = vnfs;
+ }
@Override
public boolean equals(final Object other) {
if (!(other instanceof InstanceGroup)) {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java
index 259a988262..e2a8688395 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java
@@ -79,6 +79,8 @@ public class ServiceInstance implements Serializable, ShallowCopy<ServiceInstanc
private SolutionInfo solutionInfo;
@JsonProperty("model-info-service-instance")
private ModelInfoServiceInstance modelInfoServiceInstance;
+ @JsonProperty("instance-groups")
+ private List<InstanceGroup> instanceGroups = new ArrayList<>();
public List<GenericVnf> getVnfs() {
return vnfs;
@@ -191,6 +193,12 @@ public class ServiceInstance implements Serializable, ShallowCopy<ServiceInstanc
public void setSolutionInfo(SolutionInfo solutionInfo) {
this.solutionInfo = solutionInfo;
}
+ public List<InstanceGroup> getInstanceGroups() {
+ return instanceGroups;
+ }
+ public void setInstanceGroups(List<InstanceGroup> instanceGroups) {
+ this.instanceGroups = instanceGroups;
+ }
@Override
public boolean equals(final Object other) {
if (!(other instanceof ServiceInstance)) {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java
index 433315b2ed..15dfe85c1a 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java
@@ -36,6 +36,7 @@ public class WorkflowResourceIds implements Serializable {
private String vfModuleId;
private String networkCollectionId;
private String configurationId;
+ private String instanceGroupId;
@Override
public String toString() {
@@ -100,4 +101,12 @@ public class WorkflowResourceIds implements Serializable {
public void setConfigurationId(String configurationId) {
this.configurationId = configurationId;
}
+
+ public String getInstanceGroupId() {
+ return instanceGroupId;
+ }
+
+ public void setInstanceGroupId(String instanceGroupId) {
+ this.instanceGroupId = instanceGroupId;
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 77372bcd88..c80cd3d2a0 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -59,6 +59,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException;
import org.onap.so.client.aai.AAICommonObjectMapperProvider;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIResultWrapper;
@@ -225,6 +226,7 @@ public class BBInputSetup implements JavaDelegate {
lookupKeyMap.put(ResourceKey.VF_MODULE_ID, workflowResourceIds.getVfModuleId());
lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, workflowResourceIds.getVolumeGroupId());
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, workflowResourceIds.getConfigurationId());
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, workflowResourceIds.getInstanceGroupId());
}
protected GeneralBuildingBlock getGBBALaCarteNonService(ExecuteBuildingBlock executeBB,
@@ -244,7 +246,7 @@ public class BBInputSetup implements JavaDelegate {
ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance);
serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service));
this.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap,
- resourceId, vnfType);
+ resourceId, vnfType, executeBB.getBuildingBlock().getKey(), executeBB.getConfigurationResourceKeys());
return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null);
} else {
logger.debug("Related Service Instance from AAI: {}", aaiServiceInstance);
@@ -255,25 +257,59 @@ public class BBInputSetup implements JavaDelegate {
protected GeneralBuildingBlock getGBBCM(ExecuteBuildingBlock executeBB,
RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction,
- String resourceId) throws Exception {
+ String resourceId) throws Exception {
ServiceInstance serviceInstance = new ServiceInstance();
String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
- serviceInstance.setServiceInstanceId(serviceInstanceId);
-
+ serviceInstance.setServiceInstanceId(serviceInstanceId);
+ Customer customer = new Customer();
List<GenericVnf> genericVnfs = serviceInstance.getVnfs();
String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
- org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
-
- GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
- genericVnfs.add(genericVnf);
-
- return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, new Customer());
+ if(vnfId != null) {
+ org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
+ GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
+ genericVnfs.add(genericVnf);
+ }
+ String instanceGroupId = lookupKeyMap.get(ResourceKey.INSTANCE_GROUP_ID);
+ if(instanceGroupId != null) {
+ org.onap.aai.domain.yang.InstanceGroup aaiInstancegroup = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
+ InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstancegroup);
+ instanceGroup.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+
+ if(serviceInstanceId == null) {
+ Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstanceOpt = bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
+ if(aaiServiceInstanceOpt.isPresent()) {
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiServiceInstanceOpt.get();
+ serviceInstance = this.mapperLayer.mapAAIServiceInstanceIntoServiceInstance(aaiServiceInstance);
+ WorkflowResourceIds workflowResourceIds = executeBB.getWorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, workflowResourceIds.getServiceInstanceId());
+ } else {
+ throw new NoServiceInstanceFoundException("Related ServiceInstance not found in A&AI.");
+ }
+ }
+ RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList();
+ if (relatedInstanceList != null) {
+ for (RelatedInstanceList relatedInstList : relatedInstanceList) {
+ RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
+ if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(relatedInstance.getInstanceId());
+ GenericVnf vnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiVnf);
+ instanceGroup.getVnfs().add(vnf);
+ }
+ }
+ }
+
+ serviceInstance.getInstanceGroups().add(instanceGroup);
+ customer.setServiceSubscription(new ServiceSubscription());
+ }
+ return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, customer);
}
protected void populateObjectsOnAssignAndCreateFlows(RequestDetails requestDetails, Service service, String bbName,
- ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType)
+ ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType,
+ String configurationKey, ConfigurationResourceKeys configurationResourceKeys)
throws Exception {
ModelInfo modelInfo = requestDetails.getModelInfo();
String instanceName = requestDetails.getRequestInfo().getInstanceName();
@@ -296,13 +332,36 @@ public class BBInputSetup implements JavaDelegate {
this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
relatedInstanceList, instanceName, vnfType, null);
} else if (modelType.equals(ModelType.vfModule)) {
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId);
- this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration());
+ if(bbName.contains("Configuration")) {
+ ModelInfo configurationModelInfo = new ModelInfo();
+ configurationModelInfo.setModelCustomizationUuid(configurationKey);
+ populateConfiguration(configurationModelInfo, service, bbName, serviceInstance,
+ lookupKeyMap, resourceId, instanceName, configurationResourceKeys);
+ } else {
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId);
+ this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
+ relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration());
+ }
+ } else if (modelType.equals(ModelType.instanceGroup)) {
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, resourceId);
+ this.populateInstanceGroup(modelInfo, service, serviceInstance, resourceId, instanceName);
} else {
return;
}
}
+
+ protected void populateInstanceGroup(ModelInfo modelInfo, Service service, ServiceInstance serviceInstance, String instanceGroupId, String instanceName) {
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setId(instanceGroupId);
+ instanceGroup.setInstanceGroupName(instanceName);
+ mapCatalogInstanceGroup(instanceGroup, modelInfo, service);
+ serviceInstance.getInstanceGroups().add(instanceGroup);
+ }
+
+ protected void mapCatalogInstanceGroup(InstanceGroup instanceGroup, ModelInfo modelInfo, Service service) {
+ // @TODO: this will populate the instanceGroup model info.
+ // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter to support VNF Groups
+ }
protected void populateConfiguration(ModelInfo modelInfo, Service service, String bbName,
ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String instanceName, ConfigurationResourceKeys configurationResourceKeys) {
@@ -344,13 +403,19 @@ public class BBInputSetup implements JavaDelegate {
if (configurationResourceCustomization != null && vnfVfmoduleCvnfcConfigurationCustomization != null) {
configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization
, vnfVfmoduleCvnfcConfigurationCustomization));
+ } else {
+ logger.debug("for Fabric configuration mapping by VF MODULE CUST UUID: " + configurationResourceKeys.getVfModuleCustomizationUUID());
+ vnfVfmoduleCvnfcConfigurationCustomization = findVnfVfmoduleCvnfcConfigurationCustomization(configurationResourceKeys.getVfModuleCustomizationUUID(),
+ configurationResourceKeys.getVnfResourceCustomizationUUID(), configurationResourceKeys.getCvnfcCustomizationUUID());
+ if (vnfVfmoduleCvnfcConfigurationCustomization != null){
+ configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(vnfVfmoduleCvnfcConfigurationCustomization));
+ }
}
}
protected VnfVfmoduleCvnfcConfigurationCustomization findVnfVfmoduleCvnfcConfigurationCustomization(String vfModuleCustomizationUUID,
String vnfResourceCustomizationUUID, String cvnfcCustomizationUUID, ConfigurationResourceCustomization configurationResourceCustomization) {
-
- if(configurationResourceCustomization.getConfigurationResource() != null)
+ if(configurationResourceCustomization != null && configurationResourceCustomization.getConfigurationResource() != null)
for(VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization :
configurationResourceCustomization.getConfigurationResource().getVnfVfmoduleCvnfcConfigurationCustomization()) {
if(vnfVfmoduleCvnfcConfigurationCustomization.getVfModuleCustomization().getModelCustomizationUUID().equalsIgnoreCase(vfModuleCustomizationUUID)
@@ -370,6 +435,13 @@ public class BBInputSetup implements JavaDelegate {
}
return null;
}
+
+ protected VnfVfmoduleCvnfcConfigurationCustomization findVnfVfmoduleCvnfcConfigurationCustomization(String vnfResourceCustomizationUUID,
+ String vfModuleCustomizationUUID, String cvnfcCustomizationUUID) {
+ return bbInputSetupUtils.getVnfVfmoduleCvnfcConfigurationCustomizationByActionAndIsALaCarteAndRequestScopeAndCloudOwner(vnfResourceCustomizationUUID,
+ vfModuleCustomizationUUID, cvnfcCustomizationUUID);
+
+ }
protected void populateVfModule(ModelInfo modelInfo, Service service, String bbName,
ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId,
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
index a838ffdbae..fac2e9b8c3 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
@@ -496,6 +496,16 @@ public class BBInputSetupMapperLayer {
modelInfoConfiguration.setPolicyName(vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName());
return modelInfoConfiguration;
}
+
+ protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration(
+ VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization) {
+ ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
+ modelInfoConfiguration.setModelVersionId(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationResource().getModelUUID());
+ modelInfoConfiguration.setModelCustomizationId(vnfVfmoduleCvnfcConfigurationCustomization.getModelCustomizationUUID());
+ modelInfoConfiguration.setModelInvariantId(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationResource().getModelInvariantUUID());
+ modelInfoConfiguration.setPolicyName(vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName());
+ return modelInfoConfiguration;
+ }
public NetworkResourceCustomization mapCollectionNetworkResourceCustToNetworkResourceCust(
CollectionNetworkResourceCustomization collectionNetworkResourceCust) {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
index 486164e75f..a71c38f127 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
@@ -42,6 +42,8 @@ import org.onap.aai.domain.yang.VolumeGroup;
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.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.entities.AAIResultWrapper;
@@ -53,6 +55,8 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -137,6 +141,16 @@ public class BBInputSetupUtils {
return catalogDbClient.getNetworkCollectionResourceCustomizationByID(collectionCustomizationId);
}
+ public VfModuleCustomization getVfModuleCustomizationByModelCuztomizationUUID(String modelCustomizationUUID) {
+ return catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(modelCustomizationUUID);
+ }
+
+ public VnfVfmoduleCvnfcConfigurationCustomization getVnfVfmoduleCvnfcConfigurationCustomizationByActionAndIsALaCarteAndRequestScopeAndCloudOwner(String vnfCustomizationUuid,
+ String vfModuleCustomizationUuid, String cvnfcCustomizationUuid) {
+ return catalogDbClient.getVnfVfmoduleCvnfcConfigurationCustomizationByVnfCustomizationUuidAndVfModuleCustomizationUuidAndCvnfcCustomizationUuid(vnfCustomizationUuid,
+ vfModuleCustomizationUuid, cvnfcCustomizationUuid);
+ }
+
public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroups(String modelCustomizationUUID) {
return catalogDbClient.getVnfcInstanceGroupsByVnfResourceCust(modelCustomizationUUID);
}
@@ -346,6 +360,26 @@ public class BBInputSetupUtils {
}
+ public Optional<ServiceInstance> getRelatedServiceInstanceFromInstanceGroup(String instanceGroupId) throws Exception {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId);
+ uri.relatedTo(AAIObjectPlurals.SERVICE_INSTANCE);
+ Optional<ServiceInstances> serviceInstances = injectionHelper.getAaiClient().get(ServiceInstances.class, uri);
+ ServiceInstance serviceInstance = null;
+ if (!serviceInstances.isPresent()) {
+ logger.debug("No ServiceInstances were found");
+ return Optional.empty();
+ } else {
+ if (serviceInstances.get().getServiceInstance().isEmpty()) {
+ throw new NoServiceInstanceFoundException("No ServiceInstances Returned");
+ } else if (serviceInstances.get().getServiceInstance().size() > 1) {
+ throw new MultipleObjectsFoundException("Multiple ServiceInstances Returned");
+ } else {
+ serviceInstance = serviceInstances.get().getServiceInstance().get(0);
+ }
+ return Optional.of(serviceInstance);
+ }
+ }
+
public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName) throws Exception{
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
uri.relatedTo(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName);
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java
index 79f4a07974..d2d321f8f4 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java
@@ -90,6 +90,10 @@ public class ExtractPojosForBB {
serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
result = lookupObjectInList(serviceInstance.getVpnBondingLinks(),value);
break;
+ case INSTANCE_GROUP_ID:
+ serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
+ result = lookupObjectInList(serviceInstance.getInstanceGroups(), value);
+ break;
default:
throw new BBObjectNotFoundException(key, value);
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundException.java
new file mode 100644
index 0000000000..d63f98b6ce
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundException.java
@@ -0,0 +1,47 @@
+/*-
+ * ============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;
+
+public class MultipleObjectsFoundException extends Exception {
+
+ private static final long serialVersionUID = -5045275644426587447L;
+
+ public MultipleObjectsFoundException() {
+ super();
+ }
+
+ public MultipleObjectsFoundException(String message) {
+ super(message);
+ }
+
+ public MultipleObjectsFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MultipleObjectsFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ public MultipleObjectsFoundException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundException.java
new file mode 100644
index 0000000000..2ef1a80cce
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundException.java
@@ -0,0 +1,47 @@
+/*-
+ * ============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;
+
+public class NoServiceInstanceFoundException extends Exception {
+
+ private static final long serialVersionUID = 3270499954054029908L;
+
+ public NoServiceInstanceFoundException() {
+ super();
+ }
+
+ public NoServiceInstanceFoundException(String message) {
+ super(message);
+ }
+
+ public NoServiceInstanceFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoServiceInstanceFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ public NoServiceInstanceFoundException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
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
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteInstanceGroupBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteInstanceGroupBB.bpmn
new file mode 100644
index 0000000000..d16f4405b2
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteInstanceGroupBB.bpmn
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0">
+ <bpmn:process id="DeleteInstanceGroupBB" name="DeleteInstanceGroupBB" isExecutable="true">
+ <bpmn:startEvent id="DeleteInstanceGroupBB_Start">
+ <bpmn:outgoing>SequenceFlow_0wlfmtw</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:endEvent id="DeleteInstanceGroupBB_End">
+ <bpmn:incoming>SequenceFlow_068apyw</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_0wlfmtw" sourceRef="DeleteInstanceGroupBB_Start" targetRef="DeleteInstanceGroupNaming" />
+ <bpmn:sequenceFlow id="SequenceFlow_18azuvq" sourceRef="DeleteInstanceGroupNaming" targetRef="DeleteInstanceGroupAAI" />
+ <bpmn:sequenceFlow id="SequenceFlow_068apyw" sourceRef="DeleteInstanceGroupAAI" targetRef="DeleteInstanceGroupBB_End" />
+ <bpmn:serviceTask id="DeleteInstanceGroupNaming" name="Delete Instance Group from Naming mS" camunda:expression="${NamingServiceDeleteTasks.deleteInstanceGroupName(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0wlfmtw</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_18azuvq</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="DeleteInstanceGroupAAI" name="Delete Instance Group from A&#38;AI" camunda:expression="${AAIDeleteTasks.deleteInstanceGroup(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_18azuvq</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_068apyw</bpmn:outgoing>
+ </bpmn:serviceTask>
+ </bpmn:process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteInstanceGroupBB">
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="DeleteInstanceGroupBB_Start">
+ <dc:Bounds x="173" y="102" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_1fy6x5e_di" bpmnElement="DeleteInstanceGroupBB_End">
+ <dc:Bounds x="645" y="102" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="663" y="138" width="0" height="0" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0wlfmtw_di" bpmnElement="SequenceFlow_0wlfmtw">
+ <di:waypoint xsi:type="dc:Point" x="209" y="120" />
+ <di:waypoint xsi:type="dc:Point" x="280" y="120" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="245" y="105" width="0" height="0" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_18azuvq_di" bpmnElement="SequenceFlow_18azuvq">
+ <di:waypoint xsi:type="dc:Point" x="380" y="120" />
+ <di:waypoint xsi:type="dc:Point" x="460" y="120" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="420" y="105" width="0" height="0" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_068apyw_di" bpmnElement="SequenceFlow_068apyw">
+ <di:waypoint xsi:type="dc:Point" x="560" y="120" />
+ <di:waypoint xsi:type="dc:Point" x="645" y="120" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="603" y="105" width="0" height="0" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0nh16a5_di" bpmnElement="DeleteInstanceGroupNaming">
+ <dc:Bounds x="280" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_0ybtwi8_di" bpmnElement="DeleteInstanceGroupAAI">
+ <dc:Bounds x="460" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
index 79bade3cf3..f4b528c4be 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
@@ -61,6 +61,8 @@ import org.onap.so.bpmn.infrastructure.flowspecific.tasks.CreateNetworkCollectio
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.GenericVnfHealthCheck;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.UnassignNetworkBB;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.UnassignVnf;
+import org.onap.so.bpmn.infrastructure.namingservice.tasks.NamingServiceCreateTasks;
+import org.onap.so.bpmn.infrastructure.namingservice.tasks.NamingServiceDeleteTasks;
import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCActivateTasks;
import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCAssignTasks;
import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCChangeAssignTasks;
@@ -230,6 +232,12 @@ public abstract class BaseBPMNTest {
protected SniroHomingV2 sniroHoming;
@MockBean
+ protected NamingServiceDeleteTasks namingServiceDeleteTasks;
+
+ @MockBean
+ protected NamingServiceCreateTasks namingServiceCreateTasks;
+
+ @MockBean
protected WorkflowActionBBFailure workflowActionBBFailure;
@MockBean
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteInstanceGroupBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteInstanceGroupBBTest.java
new file mode 100644
index 0000000000..6dc36ae100
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteInstanceGroupBBTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 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.infrastructure.bpmn.subprocess;
+import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+
+import java.io.IOException;
+
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.junit.Test;
+import org.onap.so.bpmn.BaseBPMNTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+
+public class DeleteInstanceGroupBBTest extends BaseBPMNTest{
+ @Test
+ public void sunnyDay() throws InterruptedException, IOException {
+ ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteInstanceGroupBB", variables);
+ assertThat(pi).isNotNull();
+ assertThat(pi).isStarted().hasPassedInOrder("DeleteInstanceGroupBB_Start", "DeleteInstanceGroupNaming", "DeleteInstanceGroupAAI",
+ "DeleteInstanceGroupBB_End");
+ assertThat(pi).isEnded();
+ }
+
+ @Test
+ public void rainyDay() throws Exception {
+ doThrow(BpmnError.class).when(aaiDeleteTasks).deleteInstanceGroup(any(BuildingBlockExecution.class));
+ ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteInstanceGroupBB", variables);
+ assertThat(pi).isNotNull();
+ assertThat(pi).isStarted()
+ .hasPassedInOrder("DeleteInstanceGroupBB_Start", "DeleteInstanceGroupNaming", "DeleteInstanceGroupAAI")
+ .hasNotPassed("DeleteInstanceGroupBB_End");
+ assertThat(pi).isEnded();
+ }
+}
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 8711f965fd..5534a39685 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
@@ -55,6 +55,7 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAIConfigurationResources;
+import org.onap.so.client.orchestration.AAIInstanceGroupResources;
import org.onap.so.client.orchestration.AAINetworkResources;
import org.onap.so.client.orchestration.AAIServiceInstanceResources;
import org.onap.so.client.orchestration.AAIVfModuleResources;
@@ -97,6 +98,8 @@ public class AAICreateTasks {
@Autowired
private AAIConfigurationResources aaiConfigurationResources;
@Autowired
+ private AAIInstanceGroupResources aaiInstanceGroupResources;
+ @Autowired
private Environment env;
public void createServiceInstance(BuildingBlockExecution execution) {
@@ -450,6 +453,16 @@ public class AAICreateTasks {
}
}
+ public void createInstanceGroupVnf(BuildingBlockExecution execution){
+ try{
+ ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
+ InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID, execution.getLookupMap().get(ResourceKey.INSTANCE_GROUP_ID));
+ aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
public void createNetworkPolicies(BuildingBlockExecution execution) {
try{
String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java
index 4908cda26a..6e4a5f3d15 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java
@@ -32,6 +32,7 @@ import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
@@ -43,6 +44,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAIConfigurationResources;
+import org.onap.so.client.orchestration.AAIInstanceGroupResources;
import org.onap.so.client.orchestration.AAINetworkResources;
import org.onap.so.client.orchestration.AAIServiceInstanceResources;
import org.onap.so.client.orchestration.AAIVfModuleResources;
@@ -76,6 +78,8 @@ public class AAIDeleteTasks {
private AAIVolumeGroupResources aaiVolumeGroupResources;
@Autowired
private AAIConfigurationResources aaiConfigurationResources;
+ @Autowired
+ private AAIInstanceGroupResources aaiInstanceGroupResources;
public void deleteVfModule(BuildingBlockExecution execution) throws Exception {
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
@@ -162,6 +166,15 @@ public class AAIDeleteTasks {
}
}
+ public void deleteInstanceGroupVnf(BuildingBlockExecution execution) {
+ try {
+ InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID, execution.getLookupMap().get(ResourceKey.INSTANCE_GROUP_ID));
+ aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
public void deleteNetworkPolicies(BuildingBlockExecution execution) {
try{
String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
index 75f293655f..a622520a71 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
@@ -108,6 +108,10 @@ public class OrchestrationStatusValidator {
org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID, execution.getLookupMap().get(ResourceKey.CONFIGURATION_ID));
orchestrationStatus = configuration.getOrchestrationStatus();
break;
+ case INSTANCE_GROUP:
+ org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID, execution.getLookupMap().get(ResourceKey.INSTANCE_GROUP_ID));
+ orchestrationStatus = instanceGroup.getOrchestrationStatus();
+ break;
case NO_VALIDATE:
//short circuit and exit method
execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.VALIDATION_SKIPPED);
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 8a3a778b06..d87b11a1a6 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
@@ -108,7 +108,7 @@ public class WorkflowAction {
private static final String ASSIGNINSTANCE = "assignInstance";
private static final String CREATEINSTANCE = "createInstance";
private static final String USERPARAMSERVICE = "service";
- private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances";
+ private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups";
private static final String HOMINGSOLUTION = "Homing_Solution";
private static final String FABRIC_CONFIGURATION = "FabricConfiguration";
private static final String G_SERVICE_TYPE = "serviceType";
@@ -202,17 +202,25 @@ public class WorkflowAction {
orchFlows = filterOrchFlows(sIRequest, orchFlows, resourceType, execution);
String key = "";
ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo();
- if(modelInfo.getModelType().equals(ModelType.service)) {
- key = modelInfo.getModelVersionId();
- } else {
- key = modelInfo.getModelCustomizationId();
+ if(modelInfo != null) {
+ if(modelInfo.getModelType().equals(ModelType.service)) {
+ key = modelInfo.getModelVersionId();
+ } else {
+ key = modelInfo.getModelCustomizationId();
+ }
}
+ boolean isConfiguration = isConfiguration(orchFlows);
Resource resourceKey = new Resource(resourceType, key, aLaCarte);
+ List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks(sIRequest, orchFlows, requestId, resourceKey, apiVersion, resourceId, requestAction, aLaCarte, vnfType,
+ workflowResourceIds, requestDetails, isConfiguration);
for (OrchestrationFlow orchFlow : orchFlows) {
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false);
- flowsToExecute.add(ebb);
+ if(!orchFlow.getFlowName().contains("Configuration")) {
+ ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
+ requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false);
+ flowsToExecute.add(ebb);
+ }
}
+ flowsToExecute.addAll(configBuildingBlocks);
} else {
boolean foundRelated = false;
boolean containsService = false;
@@ -339,6 +347,53 @@ public class WorkflowAction {
buildAndThrowException(execution, "Exception in create execution list " + ex.getMessage(), ex);
}
}
+
+ protected boolean isConfiguration(List<OrchestrationFlow> orchFlows) {
+ for(OrchestrationFlow flow : orchFlows) {
+ if(flow.getFlowName().contains("Configuration")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ServiceInstancesRequest sIRequest, List<OrchestrationFlow> orchFlows, String requestId, Resource resourceKey,
+ String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType,
+ WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean isConfiguration) {
+ List<OrchestrationFlow> result = new ArrayList<>(orchFlows);
+ result = orchFlows.stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
+ String vnfCustomizationUUID = "";
+ String vfModuleCustomizationUUID = sIRequest.getRequestDetails().getModelInfo().getModelCustomizationUuid();
+ RelatedInstanceList[] relatedInstanceList = sIRequest.getRequestDetails().getRelatedInstanceList();
+ if (relatedInstanceList != null) {
+ for (RelatedInstanceList relatedInstList : relatedInstanceList) {
+ RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
+ if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
+ vnfCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationUuid();
+ }
+ }
+ }
+
+ List<VnfVfmoduleCvnfcConfigurationCustomization> fabricCustomizations = traverseCatalogDbForConfiguration(vnfCustomizationUUID, vfModuleCustomizationUUID);
+ List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>();
+ for(VnfVfmoduleCvnfcConfigurationCustomization fabricConfig : fabricCustomizations) {
+
+ if (requestAction.equals(CREATEINSTANCE)) {
+ workflowResourceIds.setConfigurationId(UUID.randomUUID().toString());
+ } else {
+ //TODO AAI lookup for configuration update/delete
+ }
+ for(OrchestrationFlow orchFlow : result) {
+ resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID);
+ resourceKey.setCvnfModuleCustomizationId(fabricConfig.getCvnfcCustomization().getModelCustomizationUUID());
+ resourceKey.setVnfCustomizationId(vnfCustomizationUUID);
+ ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
+ requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true);
+ flowsToExecuteConfigs.add(ebb);
+ }
+ }
+ return flowsToExecuteConfigs;
+ }
protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
int count = 0;
@@ -698,9 +753,9 @@ public class WorkflowAction {
vfModuleCustomizationUUID = vfModule.getModelInfo().getModelCustomizationUuid();
}
if(!vnfCustomizationUUID.equals("")&&!vfModuleCustomizationUUID.equals("")){
- List<String> configs = traverseCatalogDbForConfiguration(vnfCustomizationUUID,vfModuleCustomizationUUID);
- for(String config : configs){
- Resource configResource = new Resource(WorkflowType.CONFIGURATION,config,false);
+ List<VnfVfmoduleCvnfcConfigurationCustomization> configs = traverseCatalogDbForConfiguration(vnfCustomizationUUID,vfModuleCustomizationUUID);
+ for(VnfVfmoduleCvnfcConfigurationCustomization config : configs){
+ Resource configResource = new Resource(WorkflowType.CONFIGURATION,config.getConfigurationResource().getModelUUID(),false);
resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId());
resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId());
resourceCounter.add(configResource);
@@ -734,20 +789,19 @@ public class WorkflowAction {
}
return foundRelated;
}
-
- protected List<String> traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) {
- List<String> configurations = new ArrayList<>();
+ protected List<VnfVfmoduleCvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) {
+ List<VnfVfmoduleCvnfcConfigurationCustomization> configurations = new ArrayList<>();
try{
List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(vnfCustomizationUUID, vfModuleCustomizationUUID);
for(CvnfcCustomization cvnfc : cvnfcCustomizations){
for(VnfVfmoduleCvnfcConfigurationCustomization customization : cvnfc.getVnfVfmoduleCvnfcConfigurationCustomization()){
if(customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)){
- configurations.add(customization.getConfigurationResource().getModelUUID());
+ configurations.add(customization);
}
}
}
- logger.debug("found {} configurations" , configurations.size() );
+ logger.debug("found {} configuration(s)" , configurations.size() );
return configurations;
} catch (Exception ex){
logger.error("Error in finding configurations", ex);
@@ -774,6 +828,7 @@ public class WorkflowAction {
workflowResourceIds.setVfModuleId((String) execution.getVariable("vfModuleId"));
workflowResourceIds.setVnfId((String) execution.getVariable("vnfId"));
workflowResourceIds.setVolumeGroupId((String) execution.getVariable("volumeGroupId"));
+ workflowResourceIds.setInstanceGroupId((String) execution.getVariable("instanceGroupId"));
return workflowResourceIds;
}
@@ -1048,7 +1103,7 @@ public class WorkflowAction {
executeBuildingBlock.setRequestId(requestId);
executeBuildingBlock.setBuildingBlock(buildingBlock);
executeBuildingBlock.setRequestDetails(requestDetails);
- if(isConfiguration){
+ if(resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))){
ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
if (resource != null){
configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
@@ -1120,7 +1175,7 @@ public class WorkflowAction {
}
if (resourceType.equals(WorkflowType.VFMODULE)) {
- List<String> fabricCustomizations = traverseCatalogDbForConfiguration(vnfCustomizationUUID, vfModuleCustomizationUUID);
+ List<VnfVfmoduleCvnfcConfigurationCustomization> fabricCustomizations = traverseCatalogDbForConfiguration(vnfCustomizationUUID, vfModuleCustomizationUUID);
if (fabricCustomizations.isEmpty()) {
result = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
}
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 2e91a52f65..33a89e0b82 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
@@ -161,6 +161,7 @@ public class WorkflowActionBBTasks {
WorkflowContextHolder.getInstance().processCallback(processKey, execution.getProcessInstanceId(), requestId,
callbackResponse);
logger.info("Successfully sent sync ack.");
+ updateInstanceId(execution);
}
public void sendErrorSyncAck(DelegateExecution execution) {
@@ -303,100 +304,31 @@ public class WorkflowActionBBTasks {
workflowAction.buildAndThrowException(execution, "Rollback has already been called. Cannot rollback a request that is currently in the rollback state.");
}
}
-
- protected void updateRequestErrorStatusMessage(DelegateExecution execution) {
- try {
- String requestId = (String) execution.getVariable(G_REQUEST_ID);
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- String errorMsg = retrieveErrorMessage(execution);
- if(errorMsg == null || errorMsg.equals("")){
- errorMsg = "Failed to determine error message";
- }
- request.setStatusMessage(errorMsg);
- logger.debug("Updating RequestDB to failed: errorMsg = " + errorMsg);
- requestDbclient.updateInfraActiveRequests(request);
- } catch (Exception e) {
- logger.error("Failed to update Request db with the status message after retry or rollback has been initialized.",e);
- }
- }
-
- public void abortCallErrorHandling(DelegateExecution execution) {
- String msg = "Flow has failed. Rainy day handler has decided to abort the process.";
- logger.error(msg);
- throw new BpmnError(msg);
- }
- public void updateRequestStatusToFailed(DelegateExecution execution) {
- try {
+ protected void updateInstanceId(DelegateExecution execution){
+ try{
String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ String resourceId = (String) execution.getVariable("resourceId");
+ WorkflowType resourceType = (WorkflowType) execution.getVariable("resourceType");
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- String errorMsg = null;
- String rollbackErrorMsg = null;
- boolean rollbackCompleted = (boolean) execution.getVariable("isRollbackComplete");
- boolean isRollbackFailure = (boolean) execution.getVariable("isRollback");
- ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
-
- if(rollbackCompleted){
- rollbackErrorMsg = "Rollback has been completed successfully.";
- request.setRollbackStatusMessage(rollbackErrorMsg);
- logger.debug("Updating RequestDB to failed: Rollback has been completed successfully");
- }else{
- if(isRollbackFailure){
- rollbackErrorMsg = retrieveErrorMessage(execution);
- if(rollbackErrorMsg == null || rollbackErrorMsg.equals("")){
- rollbackErrorMsg = "Failed to determine rollback error message.";
- }
- request.setRollbackStatusMessage(rollbackErrorMsg);
- logger.debug("Updating RequestDB to failed: rollbackErrorMsg = " + rollbackErrorMsg);
- }else{
- errorMsg = retrieveErrorMessage(execution);
- if(errorMsg == null || errorMsg.equals("")){
- errorMsg = "Failed to determine error message";
- }
- request.setStatusMessage(errorMsg);
- logger.debug("Updating RequestDB to failed: errorMsg = " + errorMsg);
- }
- }
- if(ebb!=null && ebb.getBuildingBlock()!=null){
- String flowStatus = ebb.getBuildingBlock().getBpmnFlowName() + " has failed.";
- request.setFlowStatus(flowStatus);
- execution.setVariable("flowStatus", flowStatus);
+ if(resourceType == WorkflowType.SERVICE){
+ request.setServiceInstanceId(resourceId);
+ }else if(resourceType == WorkflowType.VNF){
+ request.setVnfId(resourceId);
+ }else if(resourceType == WorkflowType.VFMODULE){
+ request.setVfModuleId(resourceId);
+ }else if(resourceType == WorkflowType.VOLUMEGROUP){
+ request.setVolumeGroupId(resourceId);
+ }else if(resourceType == WorkflowType.NETWORK){
+ request.setNetworkId(resourceId);
+ }else if(resourceType == WorkflowType.CONFIGURATION){
+ request.setConfigurationId(resourceId);
+ }else if(resourceType == WorkflowType.INSTANCE_GROUP){
+ request.setInstanceGroupId(resourceId);
}
-
- request.setProgress(Long.valueOf(100));
- request.setRequestStatus("FAILED");
- request.setLastModifiedBy("CamundaBPMN");
requestDbclient.updateInfraActiveRequests(request);
- } catch (Exception e) {
- workflowAction.buildAndThrowException(execution, "Error Updating Request Database", e);
+ }catch(Exception ex){
+ workflowAction.buildAndThrowException(execution, "Failed to update Request db with instanceId");
}
}
-
- private String retrieveErrorMessage (DelegateExecution execution){
- String errorMsg = "";
- try {
- WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
- if(exception != null && (exception.getErrorMessage()!=null || !exception.getErrorMessage().equals(""))){
- errorMsg = exception.getErrorMessage();
- }
- } catch (Exception ex) {
- //log error and attempt to extact WorkflowExceptionMessage
- logger.error("Failed to extract workflow exception from execution.",ex);
- }
-
- if (errorMsg == null || errorMsg.equals("")){
- try {
- errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage");
- } catch (Exception ex) {
- logger.error("Failed to extract workflow exception message from WorkflowException",ex);
- errorMsg = "Unexpected Error in BPMN.";
- }
- }
- return errorMsg;
- }
-
- public void updateRequestStatusToFailedWithRollback(DelegateExecution execution) {
- execution.setVariable("isRollbackComplete", true);
- updateRequestStatusToFailed(execution);
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java
index ff5ba152b9..304b4000bd 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java
@@ -29,7 +29,8 @@ public enum WorkflowType {
NETWORK("Network"),
VIRTUAL_LINK("VirtualLink"),
NETWORKCOLLECTION("NetworkCollection"),
- CONFIGURATION("Configuration");
+ CONFIGURATION("Configuration"),
+ INSTANCE_GROUP("InstanceGroup");
private final String type;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java
index 68f6e8ffa2..c325dd75ee 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java
@@ -25,6 +25,7 @@ import java.util.Optional;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
@@ -68,5 +69,12 @@ public class AAIInstanceGroupResources {
AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
return injectionHelper.getAaiClient().exists(instanceGroupUri);
}
-
+
+ public void createInstanceGroupandConnectServiceInstance(InstanceGroup instanceGroup, ServiceInstance serviceInstance) {
+ AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
+ AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ serviceInstance.getServiceInstanceId());
+ injectionHelper.getAaiClient().createIfNotExists(instanceGroupUri, Optional.of(aaiInstanceGroup)).connect(instanceGroupUri, serviceInstanceURI);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
index 7715de9672..6dc0b1861d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
@@ -24,6 +24,7 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.common.data.TestDataSetup;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.AssignNetworkBBUtils;
import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionExtractResourcesAAI;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
index d8c7ebaff7..166319d32b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
@@ -382,7 +382,24 @@ public class TestDataSetup{
}
collection.setInstanceGroup(instanceGroup);
+
+ return instanceGroup;
+ }
+
+ public InstanceGroup setInstanceGroupVnf() {
+ InstanceGroup instanceGroup = buildInstanceGroup();
+
+ ServiceInstance serviceInstance = null;
+
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
+ } catch(BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
+
+ serviceInstance.getInstanceGroups().add(instanceGroup);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroup.getId());
return instanceGroup;
}
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 c48019af83..4e147a022c 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
@@ -49,6 +49,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
@@ -75,6 +76,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
private VfModule vfModule;
private Customer customer;
private Configuration configuration;
+ private InstanceGroup instanceGroup;
@Captor
ArgumentCaptor<NetworkPolicy> networkPolicyCaptor;
@@ -92,6 +94,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
cloudRegion = setCloudRegion();
vfModule = setVfModule();
configuration = setConfiguration();
+ instanceGroup = setInstanceGroupVnf();
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
@@ -99,6 +102,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID), any())).thenReturn(configuration);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID), any())).thenReturn(instanceGroup);
doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
@@ -467,6 +471,21 @@ public class AAICreateTasksTest extends BaseTaskTest{
aaiCreateTasks.connectVnfToTenant(execution);
verify(aaiVnfResources, times(1)).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
}
+
+ @Test
+ public void createInstanceGroupVnfTest() throws Exception {
+ doNothing().when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
+ aaiCreateTasks.createInstanceGroupVnf(execution);
+ verify(aaiInstanceGroupResources, times(1)).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
+ }
+
+ @Test
+ public void createInstanceGroupVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
+ aaiCreateTasks.createInstanceGroupVnf(execution);
+ }
+
@Test
public void createNetworkPolicyNeedToCreateAllTest() throws Exception {
execution.setVariable("heatStackId", "testHeatStackId");
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
index 4984b2fbb5..94d886cdb5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
@@ -48,6 +48,7 @@ import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
@@ -71,6 +72,7 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
private VolumeGroup volumeGroup;
private CloudRegion cloudRegion;
private Configuration configuration;
+ private InstanceGroup instanceGroup;
@Captor
ArgumentCaptor<String> stringCaptor;
@@ -84,6 +86,7 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
volumeGroup = setVolumeGroup();
cloudRegion = setCloudRegion();
configuration = setConfiguration();
+ instanceGroup = setInstanceGroupVnf();
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
@@ -91,6 +94,7 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID), any())).thenReturn(configuration);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID), any())).thenReturn(instanceGroup);
doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
@@ -194,6 +198,13 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
}
@Test
+ public void deleteInstanceGroupVnfTest() throws Exception {
+ doNothing().when(aaiInstanceGroupResources).deleteInstanceGroup(instanceGroup);
+ aaiDeleteTasks.deleteInstanceGroupVnf(execution);
+ verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(instanceGroup);
+ }
+
+ @Test
public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception {
execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456");
final String content0 = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete0.json")));
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 17a37c873a..c2bca34fb6 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
@@ -137,26 +137,6 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
}
@Test
- public void updateRequestStatusToFailedFlowStatusTest() {
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- execution.setVariable("isRollbackComplete", false);
- execution.setVariable("isRollback", false);
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- BuildingBlock buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName("CreateNetworkBB");
- ebb.setBuildingBlock(buildingBlock);
- execution.setVariable("buildingBlock", ebb);
- WorkflowException wfe = new WorkflowException("failure", 1, "failure");
- execution.setVariable("WorkflowException", wfe);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBTasks.updateRequestStatusToFailed(execution);
- assertEquals("CreateNetworkBB has failed.",execution.getVariable("flowStatus"));
- }
-
- @Test
public void rollbackExecutionPathTest(){
execution.setVariable("handlingCode", "Rollback");
execution.setVariable("isRollback", false);
@@ -337,4 +317,17 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
workflowActionBBTasks.checkRetryStatus(execution);
assertEquals(0,execution.getVariable("retryCount"));
}
+
+ @Test
+ public void updateInstanceId(){
+ String reqId = "req123";
+ String instanceId = "123123123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("resourceId", instanceId);
+ execution.setVariable("resourceType", WorkflowType.SERVICE);
+ doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBTasks.updateInstanceId(execution);
+ Mockito.verify( reqMock, Mockito.times(1)).setServiceInstanceId(instanceId);
+ }
}
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 93d4b413f8..8c0792e628 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
@@ -902,16 +902,32 @@ public class WorkflowActionTest extends BaseTaskTest {
ConfigurationResource configurationResource = new ConfigurationResource();
configurationResource.setToscaNodeType("FabricConfiguration");
vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
+ vnfVfmoduleCvnfcConfigurationCustomization.setModelInstanceName("modelInstanceName1");
+ vnfVfmoduleCvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
Set<VnfVfmoduleCvnfcConfigurationCustomization> custSet = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
custSet.add(vnfVfmoduleCvnfcConfigurationCustomization);
cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(custSet);
+ cvnfcCustomization.setDescription("description");
cvnfcCustomizations.add(cvnfcCustomization);
+ CvnfcCustomization cvnfcCustomization2 = new CvnfcCustomization();
+ VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization2 = new VnfVfmoduleCvnfcConfigurationCustomization();
+ ConfigurationResource configurationResource2 = new ConfigurationResource();
+ configurationResource2.setToscaNodeType("FabricConfiguration");
+ vnfVfmoduleCvnfcConfigurationCustomization2.setConfigurationResource(configurationResource2);
+ vnfVfmoduleCvnfcConfigurationCustomization2.setModelInstanceName("modelInstanceName2");
+ vnfVfmoduleCvnfcConfigurationCustomization2.setCvnfcCustomization(cvnfcCustomization2);
+ Set<VnfVfmoduleCvnfcConfigurationCustomization> custSet2 = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
+ custSet2.add(vnfVfmoduleCvnfcConfigurationCustomization2);
+ cvnfcCustomization2.setVnfVfmoduleCvnfcConfigurationCustomization(custSet2);
+ cvnfcCustomization2.setDescription("description2");
+ cvnfcCustomizations.add(cvnfcCustomization2);
+
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("fc25201d-36d6-43a3-8d39-fdae88e526ae", "9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(cvnfcCustomizations);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
+ assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB", "AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
}
/**
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
index 2dd4033aa2..8195cd58c0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
@@ -144,9 +144,9 @@ public class WorkflowActionUnitTest {
when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(any(String.class), any(String.class)))
.thenReturn(cvnfcCustomizations);
- List<String> results = workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId");
+ List<VnfVfmoduleCvnfcConfigurationCustomization> results = workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId");
- assertThat(results, is(Arrays.asList("my-uuid")));
+ assertThat(results, is(Arrays.asList(vfModuleCustomization)));
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
index 10bbf39823..58bcc8b1aa 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
@@ -21,7 +21,10 @@
package org.onap.so.client.orchestration;
import static org.mockito.ArgumentMatchers.eq;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -38,11 +41,14 @@ import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.AAIEdgeLabel;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
+import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
public class AAIInstanceGroupResourcesTest extends TestDataSetup{
@@ -51,6 +57,7 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup{
private InstanceGroup instanceGroup;
private GenericVnf vnf;
+ private ServiceInstance serviceInstance;
@Mock
protected AAIResourcesClient MOCK_aaiResourcesClient;
@@ -65,6 +72,7 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup{
public void before() {
instanceGroup = buildInstanceGroup();
vnf = buildGenericVnf();
+ serviceInstance = buildServiceInstance();
doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
}
@@ -99,4 +107,17 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup{
verify(MOCK_aaiResourcesClient, times(1)).exists(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
}
+ @Test
+ public void createInstanceGroupandConnectServiceInstanceTest() {
+ doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper).mapInstanceGroup(instanceGroup);
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+
+ aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
+
+ verify(MOCK_aaiObjectMapper, times(1)).mapInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java
index 24fb0e0d20..1dece5c341 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java
@@ -80,6 +80,7 @@ public final class CommonConstants {
public static final String X_PATCH_VERSION = "X-PatchVersion";
public static final String X_LATEST_VERSION = "X-LatestVersion";
public static final String INSTANCE_GROUP_ID = "instanceGroupId";
+ public static final String INSTANCE_GROUP_INSTANCE_ID = "instanceGroupInstanceId";
private CommonConstants () {
// prevent creating an instance of this class
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 0b2b1e73b4..2dab494b07 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -657,7 +657,7 @@ public class ServiceInstances {
public Response deleteInstanceGroups(@PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
String requestId = getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put(CommonConstants.INSTANCE_GROUP_ID, instanceGroupId);
+ instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId);
return deleteInstanceGroups(Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext), requestContext);
}
@@ -670,7 +670,7 @@ public class ServiceInstances {
public Response addInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
String requestId = getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put(CommonConstants.INSTANCE_GROUP_ID, instanceGroupId);
+ instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId);
return serviceInstances(request, Action.addMembers, instanceIdMap, version, requestId, getRequestUri(requestContext));
}
@@ -683,7 +683,7 @@ public class ServiceInstances {
public Response removeInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
String requestId = getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put(CommonConstants.INSTANCE_GROUP_ID, instanceGroupId);
+ instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId);
return serviceInstances(request, Action.removeMembers, instanceIdMap, version, requestId, getRequestUri(requestContext));
}
@@ -808,16 +808,13 @@ public class ServiceInstances {
}
- serviceInstanceId = "";
+ serviceInstanceId = setServiceInstanceId(requestScope, sir);
String vnfId = "";
String vfModuleId = "";
String volumeGroupId = "";
String networkId = "";
String pnfCorrelationId = "";
String instanceGroupId = null;
- if(sir.getServiceInstanceId () != null){
- serviceInstanceId = sir.getServiceInstanceId ();
- }
if(sir.getVnfInstanceId () != null){
vnfId = sir.getVnfInstanceId ();
@@ -884,7 +881,7 @@ public class ServiceInstances {
return postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
public Response deleteInstanceGroups(Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri, ContainerRequestContext requestContext) throws ApiException {
- String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_ID);
+ String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID);
Boolean aLaCarte = true;
long startTime = System.currentTimeMillis ();
String apiVersion = version.substring(1);
@@ -1117,8 +1114,8 @@ public class ServiceInstances {
if(instanceIdMap.get("configurationInstanceId") != null){
currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
}
- if(instanceIdMap.get("InstanceGroupInstanceId") != null){
- currentActiveReq.setInstanceGroupId(instanceIdMap.get("InstanceGroupInstanceId"));
+ if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null){
+ currentActiveReq.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID));
}
}
}
@@ -1970,4 +1967,20 @@ public class ServiceInstances {
}
return serviceType;
}
+ protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir){
+ if(sir.getServiceInstanceId () != null){
+ return sir.getServiceInstanceId ();
+ }else if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())){
+ RelatedInstanceList[] relatedInstances = sir.getRequestDetails().getRelatedInstanceList();
+ if(relatedInstances != null){
+ for(RelatedInstanceList relatedInstanceList : relatedInstances){
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ if(relatedInstance.getModelInfo().getModelType() == ModelType.service){
+ return relatedInstance.getInstanceId();
+ }
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
index f1985e9fcf..fad11a5cc6 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
@@ -77,11 +77,11 @@ public class InstanceIdMapValidation implements ValidationRule{
sir.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
}
- if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_ID) != null){
- if (!UUIDChecker.isValidUUID (instanceIdMap.get (CommonConstants.INSTANCE_GROUP_ID))) {
- throw new ValidationException (CommonConstants.INSTANCE_GROUP_ID, true);
+ if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null){
+ if (!UUIDChecker.isValidUUID (instanceIdMap.get (CommonConstants.INSTANCE_GROUP_INSTANCE_ID))) {
+ throw new ValidationException (CommonConstants.INSTANCE_GROUP_INSTANCE_ID, true);
}
- sir.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_ID));
+ sir.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID));
}
}
return info;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
index 145213fc6c..ee98accfdc 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
@@ -430,12 +430,12 @@ public class MsoRequestTest extends BaseTest {
@Test
public void instanceGroupIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
this.sir = mapper.readValue(inputStream("/SuccessfulValidation/InstanceIdHashMap.json"), ServiceInstancesRequest.class);
- this.instanceIdMapTest.put("instanceGroupId", "test");
+ this.instanceIdMapTest.put("instanceGroupInstanceId", "test");
this.action = Action.createInstance;
thrown.expect(ValidationException.class);
this.reqVersion = 7;
this.version = "v" + reqVersion;
- thrown.expectMessage("No valid instanceGroupId is specified");
+ thrown.expectMessage("No valid instanceGroupInstanceId is specified");
this.msoRequest = new MsoRequest();
this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index 83b5a49e8c..23974ef1fa 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -31,6 +31,7 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -79,8 +80,10 @@ import org.springframework.util.ResourceUtils;
import org.springframework.web.util.UriComponentsBuilder;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.http.Fault;
@@ -114,9 +117,12 @@ public class ServiceInstancesTest extends BaseTest{
// set headers
headers = new HttpHeaders();
headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
- headers.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
- headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
- try { // generate one-time port number to avoid RANDOM port number later.
+ headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(MsoLogger.CLIENT_ID, "VID");
+ headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
+ try { // generate one-time port number to avoid RANDOM port number later.
initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
initialPort = initialUrl.getPort();
} catch (MalformedURLException e) {
@@ -391,9 +397,10 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void activateServiceInstanceNoRecipeALaCarte() throws IOException{
+ TestAppender.events.clear();
uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
HttpHeaders requestIDheaders = new HttpHeaders();
- requestIDheaders.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST, requestIDheaders);
Service defaultService = new Service();
@@ -2368,7 +2375,8 @@ public class ServiceInstancesTest extends BaseTest{
if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging") &&
logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")){
Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ assertEquals("VID",mdc.get(MsoLogger.PARTNERNAME));
}
}
}
@@ -2425,6 +2433,7 @@ public class ServiceInstancesTest extends BaseTest{
public void deleteInstanceGroupNoPartnerNameHeader() throws IOException{
HttpHeaders noPartnerHeaders = new HttpHeaders();
noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
+ noPartnerHeaders.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
//then
@@ -2621,6 +2630,61 @@ public class ServiceInstancesTest extends BaseTest{
assertEquals(serviceType, "networkModelName");
}
@Test
+ public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException{
+ String requestScope = "instanceGroup";
+ ServiceInstancesRequest sir = mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
+ assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", servInstances.setServiceInstanceId(requestScope, sir));
+ }
+ @Test
+ public void setServiceInstanceIdTest(){
+ String requestScope = "vnf";
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f", servInstances.setServiceInstanceId(requestScope, sir));
+ }
+ @Test
+ public void setServiceInstanceIdReturnNullTest(){
+ String requestScope = "vnf";
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ assertNull(servInstances.setServiceInstanceId(requestScope, sir));
+ }
+ @Test
+ public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException{
+ stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
+ assertTrue(inProgress);
+ }
+ @Test
+ public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException{
+ stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
+ assertFalse(inProgress);
+ }
+ @Test
+ public void camundaHistoryCheckNotInProgressTest()throws ContactCamundaException, RequestDbFailureException{
+ stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/HistoryCheckResponseCompleted.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
+ assertFalse(inProgress);
+ }
+ @Test
public void setCamundaHeadersTest()throws ContactCamundaException, RequestDbFailureException{
String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
String key = "07a7159d3bf51a0e53be7a8f89699be7";
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationAction.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationAction.java
index d831d1ebd2..1fd254f254 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationAction.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationAction.java
@@ -30,6 +30,8 @@ public enum OrchestrationAction {
CREATE("Create"),
DELETE("Delete"),
UPDATE("Update"),
+ ADD_MEMBERS("AddMembers"),
+ REMOVE_MEMBERS("RemoveMembers"),
CUSTOM("Custom");
private final String name;
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java
index 64eff56f97..6d5c0fd9a8 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java
@@ -28,6 +28,7 @@ public enum ResourceType {
NETWORK("Network"),
NETWORK_COLLECTION("NetworkCollection"),
CONFIGURATION("Configuration"),
+ INSTANCE_GROUP("InstanceGroup"),
NO_VALIDATE("NoValidate");
private final String name;
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomization.java
index f5e9b5f560..7ce657c5c7 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomization.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomization.java
@@ -213,6 +213,7 @@ public class VnfVfmoduleCvnfcConfigurationCustomization implements Serializable
this.configurationResource = configurationResource;
}
+ @LinkedResource
public CvnfcCustomization getCvnfcCustomization() {
return cvnfcCustomization;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index b79ffedf83..9b888cb2ed 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -53,6 +53,7 @@ import org.onap.so.db.catalog.beans.VnfComponentsRecipe;
import org.onap.so.db.catalog.beans.VnfRecipe;
import org.onap.so.db.catalog.beans.VnfResource;
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.catalog.beans.macro.NorthBoundRequest;
import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
@@ -231,6 +232,8 @@ public class CatalogDbClient {
private final Client<ControllerSelectionReference> controllerSelectionReferenceClient;
+ private final Client<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizationClient;
+
private final Client<PnfResource> pnfResourceClient;
private final Client<PnfResourceCustomization> pnfResourceCustomizationClient;
@@ -359,6 +362,7 @@ public class CatalogDbClient {
cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class);
controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class);
externalServiceToInternalServiceClient = clientFactory.create(ExternalServiceToInternalService.class);
+ vnfVfmoduleCvnfcConfigurationCustomizationClient = clientFactory.create(VnfVfmoduleCvnfcConfigurationCustomization.class);
pnfResourceClient = clientFactory.create(PnfResource.class);
pnfResourceCustomizationClient = clientFactory.create(PnfResourceCustomization.class);
}
@@ -408,6 +412,7 @@ public class CatalogDbClient {
cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class);
controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class);
externalServiceToInternalServiceClient = clientFactory.create(ExternalServiceToInternalService.class);
+ vnfVfmoduleCvnfcConfigurationCustomizationClient = clientFactory.create(VnfVfmoduleCvnfcConfigurationCustomization.class);
pnfResourceClient = clientFactory.create(PnfResource.class);
pnfResourceCustomizationClient = clientFactory.create(PnfResourceCustomization.class);
}
@@ -784,4 +789,12 @@ public class CatalogDbClient {
.queryParam("VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID", vfModuleCustomizationUUID).build().toString()));
}
+ public VnfVfmoduleCvnfcConfigurationCustomization getVnfVfmoduleCvnfcConfigurationCustomizationByVnfCustomizationUuidAndVfModuleCustomizationUuidAndCvnfcCustomizationUuid(String vnfCustomizationUuid,
+ String vfModuleCustomizationUuid, String cvnfcCustomizationUuid) {
+ return this.getSingleResource(vnfVfmoduleCvnfcConfigurationCustomizationClient, getUri(UriBuilder
+ .fromUri(endpoint + "/vnfVfmoduleCvnfcConfigurationCustomization/search/findOneByVnfResourceCustomizationAndVfModuleCustomizationAndCvnfcCustomization")
+ .queryParam("VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID", vnfCustomizationUuid)
+ .queryParam("VF_MODULE_MODEL_CUSTOMIZATION_UUID", vfModuleCustomizationUuid)
+ .queryParam("CVNFC_MODEL_CUSTOMIZATION_UUID", cvnfcCustomizationUuid).build().toString()));
+ }
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepository.java
index f936933485..aad75a15be 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepository.java
@@ -24,9 +24,17 @@ import java.util.List;
import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "vnfVfmoduleCvnfcConfigurationCustomization", path = "vnfVfmoduleCvnfcConfigurationCustomization")
public interface VnfVfmoduleCvnfcConfigurationCustomizationRepository extends JpaRepository<VnfVfmoduleCvnfcConfigurationCustomization, Integer> {
List<VnfVfmoduleCvnfcConfigurationCustomization> findByModelCustomizationUUID(String modelCustomizationUUID);
+
+ @Query(value = "SELECT * FROM vnf_vfmodule_cvnfc_configuration_customization WHERE VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID = ?1 AND VF_MODULE_MODEL_CUSTOMIZATION_UUID = ?2 AND CVNFC_MODEL_CUSTOMIZATION_UUID = ?3", nativeQuery = true)
+ VnfVfmoduleCvnfcConfigurationCustomization findOneByVnfResourceCustomizationAndVfModuleCustomizationAndCvnfcCustomization (
+ @Param("VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID") String vnfResourceCustomizationUuid,
+ @Param("VF_MODULE_MODEL_CUSTOMIZATION_UUID") String vfModuleCustomizationUuid,
+ @Param("CVNFC_MODEL_CUSTOMIZATION_UUID") String cvnfcCustomizationUuid);
} \ No newline at end of file
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest.java
index 6f0e3020b1..a953fc8a3c 100644
--- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest.java
@@ -81,7 +81,7 @@ public class VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest extends Ba
vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization();
- cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459");
+ cvnfcCustomization.setModelCustomizationUUID("0c3a8b76-3f5b-11e9-b210-d663bd873d93");
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459");
@@ -122,5 +122,12 @@ public class VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest extends Ba
if(foundVnfVfmoduleCvnfcConfigurationCustomization == null)
fail("should not be null");
+
+ VnfVfmoduleCvnfcConfigurationCustomization foundOneVnfVfmoduleCvnfcConfigurationCustomization =
+ vnfVfmoduleCvnfcConfigurationCustomizationRepository.findOneByVnfResourceCustomizationAndVfModuleCustomizationAndCvnfcCustomization("cf9f6efc-9f14-11e8-98d0-529269fb1459", "cf9f6efc-9f14-11e8-98d0-529269fb1459", "0c3a8b76-3f5b-11e9-b210-d663bd873d93");
+
+ if(foundOneVnfVfmoduleCvnfcConfigurationCustomization == null)
+ fail("should not be null");
+ Assert.assertTrue(foundOneVnfVfmoduleCvnfcConfigurationCustomization.getConfigurationFunction().equalsIgnoreCase("testConfigurationFunction"));
}
-}
+} \ No newline at end of file