aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java174
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java95
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java3
5 files changed, 206 insertions, 220 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();
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 9200d99fe1..2921cada18 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
@@ -144,6 +144,7 @@ public class WorkflowAction {
private static final String VOLUMEGROUP_DELETE_PATTERN = "(Un|De)(.*)Volume(.*)";
private static final String VOLUMEGROUP_CREATE_PATTERN = "(A|C)(.*)Volume(.*)";
private static final String CONTROLLER = "Controller";
+ private static final String DEFAULT_CLOUD_OWNER = "org.onap.so.cloud-owner";
@Autowired
protected BBInputSetup bbInputSetup;
@@ -159,10 +160,8 @@ public class WorkflowAction {
private WorkflowActionExtractResourcesAAI workflowActionUtils;
@Autowired
private VrfValidation vrfValidation;
-
@Autowired
private Environment environment;
- private String defaultCloudOwner = "org.onap.so.cloud-owner";
public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
this.bbInputSetupUtils = bbInputSetupUtils;
@@ -235,7 +234,7 @@ public class WorkflowAction {
.setRequestDetails(requestDetails).setExecution(execution));
for (OrchestrationFlow orchFlow : orchFlows) {
if (orchFlow.getFlowName().contains(CONFIGURATION)) {
- List<OrchestrationFlow> configOrchFlows = new ArrayList<OrchestrationFlow>();
+ List<OrchestrationFlow> configOrchFlows = new ArrayList<>();
configOrchFlows.add(orchFlow);
List<ExecuteBuildingBlock> configBuildingBlocks =
getConfigBuildingBlocks(new ConfigBuildingBlocksDataObject()
@@ -287,11 +286,8 @@ public class WorkflowAction {
if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
List<Map<String, Object>> userParams =
sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- for (Map<String, Object> params : userParams) {
- if (params.containsKey(USERPARAMSERVICE)) {
- containsService = true;
- }
- }
+ containsService =
+ userParams.stream().anyMatch(param -> param.containsKey(USERPARAMSERVICE));
if (containsService) {
traverseUserParamsService(execution, resourceList, sIRequest, requestAction);
}
@@ -309,11 +305,8 @@ public class WorkflowAction {
if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
List<Map<String, Object>> userParams =
sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- for (Map<String, Object> params : userParams) {
- if (params.containsKey(USERPARAMSERVICE)) {
- containsService = true;
- }
- }
+ containsService =
+ userParams.stream().anyMatch(param -> param.containsKey(USERPARAMSERVICE));
}
if (containsService) {
foundRelated = traverseUserParamsService(execution, resourceList, sIRequest, requestAction);
@@ -341,13 +334,13 @@ public class WorkflowAction {
} else {
buildAndThrowException(execution, "Current Macro Request is not supported");
}
- String foundObjects = "";
+ StringBuilder foundObjects = new StringBuilder();
for (WorkflowType type : WorkflowType.values()) {
- foundObjects = foundObjects + type + " - " + resourceList.stream()
- .filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList()).size()
- + " ";
+ foundObjects.append(type).append(" - ").append(
+ (int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count())
+ .append(" ");
}
- logger.info("Found {}", foundObjects);
+ logger.info("Found {}", foundObjects.toString());
if (orchFlows == null || orchFlows.isEmpty()) {
orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, isALaCarte,
@@ -367,8 +360,7 @@ public class WorkflowAction {
// By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE
if (resourceType == WorkflowType.SERVICE
&& (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE))
- && !resourceList.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType()))
- .collect(Collectors.toList()).isEmpty()) {
+ && resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
execution.setVariable("homing", true);
execution.setVariable("calledHoming", false);
}
@@ -389,11 +381,7 @@ public class WorkflowAction {
sIRequest.getRequestDetails().getRequestParameters().getUserParams();
for (Map<String, Object> params : userParams) {
if (params.containsKey(HOMINGSOLUTION)) {
- if ("none".equals(params.get(HOMINGSOLUTION))) {
- execution.setVariable("homing", false);
- } else {
- execution.setVariable("homing", true);
- }
+ execution.setVariable("homing", !"none".equals(params.get(HOMINGSOLUTION)));
}
}
}
@@ -448,7 +436,7 @@ public class WorkflowAction {
return cloudConfiguration.getCloudOwner();
}
logger.warn("cloud owner value not found in request details, it will be set as default");
- return environment.getProperty(defaultCloudOwner);
+ return environment.getProperty(DEFAULT_CLOUD_OWNER);
}
protected <T> List<T> getRelatedResourcesInVfModule(String vnfId, String vfModuleId, Class<T> resultClass,
@@ -514,7 +502,7 @@ public class WorkflowAction {
String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId();
String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
- String vfModuleCustomizationUUID = "";
+ String vfModuleCustomizationUUID;
org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId);
if (aaiVfModule == null) {
@@ -575,8 +563,7 @@ public class WorkflowAction {
boolean rebuildVolumeGroups = false;
if (dataObj.getRequestDetails().getRequestParameters() != null
&& dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups() != null) {
- rebuildVolumeGroups =
- dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups().booleanValue();
+ rebuildVolumeGroups = dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups();
}
Optional<VolumeGroup> volumeGroupFromVfModule =
@@ -629,7 +616,7 @@ public class WorkflowAction {
}
Relationships relationships = relationshipsOp.get();
List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(AAIObjectType.VNFC);
- if (vnfcResultWrappers.size() > 1 || vnfcResultWrappers.isEmpty()) {
+ if (vnfcResultWrappers.size() != 1) {
logger.debug("Too many vnfcs or no vnfc found that are related to configuration");
}
Optional<Vnfc> vnfcOp = vnfcResultWrappers.get(0).asBean(Vnfc.class);
@@ -667,11 +654,10 @@ public class WorkflowAction {
logger.debug(pair.getValue0() + ", " + pair.getValue1());
}
- Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> {
- resourceList.stream().filter(resource -> type.equals(resource.getResourceType()))
- .forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(),
- retrieveAAIResourceId(aaiResourceIds, type), null, serviceInstanceId));
- });
+ Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE))
+ .forEach(type -> resourceList.stream().filter(resource -> type.equals(resource.getResourceType()))
+ .forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(),
+ retrieveAAIResourceId(aaiResourceIds, type), null, serviceInstanceId)));
}
private String retrieveAAIResourceId(List<Pair<WorkflowType, String>> aaiResourceIds, WorkflowType resource) {
@@ -688,11 +674,10 @@ public class WorkflowAction {
private void generateResourceIds(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList,
String serviceInstanceId) {
- Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> {
- resourceList.stream().filter(resource -> type.equals(resource.getResourceType()))
- .forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(), null,
- resource.getVirtualLinkKey(), serviceInstanceId));
- });
+ Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE))
+ .forEach(type -> resourceList.stream().filter(resource -> type.equals(resource.getResourceType()))
+ .forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(),
+ null, resource.getVirtualLinkKey(), serviceInstanceId)));
}
protected void updateWorkflowResourceIds(List<ExecuteBuildingBlock> flowsToExecute, WorkflowType resourceType,
@@ -947,8 +932,7 @@ public class WorkflowAction {
}
private boolean isNetworkCollectionInTheResourceList(List<Resource> resourceList) {
- return !(resourceList.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType())
- .collect(Collectors.toList()).isEmpty());
+ return resourceList.stream().anyMatch(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType());
}
private boolean isVnfCustomizationsInTheService(org.onap.so.db.catalog.beans.Service service) {
@@ -962,28 +946,7 @@ public class WorkflowAction {
org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
- if (serviceInstanceMSO.getVnfs() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
- aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
- resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
- if (vnf.getVfModules() != null) {
- for (VfModule vfModule : vnf.getVfModules()) {
- aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
- Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false);
- resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean());
- resourceList.add(resource);
- }
- }
- if (vnf.getVolumeGroups() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
- .getVolumeGroups()) {
- aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
- resourceList
- .add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
- }
- }
- }
- }
+ traverseServiceInstanceMSOVnfs(resourceList, aaiResourceIds, serviceInstanceMSO);
if (serviceInstanceMSO.getNetworks() != null) {
for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO
.getNetworks()) {
@@ -1022,6 +985,38 @@ public class WorkflowAction {
}
}
+ private void traverseServiceInstanceMSOVnfs(List<Resource> resourceList,
+ List<Pair<WorkflowType, String>> aaiResourceIds,
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) {
+ if (serviceInstanceMSO.getVnfs() == null) {
+ return;
+ }
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
+ aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
+ resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
+ traverseVnfModules(resourceList, aaiResourceIds, vnf);
+ if (vnf.getVolumeGroups() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf.getVolumeGroups()) {
+ aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
+ resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
+ }
+ }
+ }
+ }
+
+ private void traverseVnfModules(List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds,
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf) {
+ if (vnf.getVfModules() == null) {
+ return;
+ }
+ for (VfModule vfModule : vnf.getVfModules()) {
+ aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
+ Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false);
+ resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean());
+ resourceList.add(resource);
+ }
+ }
+
private void traverseAAIVnf(DelegateExecution execution, List<Resource> resourceList, String serviceId,
String vnfId, List<Pair<WorkflowType, String>> aaiResourceIds) {
try {
@@ -1134,12 +1129,9 @@ public class WorkflowAction {
foundVfModuleOrVG = true;
Resource resource = new Resource(WorkflowType.VFMODULE,
vfModuleCustomization.getModelCustomizationUUID(), false);
- if (vfModuleCustomization.getVfModule().getIsBase() != null
- && vfModuleCustomization.getVfModule().getIsBase()) {
- resource.setBaseVfModule(true);
- } else {
- resource.setBaseVfModule(false);
- }
+ resource.setBaseVfModule(
+ vfModuleCustomization.getVfModule().getIsBase() != null
+ && vfModuleCustomization.getVfModule().getIsBase());
resourceList.add(resource);
if (vfModule.getModelInfo() != null
&& vfModule.getModelInfo().getModelCustomizationUuid() != null) {
@@ -1429,7 +1421,7 @@ public class WorkflowAction {
true, false);
} else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER)
&& (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- List<Resource> vfModuleResourcesSorted = null;
+ List<Resource> vfModuleResourcesSorted;
if (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)
|| requestAction.equals("activateInstance")) {
vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceList.stream()
@@ -1438,10 +1430,10 @@ public class WorkflowAction {
vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceList.stream()
.filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
}
- for (int i = 0; i < vfModuleResourcesSorted.size(); i++) {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, vfModuleResourcesSorted.get(i),
- apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails,
- false, null, null, false));
+ for (Resource resource : vfModuleResourcesSorted) {
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
+ requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null,
+ false));
}
} else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) {
if (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
@@ -1477,8 +1469,8 @@ public class WorkflowAction {
new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString())
.setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey)
.setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse(""));
- Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(action -> buildingBlock.setBpmnAction(action));
- Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(scope -> buildingBlock.setBpmnScope(scope));
+ Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(buildingBlock::setBpmnAction);
+ Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(buildingBlock::setBpmnScope);
if (resource != null
&& (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
@@ -1493,16 +1485,21 @@ public class WorkflowAction {
.setRequestDetails(requestDetails);
if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) {
- ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
- Optional.ofNullable(vnfcName).ifPresent(name -> configurationResourceKeys.setVnfcName(name));
- configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
- configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
- configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
+ ConfigurationResourceKeys configurationResourceKeys = getConfigurationResourceKeys(resource, vnfcName);
executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
}
return executeBuildingBlock;
}
+ private ConfigurationResourceKeys getConfigurationResourceKeys(Resource resource, String vnfcName) {
+ ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
+ Optional.ofNullable(vnfcName).ifPresent(configurationResourceKeys::setVnfcName);
+ configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
+ configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
+ configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
+ return configurationResourceKeys;
+ }
+
protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction,
WorkflowType resourceName, boolean aLaCarte, String cloudOwner) {
return this.queryNorthBoundRequestCatalogDb(execution, requestAction, resourceName, aLaCarte, cloudOwner, "");
@@ -1511,7 +1508,7 @@ public class WorkflowAction {
protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction,
WorkflowType resourceName, boolean aLaCarte, String cloudOwner, String serviceType) {
List<OrchestrationFlow> listToExecute = new ArrayList<>();
- NorthBoundRequest northBoundRequest = null;
+ NorthBoundRequest northBoundRequest;
if (serviceType.equalsIgnoreCase(SERVICE_TYPE_TRANSPORT)
|| serviceType.equalsIgnoreCase(SERVICE_TYPE_BONDING)) {
northBoundRequest =
@@ -1592,7 +1589,7 @@ public class WorkflowAction {
}
protected String validateServiceResourceIdInAAI(String generatedResourceId, String instanceName,
- RequestDetails reqDetails) throws DuplicateNameException, MultipleObjectsFoundException {
+ RequestDetails reqDetails) throws DuplicateNameException {
String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId();
String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType();
if (instanceName != null) {
@@ -1656,8 +1653,7 @@ public class WorkflowAction {
}
protected String validateVnfResourceIdInAAI(String generatedResourceId, String instanceName,
- RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds)
- throws DuplicateNameException, MultipleObjectsFoundException {
+ RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
Optional<GenericVnf> vnf = bbInputSetupUtils
.getRelatedVnfByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
if (vnf.isPresent()) {
@@ -1701,8 +1697,7 @@ public class WorkflowAction {
}
protected String validateVolumeGroupResourceIdInAAI(String generatedResourceId, String instanceName,
- RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds)
- throws DuplicateNameException, MultipleObjectsFoundException {
+ RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
Optional<VolumeGroup> volumeGroup =
bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName);
if (volumeGroup.isPresent()) {
@@ -1720,8 +1715,7 @@ public class WorkflowAction {
}
protected String validateConfigurationResourceIdInAAI(String generatedResourceId, String instanceName,
- RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds)
- throws DuplicateNameException, MultipleObjectsFoundException {
+ RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
Optional<org.onap.aai.domain.yang.Configuration> configuration =
bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance(
workflowResourceIds.getServiceInstanceId(), instanceName);
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 be2abb21a2..343b25eb97 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
@@ -20,20 +20,12 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.UUID;
-import javax.persistence.EntityNotFoundException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.InstanceGroup;
-import org.onap.aai.domain.yang.L3Network;
-import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aai.domain.yang.VfModule;
-import org.onap.aai.domain.yang.Vnfc;
-import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.aai.domain.yang.*;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.entities.Configuration;
import org.onap.so.bpmn.common.DelegateExecutionImpl;
import org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner;
import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner;
@@ -44,8 +36,6 @@ import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
-import org.onap.aaiclient.client.aai.AAIObjectType;
-import org.onap.aaiclient.client.aai.entities.Configuration;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
import org.onap.so.db.catalog.client.CatalogDbClient;
@@ -58,8 +48,13 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.persistence.EntityNotFoundException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.stream.Collectors;
@Component
public class WorkflowActionBBTasks {
@@ -108,11 +103,7 @@ public class WorkflowActionBBTasks {
execution.setVariable("buildingBlock", ebb);
currentSequence++;
- if (currentSequence >= flowsToExecute.size()) {
- execution.setVariable(COMPLETED, true);
- } else {
- execution.setVariable(COMPLETED, false);
- }
+ execution.setVariable(COMPLETED, currentSequence >= flowsToExecute.size());
execution.setVariable(G_CURRENT_SEQUENCE, currentSequence);
}
@@ -152,7 +143,7 @@ public class WorkflowActionBBTasks {
protected Long getPercentProgress(int completedBBs, int totalBBs) {
double ratio = (completedBBs / (totalBBs * 1.0));
int percentProgress = (int) (ratio * 95);
- return new Long(percentProgress + 5);
+ return (long) (percentProgress + 5);
}
protected String getStatusMessage(String completedBB, String nextBB, int completedBBs, int remainingBBs) {
@@ -222,7 +213,7 @@ public class WorkflowActionBBTasks {
final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
final String resourceName = (String) execution.getVariable("resourceName");
String statusMessage = (String) execution.getVariable("StatusMessage");
- String macroAction = "";
+ String macroAction;
if (statusMessage == null) {
if (aLaCarte) {
macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly.";
@@ -237,7 +228,7 @@ public class WorkflowActionBBTasks {
request.setEndTime(endTime);
request.setFlowStatus("Successfully completed all Building Blocks");
request.setStatusMessage(macroAction);
- request.setProgress(Long.valueOf(100));
+ request.setProgress(100L);
request.setRequestStatus("COMPLETE");
request.setLastModifiedBy("CamundaBPMN");
requestsDbListener.post(request, new DelegateExecutionImpl(execution));
@@ -294,14 +285,11 @@ public class WorkflowActionBBTasks {
List<ExecuteBuildingBlock> flowsToExecute =
(List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- List<ExecuteBuildingBlock> flowsToExecuteChangeBBs = new ArrayList();
- for (int i = 0; i < flowsToExecute.size(); i++) {
- if (flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName().startsWith("Change")) {
- flowsToExecuteChangeBBs.add(flowsToExecute.get(i));
- }
- }
+ List<ExecuteBuildingBlock> flowsToExecuteChangeBBs = flowsToExecute.stream()
+ .filter(buildingBlock -> buildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change"))
+ .collect(Collectors.toList());
- List<ExecuteBuildingBlock> rollbackFlows = new ArrayList();
+ List<ExecuteBuildingBlock> rollbackFlows = new ArrayList<>();
int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
int listSize = flowsToExecute.size();
@@ -339,25 +327,24 @@ public class WorkflowActionBBTasks {
}
String handlingCode = (String) execution.getVariable(HANDLINGCODE);
- List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>();
- rollbackFlowsFiltered.addAll(rollbackFlows);
+ List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>(rollbackFlows);
if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode)) {
- for (int i = 0; i < rollbackFlows.size(); i++) {
- if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Unassign") && !rollbackFlows
- .get(i).getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) {
- rollbackFlowsFiltered.remove(rollbackFlows.get(i));
- } else if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Delete")
+ for (ExecuteBuildingBlock rollbackFlow : rollbackFlows) {
+ if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Unassign")
+ && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) {
+ rollbackFlowsFiltered.remove(rollbackFlow);
+ } else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Delete")
&& ROLLBACKTOCREATED.equals(handlingCode)) {
- rollbackFlowsFiltered.remove(rollbackFlows.get(i));
+ rollbackFlowsFiltered.remove(rollbackFlow);
}
}
}
- List<ExecuteBuildingBlock> rollbackFlowsFilteredNonChangeBBs = new ArrayList();
+ List<ExecuteBuildingBlock> rollbackFlowsFilteredNonChangeBBs = new ArrayList<>();
if (action.equals(REPLACEINSTANCE) && resourceName.equals(VFMODULE)) {
- for (int i = 0; i < rollbackFlowsFiltered.size(); i++) {
- if (!rollbackFlowsFiltered.get(i).getBuildingBlock().getBpmnFlowName().startsWith("Change")) {
- rollbackFlowsFilteredNonChangeBBs.add(rollbackFlowsFiltered.get(i));
+ for (ExecuteBuildingBlock executeBuildingBlock : rollbackFlowsFiltered) {
+ if (!executeBuildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")) {
+ rollbackFlowsFilteredNonChangeBBs.add(executeBuildingBlock);
}
}
rollbackFlowsFiltered.clear();
@@ -366,10 +353,7 @@ public class WorkflowActionBBTasks {
}
workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
- if (rollbackFlows.isEmpty())
- execution.setVariable("isRollbackNeeded", false);
- else
- execution.setVariable("isRollbackNeeded", true);
+ execution.setVariable("isRollbackNeeded", !rollbackFlows.isEmpty());
execution.setVariable("flowsToExecute", rollbackFlowsFiltered);
execution.setVariable(HANDLINGCODE, "PreformingRollback");
execution.setVariable("isRollback", true);
@@ -456,9 +440,8 @@ public class WorkflowActionBBTasks {
ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb,
configurationId, configurationResourceKeys);
flowsToExecute.add(addConfigBB);
- flowsToExecute.stream()
- .forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
- executeBB.getBuildingBlock().getBpmnFlowName()));
+ flowsToExecute.forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
+ executeBB.getBuildingBlock().getBpmnFlowName()));
execution.setVariable("flowsToExecute", flowsToExecute);
execution.setVariable(COMPLETED, false);
} else {
@@ -493,12 +476,10 @@ public class WorkflowActionBBTasks {
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(ebb.getWorkflowResourceIds());
workflowResourceIds.setConfigurationId(configurationId);
- ExecuteBuildingBlock configBB = new ExecuteBuildingBlock().setaLaCarte(ebb.isaLaCarte())
- .setApiVersion(ebb.getApiVersion()).setRequestAction(ebb.getRequestAction())
- .setVnfType(ebb.getVnfType()).setRequestId(ebb.getRequestId())
+ return new ExecuteBuildingBlock().setaLaCarte(ebb.isaLaCarte()).setApiVersion(ebb.getApiVersion())
+ .setRequestAction(ebb.getRequestAction()).setVnfType(ebb.getVnfType()).setRequestId(ebb.getRequestId())
.setRequestDetails(ebb.getRequestDetails()).setBuildingBlock(buildingBlock)
.setWorkflowResourceIds(workflowResourceIds).setConfigurationResourceKeys(configurationResourceKeys);
- return configBB;
}
protected void setInstanceName(String resourceId, WorkflowType resourceType, InfraActiveRequests request) {
@@ -522,9 +503,7 @@ public class WorkflowActionBBTasks {
} else if (resourceType == WorkflowType.VOLUMEGROUP && request.getVolumeGroupName() == null) {
Optional<VolumeGroup> volumeGroup =
bbInputSetupUtils.getRelatedVolumeGroupByIdFromVnf(request.getVnfId(), resourceId);
- if (volumeGroup.isPresent()) {
- request.setVolumeGroupName(volumeGroup.get().getVolumeGroupName());
- }
+ volumeGroup.ifPresent(group -> request.setVolumeGroupName(group.getVolumeGroupName()));
} else if (resourceType == WorkflowType.NETWORK && request.getNetworkName() == null) {
L3Network network = bbInputSetupUtils.getAAIL3Network(resourceId);
if (network != null) {
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 0948436345..1aa7640492 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
@@ -57,6 +57,7 @@ import java.util.List;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.anyString;
@@ -176,7 +177,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
workflowActionBBTasks.selectBB(execution);
boolean success = (boolean) execution.getVariable("completed");
int currentSequence = (int) execution.getVariable("gCurrentSequence");
- assertEquals(false, success);
+ assertFalse(success);
assertEquals(1, currentSequence);
}