summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2021-09-29 11:10:14 +0100
committerAndr� Schmid <andre.schmid@est.tech>2021-09-29 18:01:31 +0000
commit5546fc839016788d97e04ed99cee54d6acbce472 (patch)
tree0f6cb7df5a21b8311e00a294cfb72b7a1669735a
parentaf35b7126cd14e2a8c3a6b0d33d142a7760216c8 (diff)
Fixing distribution to AAI/SO issue
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3740 Change-Id: Ib39125eac6011c393f6ee643e3997e1bff6f43c3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java42
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java37
2 files changed, 77 insertions, 2 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java
index 0af2bb55ed..0b13ff8609 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java
@@ -23,35 +23,75 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.stream.Collectors;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupInstance;
import org.openecomp.sdc.be.model.GroupInstanceProperty;
+import org.openecomp.sdc.be.model.GroupProperty;
import org.openecomp.sdc.common.api.Constants;
+@SuppressWarnings("unused")
public class VfModuleArtifactPayload {
- private String vfModuleModelName;
+ private String vfModuleModelName;
+ private String vfModuleModelInvariantUUID;
+ private String vfModuleModelVersion;
+ private String vfModuleModelUUID;
+ private String vfModuleModelCustomizationUUID;
+ private String vfModuleModelDescription;
+ private Boolean isBase;
private List<String> artifacts;
private Map<String, Object> properties;
public VfModuleArtifactPayload(GroupDefinition group) {
vfModuleModelName = group.getName();
+ vfModuleModelInvariantUUID = group.getInvariantUUID();
+ vfModuleModelVersion = group.getVersion();
+ vfModuleModelUUID = group.getGroupUUID();
+ vfModuleModelDescription = group.getDescription();
artifacts = group.getArtifactsUuid();
// Base Value is set from properties
+ setBaseValue(group);
}
public VfModuleArtifactPayload(GroupInstance group) {
vfModuleModelName = group.getGroupName();
+ vfModuleModelInvariantUUID = group.getInvariantUUID();
+ vfModuleModelVersion = group.getVersion();
+ vfModuleModelUUID = group.getGroupUUID();
+ vfModuleModelCustomizationUUID = group.getCustomizationUUID();
+ vfModuleModelDescription = group.getDescription();
artifacts = new ArrayList<>(group.getArtifactsUuid() != null ? group.getArtifactsUuid() : new LinkedList<>());
artifacts.addAll(group.getGroupInstanceArtifactsUuid() != null ? group.getGroupInstanceArtifactsUuid() : new LinkedList<>());
// Base Value is set from properties
+ setBaseValue(group);
if (group.convertToGroupInstancesProperties() != null) {
setProperties(group.convertToGroupInstancesProperties());
}
}
+ private void setBaseValue(GroupInstance group) {
+ if (group.convertToGroupInstancesProperties() != null) {
+ Optional<GroupInstanceProperty> findBaseProperty = group.convertToGroupInstancesProperties().stream()
+ .filter(p -> p.getName().equals(Constants.IS_BASE)).findAny();
+ if (findBaseProperty.isPresent()) {
+ isBase = Boolean.valueOf(findBaseProperty.get().getValue());
+ }
+ }
+ }
+
+ private void setBaseValue(GroupDefinition group) {
+ if (group.getProperties() != null) {
+ Optional<GroupProperty> findBaseProperty = group.convertToGroupProperties().stream().filter(p -> p.getName().equals(Constants.IS_BASE))
+ .findAny();
+ if (findBaseProperty.isPresent()) {
+ isBase = Boolean.valueOf(findBaseProperty.get().getValue());
+ }
+ }
+ }
+
public static int compareByGroupName(VfModuleArtifactPayload art1, VfModuleArtifactPayload art2) {
Float thisCounter = Float.parseFloat(art1.vfModuleModelName.split(Constants.MODULE_NAME_DELIMITER)[1].replace(' ', '.'));
Float otherCounter = Float.parseFloat(art2.vfModuleModelName.split(Constants.MODULE_NAME_DELIMITER)[1].replace(' ', '.'));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java
index f808f4839c..23af5f54bc 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java
@@ -21,10 +21,12 @@
package org.openecomp.sdc.be.components.distribution.engine;
import org.junit.Test;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupInstance;
import org.openecomp.sdc.be.model.GroupInstanceProperty;
-
+import com.google.gson.Gson;
+import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -40,6 +42,39 @@ public class VfModuleArtifactPayloadTest {
public void testConstructor() {
new VfModuleArtifactPayload(new GroupInstance());
}
+
+ @Test
+ public void toJson() {
+ final Gson gson = new Gson();
+
+ final GroupInstance group = new GroupInstance();
+ final String groupName = "groupName";
+ final String invariantUUID = "123abc";
+ final String version = "1.0";
+ final String groupUuid = "abc123";
+ final String customizationUUID = "abc987";
+ final List<PropertyDataDefinition> properties = new ArrayList<>();
+ final PropertyDataDefinition property = new PropertyDataDefinition();
+ property.setName("isBase");
+ property.setValue("true");
+ properties.add(property );
+
+ group.setGroupName(groupName);
+ group.setInvariantUUID(invariantUUID);
+ group.setVersion(version);
+ group.setGroupUUID(groupUuid);
+ group.setCustomizationUUID(customizationUUID);
+ group.setProperties(properties);
+
+ final String asJson = gson.toJson(new VfModuleArtifactPayload(group));
+
+ assertTrue(asJson.contains(groupName));
+ assertTrue(asJson.contains(invariantUUID));
+ assertTrue(asJson.contains(version));
+ assertTrue(asJson.contains(groupUuid));
+ assertTrue(asJson.contains(customizationUUID));
+ assertTrue(asJson.contains("isBase"));
+ }
@Test