aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
authorAlexey Sandler <alexey.sandler@intl.att.com>2019-12-22 14:50:48 +0200
committerAlexey Sandler <alexey.sandler@intl.att.com>2019-12-22 17:25:25 +0200
commit08b74c3652af3e0c8264e5971763f2d2845413b8 (patch)
treecc7eff8e2ad1c24dc370e8d5589f6383d6f8ad9a /vid-app-common
parent4c87ecaa8cce40f078f8540a15928e7e805e4ef7 (diff)
Add Volume Groups count ability during summarizing.
Issue-ID: VID-724 Signed-off-by: Alexey Sandler <alexey.sandler@intl.att.com> Change-Id: I0478469817f13609618c1597c654decac463474b
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java35
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java1
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/templateSummarize4vnfs6vfmodules.json3
3 files changed, 32 insertions, 7 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
index c0ee7ea4f..787ad1262 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
@@ -20,11 +20,13 @@
package org.onap.vid.services;
+import static com.google.common.collect.Streams.concat;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;
-import static java.util.stream.Stream.concat;
+import static java.util.stream.Stream.empty;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
@@ -41,7 +43,6 @@ import java.util.Objects;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.stream.Stream;
-import org.apache.commons.lang3.StringUtils;
import org.hibernate.SessionFactory;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.aai.AaiClientInterface;
@@ -63,6 +64,7 @@ import org.onap.vid.model.ResourceInfo;
import org.onap.vid.model.ServiceInfo;
import org.onap.vid.model.serviceInstantiation.BaseResource;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.vid.model.serviceInstantiation.VfModule;
import org.onap.vid.mso.MsoBusinessLogicImpl;
import org.onap.vid.mso.MsoProperties;
import org.onap.vid.mso.MsoUtil;
@@ -188,9 +190,8 @@ public class AsyncInstantiationBusinessLogicImpl implements
public Map<String, Long> getSummarizedChildrenMap(ServiceInstantiation serviceInstantiation){
Stream<String> existingTypesStream =
allDeepChildResources(serviceInstantiation)
- .map(BaseResource::getModelInfo)
- .filter(Objects::nonNull)
- .map(ModelInfo::getModelType);
+ .map(this::getModelTypes)
+ .flatMap(identity());
Map<String, Long> existingTypesCounters =
existingTypesStream.collect(groupingBy(identity(), counting()));
@@ -198,6 +199,28 @@ public class AsyncInstantiationBusinessLogicImpl implements
return existingTypesCounters;
}
+ private Stream<String> getModelTypes(BaseResource resource) {
+ return concat(
+ Stream.of(resource)
+ .map(BaseResource::getModelInfo)
+ .filter(Objects::nonNull)
+ .map(ModelInfo::getModelType),
+ streamVolumeGroups(resource)
+ );
+ }
+
+ private Stream<String> streamVolumeGroups(BaseResource resource) {
+ return hasVolumeGroup(resource)
+ ? Stream.of("volumeGroup")
+ : empty();
+ }
+
+ private boolean hasVolumeGroup(BaseResource resource) {
+ return
+ resource instanceof VfModule
+ && isNotEmpty(((VfModule) resource).getVolumeGroupInstanceName());
+ }
+
private Stream<BaseResource> allDeepChildResources(BaseResource resource) {
return resource
.getChildren()
@@ -216,7 +239,7 @@ public class AsyncInstantiationBusinessLogicImpl implements
private String getOptimisticUniqueServiceInstanceName(String instanceName) {
- return StringUtils.isNotEmpty(instanceName) ? getUniqueNameFromDbOnly(instanceName) : instanceName;
+ return isNotEmpty(instanceName) ? getUniqueNameFromDbOnly(instanceName) : instanceName;
}
protected ServiceInfo createServiceInfo(String userId, ServiceInstantiation serviceInstantiation, UUID jobId, UUID templateId, Date createdBulkDate, String optimisticUniqueServiceInstanceName, ServiceInfo.ServiceAction serviceAction) {
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
index b17b968ca..93208aa1b 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
@@ -499,6 +499,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
Map<String, Long> expectedMap = ImmutableMap.of(
"vnf", 4L,
"vfModule", 6L,
+ "volumeGroup", 1L,
"network", 2L
);
assertEquals(childrenMap,expectedMap);
diff --git a/vid-app-common/src/test/resources/payload_jsons/templateSummarize4vnfs6vfmodules.json b/vid-app-common/src/test/resources/payload_jsons/templateSummarize4vnfs6vfmodules.json
index 89a120946..8579efe89 100644
--- a/vid-app-common/src/test/resources/payload_jsons/templateSummarize4vnfs6vfmodules.json
+++ b/vid-app-common/src/test/resources/payload_jsons/templateSummarize4vnfs6vfmodules.json
@@ -21,7 +21,8 @@
"vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1yprvi": {
"modelInfo": {
"modelType": "vfModule"
- }
+ },
+ "volumeGroupName": "my_special_hvf6arlba007_lba_dj_01_vol"
}
}
}