specify a new type to cloud specific artifacts 75/82075/16
authorLiang <liang.ding@intel.com>
Wed, 13 Mar 2019 01:49:25 +0000 (01:49 +0000)
committerOren Kleks <orenkle@amdocs.com>
Wed, 10 Apr 2019 06:10:03 +0000 (06:10 +0000)
Change-Id: I26e9533989a377d407290451063d97263a814d6b
Issue-ID: SDC-2041
Signed-off-by: Liang Ding <liang.ding@intel.com>
openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/FileData.java
openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java [new file with mode: 0644]

index 35276b4..d343264 100644 (file)
@@ -93,6 +93,7 @@ public class FileData {
         MURANO_PKG("MURANO_PKG"),
         VENDOR_LICENSE("VENDOR_LICENSE"),
         VF_LICENSE("VF_LICENSE"),
+        CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT("CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT"),
         OTHER("OTHER");
 
         private String displayName;
index 3c100f1..e1a47db 100644 (file)
@@ -36,6 +36,11 @@ import java.util.regex.Pattern;
 public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
   protected static final Logger logger =
       LoggerFactory.getLogger(ManifestCreatorNamingConventionImpl.class);
+
+  private static final String CLOUD_SPECIFIC_FIXED_KEY_WORD = "cloudtech";
+  private static final String[][] CLOUD_SPECIFIC_KEY_WORDS = {{"k8s", "azure", "aws"}, /* cloud specific technology */
+                                                              {"charts", "day0", "configtemplate"} /*cloud specific sub type*/};
+
   @Override
   public Optional<ManifestContent> createManifest(
       VspDetails vspDetails, FilesDataStructure filesDataStructure) {
@@ -132,6 +137,18 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
     return Pattern.matches(Constants.BASE_HEAT_REGEX, fileName) && !isVolFile(fileName);
   }
 
+  protected boolean isCloudSpecificArtifact(String artifact) {
+      if (artifact.contains(CLOUD_SPECIFIC_FIXED_KEY_WORD)) {
+          for (int i = 0; i < CLOUD_SPECIFIC_KEY_WORDS.length; i++) {
+              if (Arrays.stream(CLOUD_SPECIFIC_KEY_WORDS[i]).noneMatch(str -> artifact.contains(str))) {
+                  return false;
+              }
+          }
+          return true;
+      } else {
+          return false;
+      }
+  }
 
   private void addArtifactsToManifestFileDataList(
       FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
@@ -139,7 +156,11 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
         .union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned());
     if (CollectionUtils.isNotEmpty(forArtifacts)) {
       for (String artifact : forArtifacts) {
-        fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact));
+        if (isCloudSpecificArtifact(artifact)) {
+            fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact));
+        } else {
+            fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact));
+        }
       }
     }
   }
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java
new file mode 100644 (file)
index 0000000..f5d2457
--- /dev/null
@@ -0,0 +1,29 @@
+package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNamingConventionImpl {
+
+    private static final String ARTIFACT_1 = "cloudtech_k8s_charts.zip";
+    private static final String ARTIFACT_2 = "cloudtech_azure_day0.zip";
+    private static final String ARTIFACT_3 = "cloudtech_aws_configtemplate.zip";
+    private static final String ARTIFACT_4 = "k8s_charts.zip";
+    private static final String ARTIFACT_5 = "cloudtech_openstack_configtemplate.zip";
+
+    @Test
+    public void testIsCloudSpecificArtifact() {
+        assertTrue(isCloudSpecificArtifact(ARTIFACT_1));
+        assertTrue(isCloudSpecificArtifact(ARTIFACT_2));
+        assertTrue(isCloudSpecificArtifact(ARTIFACT_3));
+        assertFalse(isCloudSpecificArtifact(ARTIFACT_4));
+        assertFalse(isCloudSpecificArtifact(ARTIFACT_5));
+    }
+}