aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java134
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java20
2 files changed, 83 insertions, 71 deletions
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 bfa77212c4..fcc8484385 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
@@ -1699,20 +1699,8 @@ public class BBInputSetup implements JavaDelegate {
&& bbName.equalsIgnoreCase(AssignFlows.SERVICE_INSTANCE.toString())) {
throw new Exception("Request invalid missing: RequestInfo:InstanceName");
} else {
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = null;
- if (aLaCarte && bbName.equalsIgnoreCase(AssignFlows.SERVICE_INSTANCE.toString())) {
- serviceInstanceAAI = bbInputSetupUtils
- .getAAIServiceInstanceByName(requestDetails.getRequestInfo().getInstanceName(), customer);
- }
- if (serviceInstanceId != null && serviceInstanceAAI == null) {
- if (customer != null && customer.getServiceSubscription() != null) {
- serviceInstanceAAI =
- bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(customer.getGlobalCustomerId(),
- customer.getServiceSubscription().getServiceType(), serviceInstanceId);
- } else {
- serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
- }
- }
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI;
+ serviceInstanceAAI = getServiceInstanceAAI(requestDetails, customer, serviceInstanceId, aLaCarte, bbName);
if (serviceInstanceAAI != null) {
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);
return this.getExistingServiceInstance(serviceInstanceAAI);
@@ -1722,6 +1710,25 @@ public class BBInputSetup implements JavaDelegate {
}
}
+ private org.onap.aai.domain.yang.ServiceInstance getServiceInstanceAAI(RequestDetails requestDetails,
+ Customer customer, String serviceInstanceId, boolean aLaCarte, String bbName) throws Exception {
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = null;
+ if (aLaCarte && bbName.equalsIgnoreCase(AssignFlows.SERVICE_INSTANCE.toString())) {
+ serviceInstanceAAI = bbInputSetupUtils
+ .getAAIServiceInstanceByName(requestDetails.getRequestInfo().getInstanceName(), customer);
+ }
+ if (serviceInstanceId != null && serviceInstanceAAI == null) {
+ if (customer != null && customer.getServiceSubscription() != null) {
+ serviceInstanceAAI =
+ bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(customer.getGlobalCustomerId(),
+ customer.getServiceSubscription().getServiceType(), serviceInstanceId);
+ } else {
+ serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
+ }
+ }
+ return serviceInstanceAAI;
+ }
+
protected ServiceInstance createServiceInstance(RequestDetails requestDetails, Project project,
OwningEntity owningEntity, Map<ResourceKey, String> lookupKeyMap, String serviceInstanceId) {
ServiceInstance serviceInstance = new ServiceInstance();
@@ -1833,13 +1840,12 @@ public class BBInputSetup implements JavaDelegate {
AAIResultWrapper serviceInstanceWrapper = new AAIResultWrapper(
new AAICommonObjectMapperProvider().getMapper().writeValueAsString(serviceInstanceAAI));
Optional<Relationships> relationshipsOp = serviceInstanceWrapper.getRelationships();
- Relationships relationships = null;
if (relationshipsOp.isPresent()) {
- relationships = relationshipsOp.get();
- } else {
- return;
+ mapRelationship(serviceInstance, relationshipsOp.get());
}
+ }
+ private void mapRelationship(ServiceInstance serviceInstance, Relationships relationships) {
this.mapProject(relationships.getByType(AAIObjectType.PROJECT), serviceInstance);
this.mapOwningEntity(relationships.getByType(AAIObjectType.OWNING_ENTITY), serviceInstance);
this.mapL3Networks(relationships.getRelatedAAIUris(AAIObjectType.L3_NETWORK), serviceInstance.getNetworks());
@@ -1945,14 +1951,10 @@ public class BBInputSetup implements JavaDelegate {
AAIResultWrapper lineOfBusinessWrapper = lineOfBusinesses.get(0);
Optional<org.onap.aai.domain.yang.LineOfBusiness> aaiLineOfBusinessOp =
lineOfBusinessWrapper.asBean(org.onap.aai.domain.yang.LineOfBusiness.class);
- org.onap.aai.domain.yang.LineOfBusiness aaiLineOfBusiness = null;
- if (!aaiLineOfBusinessOp.isPresent()) {
- return;
+ if (aaiLineOfBusinessOp.isPresent()) {
+ LineOfBusiness lineOfBusiness = this.mapperLayer.mapAAILineOfBusiness(aaiLineOfBusinessOp.get());
+ genericVnf.setLineOfBusiness(lineOfBusiness);
}
- aaiLineOfBusiness = aaiLineOfBusinessOp.get();
-
- LineOfBusiness lineOfBusiness = this.mapperLayer.mapAAILineOfBusiness(aaiLineOfBusiness);
- genericVnf.setLineOfBusiness(lineOfBusiness);
}
}
@@ -1961,14 +1963,10 @@ public class BBInputSetup implements JavaDelegate {
AAIResultWrapper platformWrapper = platforms.get(0);
Optional<org.onap.aai.domain.yang.Platform> aaiPlatformOp =
platformWrapper.asBean(org.onap.aai.domain.yang.Platform.class);
- org.onap.aai.domain.yang.Platform aaiPlatform = null;
- if (!aaiPlatformOp.isPresent()) {
- return;
+ if (aaiPlatformOp.isPresent()) {
+ Platform platform = this.mapperLayer.mapAAIPlatform(aaiPlatformOp.get());
+ genericVnf.setPlatform(platform);
}
- aaiPlatform = aaiPlatformOp.get();
-
- Platform platform = this.mapperLayer.mapAAIPlatform(aaiPlatform);
- genericVnf.setPlatform(platform);
}
}
@@ -1977,34 +1975,36 @@ public class BBInputSetup implements JavaDelegate {
AAIResultWrapper collectionWrapper = collections.get(0);
Optional<org.onap.aai.domain.yang.Collection> aaiCollectionOp =
collectionWrapper.asBean(org.onap.aai.domain.yang.Collection.class);
- org.onap.aai.domain.yang.Collection aaiCollection = null;
- if (!aaiCollectionOp.isPresent()) {
- return;
- }
- aaiCollection = aaiCollectionOp.get();
-
- Collection collection = this.mapperLayer.mapAAICollectionIntoCollection(aaiCollection);
- NetworkCollectionResourceCustomization collectionResourceCust = bbInputSetupUtils
- .getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId());
- collection.setModelInfoCollection(mapperLayer.mapCatalogCollectionToCollection(collectionResourceCust,
- collectionResourceCust.getCollectionResource()));
- Optional<Relationships> relationshipsOp = collectionWrapper.getRelationships();
- Relationships relationships = null;
- if (relationshipsOp.isPresent()) {
- relationships = relationshipsOp.get();
- } else {
- serviceInstance.setCollection(collection);
- return;
- }
- List<InstanceGroup> instanceGroupsList =
- mapInstanceGroups(relationships.getByType(AAIObjectType.INSTANCE_GROUP));
- if (!instanceGroupsList.isEmpty()) {
- collection.setInstanceGroup(instanceGroupsList.get(0));
- }
- serviceInstance.setCollection(collection);
+ aaiCollectionOp.ifPresent(
+ collection -> serviceInstanceSetCollection(serviceInstance, collectionWrapper, collection));
}
}
+ private void serviceInstanceSetCollection(ServiceInstance serviceInstance, AAIResultWrapper collectionWrapper,
+ org.onap.aai.domain.yang.Collection aaiCollection) {
+ Collection collection = getCollection(aaiCollection);
+ Optional<Relationships> relationshipsOp = collectionWrapper.getRelationships();
+ relationshipsOp.ifPresent(relationships -> setInstanceGroupForCollection(collection, relationships));
+ serviceInstance.setCollection(collection);
+ }
+
+ private void setInstanceGroupForCollection(Collection collection, Relationships relationships) {
+ List<InstanceGroup> instanceGroupsList =
+ mapInstanceGroups(relationships.getByType(AAIObjectType.INSTANCE_GROUP));
+ if (!instanceGroupsList.isEmpty()) {
+ collection.setInstanceGroup(instanceGroupsList.get(0));
+ }
+ }
+
+ private Collection getCollection(org.onap.aai.domain.yang.Collection aaiCollection) {
+ Collection collection = this.mapperLayer.mapAAICollectionIntoCollection(aaiCollection);
+ NetworkCollectionResourceCustomization collectionResourceCust = bbInputSetupUtils
+ .getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId());
+ collection.setModelInfoCollection(mapperLayer.mapCatalogCollectionToCollection(collectionResourceCust,
+ collectionResourceCust.getCollectionResource()));
+ return collection;
+ }
+
protected void mapL3Networks(List<AAIResourceUri> list, List<L3Network> l3Networks) {
for (AAIResourceUri aaiResourceUri : list) {
l3Networks.add(this.mapL3Network(aaiResourceUri));
@@ -2080,14 +2080,10 @@ public class BBInputSetup implements JavaDelegate {
AAIResultWrapper owningEntityWrapper = owningEntities.get(0);
Optional<org.onap.aai.domain.yang.OwningEntity> aaiOwningEntityOp =
owningEntityWrapper.asBean(org.onap.aai.domain.yang.OwningEntity.class);
- org.onap.aai.domain.yang.OwningEntity aaiOwningEntity = null;
- if (!aaiOwningEntityOp.isPresent()) {
- return;
+ if (aaiOwningEntityOp.isPresent()) {
+ OwningEntity owningEntity = this.mapperLayer.mapAAIOwningEntity(aaiOwningEntityOp.get());
+ serviceInstance.setOwningEntity(owningEntity);
}
- aaiOwningEntity = aaiOwningEntityOp.get();
-
- OwningEntity owningEntity = this.mapperLayer.mapAAIOwningEntity(aaiOwningEntity);
- serviceInstance.setOwningEntity(owningEntity);
}
}
@@ -2096,14 +2092,10 @@ public class BBInputSetup implements JavaDelegate {
AAIResultWrapper projectWrapper = projects.get(0);
Optional<org.onap.aai.domain.yang.Project> aaiProjectOp =
projectWrapper.asBean(org.onap.aai.domain.yang.Project.class);
- org.onap.aai.domain.yang.Project aaiProject = null;
- if (!aaiProjectOp.isPresent()) {
- return;
+ if (aaiProjectOp.isPresent()) {
+ Project project = this.mapperLayer.mapAAIProject(aaiProjectOp.get());
+ serviceInstance.setProject(project);
}
- aaiProject = aaiProjectOp.get();
-
- Project project = this.mapperLayer.mapAAIProject(aaiProject);
- serviceInstance.setProject(project);
}
}
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 458919c48e..9e9c6f365f 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
@@ -815,6 +815,26 @@ public class BBInputSetupTest {
assertThat(actual, sameBeanAs(expected));
}
+ @Test
+ public void testGetServiceInstanceHelperCreateScenarioExistingWithName() throws Exception {
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestDetails.setRequestInfo(requestInfo);
+ ServiceSubscription serviceSub = new ServiceSubscription();
+ Customer customer = new Customer();
+ customer.setServiceSubscription(serviceSub);
+ ServiceInstance expected = new ServiceInstance();
+ expected.setServiceInstanceId("serviceInstanceId");
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId("serviceInstanceId");
+
+ doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceByIdAndCustomer(Mockito.any(),
+ Mockito.any(), Mockito.any());
+ ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
+ new HashMap<>(), "SharansInstanceId", false, new Service(), "ActivateServiceInstanceBB");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
@Test(expected = Exception.class)
public void testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithIdExceptionThrown() throws Exception {
RequestDetails requestDetails = new RequestDetails();