Fix null values in model node type values 02/136302/3
authorMichaelMorris <michael.morris@est.tech>
Fri, 20 Oct 2023 18:34:42 +0000 (19:34 +0100)
committerMichael Morris <michael.morris@est.tech>
Fri, 20 Oct 2023 20:25:58 +0000 (20:25 +0000)
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-4663
Change-Id: I707d4532be97f093110cdc29d8807014259d8145

catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java

index a0e4203..d80a91f 100644 (file)
@@ -40,6 +40,7 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Date;
 import java.util.EnumMap;
 import java.util.HashMap;
@@ -745,7 +746,7 @@ public class CommonCsarGenerator {
                 final Object object = propertiesFromMergingContent.get(key);
                 if (object instanceof Map) {
                     ((Map<String, Object>) object).keySet().forEach(s ->
-                        propertiesMap.put(s, ((Map<String, Object>) value).get(s))
+                        propertiesMap.put(s, getValue(s, (Map<String, Object>) value))
                     );
                 } else {
                     propertiesMap.putAll(createProperties(value));
@@ -758,6 +759,24 @@ public class CommonCsarGenerator {
         return result;
     }
 
+    private Object getValue(final String key, Map<String, Object> value) {
+        final String mappedKey = mapKey(key);
+        if (mappedKey.equals("schemaType")) {
+            return Collections.singletonMap("type", value.get(mappedKey));
+        }
+        return value.get(mappedKey);
+    }
+
+    private String mapKey(final String key) {
+        if (key.equals("entry_schema")) {
+            return "schemaType";
+        }
+        if (key.equals("default")) {
+            return "defaultValue";
+        }
+        return key;
+    }
+
     private Map<String, Object> createProperties(final Object value) {
         final Map<String, Object> propertiesMap = new HashMap<>();
         propertiesMap.put("type", ((Map<String, Object>) value).get("type"));