[SDC-19] VFC to CP props 45/4145/1
authorPavel Aharoni <pa0916@att.com>
Thu, 11 May 2017 16:32:07 +0000 (19:32 +0300)
committerPavel Aharoni <pa0916@att.com>
Thu, 11 May 2017 16:32:07 +0000 (19:32 +0300)
Change-Id: I217934251fd8eeaf883b60161826306d6b7eaf3c
Signed-off-by: Pavel Aharoni <pa0916@att.com>
15 files changed:
.gitignore
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/EntityTemplate.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/common/ExceptionCollector.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/ScalarUnit.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Schema.java
sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java
sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java
sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java
sdc-tosca-parser/src/test/resources/csars/1service-ServiceWithPorts.csar [new file with mode: 0644]

index 74f7cda..233ca40 100644 (file)
@@ -16,5 +16,5 @@ target/
 *.class
 *.orig
 .idea/*
-
+/bin/
 sdc-tosca-parser/test-output/**/*
index a5d0467..3598d02 100644 (file)
@@ -1,7 +1,9 @@
 package org.openecomp.sdc.toscaparser.api;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.LinkedHashMap;
+import java.util.List;
 
 import org.openecomp.sdc.toscaparser.api.common.ExceptionCollector;
 import org.openecomp.sdc.toscaparser.api.elements.*;
@@ -49,8 +51,17 @@ public class DataEntity {
                 ExceptionCollector.appendException(String.format(
                     "TypeMismatchError: \"%s\" doesn't match \"%s\"",
                     value.toString(),dataType.getType()));
-            }
-            LinkedHashMap<String,Object> valueDict = (LinkedHashMap<String,Object>)value;
+
+                               if (value instanceof List)
+                                       value = ((List) value).get(0);
+
+                               if (!(value instanceof LinkedHashMap))
+                                       return value;
+                       }
+
+
+
+                       LinkedHashMap<String,Object> valueDict = (LinkedHashMap<String,Object>)value;
             ArrayList<String> allowedProps = new ArrayList<>();
             ArrayList<String> requiredProps = new ArrayList<>();
             LinkedHashMap<String,Object> defaultProps = new LinkedHashMap<>();
index 3d9c470..cb765ec 100644 (file)
@@ -351,7 +351,7 @@ public abstract class EntityTemplate {
         else {
             // Required properties in schema, but not in template
             if(!requiredProps.isEmpty()) {
-                ExceptionCollector.appendException(String.format(
+                ExceptionCollector.appendWarning(String.format(
                         "MissingRequiredFieldError2: properties of template \"%s\" are missing field(s): %s",
                         name,requiredProps.toString()));
             }
index d1b0179..08b66bd 100644 (file)
@@ -1,5 +1,15 @@
 package org.openecomp.sdc.toscaparser.api;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.openecomp.sdc.toscaparser.api.common.ExceptionCollector;
 import org.openecomp.sdc.toscaparser.api.common.JToscaException;
 import org.openecomp.sdc.toscaparser.api.elements.EntityType;
@@ -12,11 +22,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.yaml.snakeyaml.Yaml;
 
-import java.io.*;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
 public class ToscaTemplate extends Object {
 
        private static Logger log = LoggerFactory.getLogger(ToscaTemplate.class.getName());
@@ -501,24 +506,42 @@ public class ToscaTemplate extends Object {
        }
 
        private void verifyTemplate() throws JToscaException {
-               ArrayList<String> exceptionStrings = ExceptionCollector.getExceptionReport();
-               if (exceptionStrings != null && exceptionStrings.size() > 0) {
-                       int nexc = ExceptionCollector.errorsCaught();
-                       log.error("ToscaTemplate - verifyTemplate - {} Parsing Exception{} occurred...", nexc, (nexc > 1 ? "s" : ""));
-                       for (String s : exceptionStrings) {
+               //Warnings
+               List<String> warningsStrings = ExceptionCollector.getWarningsReport();
+               if (warningsStrings != null && warningsStrings.size() > 0) {
+                       int nexcw = ExceptionCollector.warningsCaught();
+                       log.warn("####################################################################################################");
+                       log.warn("ToscaTemplate - verifyTemplate - {} Parsing Warning{} occurred...", nexcw, (nexcw > 1 ? "s" : ""));
+                       for (String s : warningsStrings) {
                                if (s != null) {
                                        log.debug("ToscaTemplate - verifyTemplate - {}", s);
                                }
                        }
-                       if(bAbortOnParsingErrors) {
-                               throw new JToscaException("Aborting because of parsing errors");
+                       log.warn("####################################################################################################");
+
+                       
+                       List<String> exceptionStrings = ExceptionCollector.getCriticalsReport();
+                       if (exceptionStrings != null && exceptionStrings.size() > 0) {
+                               int nexc = ExceptionCollector.errorsCaught();
+                               log.error("####################################################################################################");
+                               log.error("ToscaTemplate - verifyTemplate - {} Parsing Critical{} occurred...", nexc, (nexc > 1 ? "s" : ""));
+                               for (String s : exceptionStrings) {
+                                       if (s != null) {
+                                               log.debug("ToscaTemplate - verifyTemplate - {}", s);
+                                       }
+                               }
+                               log.error("####################################################################################################");
+                               if(bAbortOnParsingErrors) {
+                                       throw new JToscaException("Aborting because of parsing errors");
+                               }
+                       } 
+                       else {
+                               if (inputPath != null) {
+                                       log.debug("ToscaTemplate - verifyTemplate - The input {} passed validation", inputPath);
+                               }
                        }
+
                } 
-               else {
-                       if (inputPath != null) {
-                               log.debug("ToscaTemplate - verifyTemplate - The input {} passed validation", inputPath);
-                       }
-               }
        }
 
        public String getPath() {
index 07dabf8..b810e87 100644 (file)
@@ -1,6 +1,7 @@
 package org.openecomp.sdc.toscaparser.api.common;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -13,13 +14,15 @@ public class ExceptionCollector {
 
        //private static boolean isCollecting = false;
        private static ArrayList<String> exceptionStrings = new ArrayList<>();
-       private static ArrayList<String> traceStrings = new ArrayList<>();
+       private static ArrayList<String> exceptionTraceStrings = new ArrayList<>();
+       private static ArrayList<String> warningStrings = new ArrayList<>();
+       private static ArrayList<String> warningTraceStrings = new ArrayList<>();
        private static boolean bWantTrace = true;
 
        /*public static void start() {
                if(exceptionStrings == null) {
                        exceptionStrings = new ArrayList<String>();
-                       traceStrings = new ArrayList<String>();
+                       exceptionTraceStrings = new ArrayList<String>();
                }
                isCollecting = true;
        }*/
@@ -30,7 +33,9 @@ public class ExceptionCollector {
 
        public static void clear() {
                exceptionStrings = new ArrayList<>();
-               traceStrings = new ArrayList<>();
+               exceptionTraceStrings = new ArrayList<>();
+               warningStrings = new ArrayList<>();
+               warningTraceStrings = new ArrayList<>();
        }
 
        public static void appendException(String strExc) { // throws Exception {
@@ -50,28 +55,67 @@ public class ExceptionCollector {
                                sb.append(String.format("  %s(%s:%d)%s",ste[i].getClassName(),ste[i].getFileName(),
                                                                                                ste[i].getLineNumber(),i==ste.length-1?" ":"\n"));
                        }
-                       traceStrings.add(sb.toString());
+                       exceptionTraceStrings.add(sb.toString());
                }
        }
+       
+       public static void appendWarning(String strExc) { // throws Exception {
 
-       public static ArrayList<String> getExceptionReport() {
+               /*if(!isCollecting) {
+                       // throw new Exception("Can't append exception " + strExc);
+                       log.error("ExceptionCollector - appendException - Can't append exception {}", strExc);
+               }*/
+
+               if(!warningStrings.contains(strExc)) {
+                       warningStrings.add(strExc);
+                       // get stack trace
+                       StackTraceElement[] ste =  Thread.currentThread().getStackTrace();
+                       StringBuilder sb = new StringBuilder();
+                       // skip the last 2 (getStackTrace and this)
+                       for(int i=2; i<ste.length; i++) {
+                               sb.append(String.format("  %s(%s:%d)%s",ste[i].getClassName(),ste[i].getFileName(),
+                                                                                               ste[i].getLineNumber(),i==ste.length-1?" ":"\n"));
+                       }
+                       warningTraceStrings.add(sb.toString());
+               }
+       }
+
+       public static List<String> getCriticalsReport() {
+               
+               List<String> res = new ArrayList<>();
                if(exceptionStrings.size() > 0) {
-                       ArrayList<String> report = new ArrayList<>();
                        for(int i=0; i<exceptionStrings.size(); i++) {
-                               report.add(exceptionStrings.get(i));
+                               res.add(exceptionStrings.get(i));
+                               if(bWantTrace) {
+                                       res.add(exceptionTraceStrings.get(i));
+                               }
+                       }
+               }
+               return res;
+       }
+       
+       public static List<String> getWarningsReport() {
+               
+               List<String> res = new ArrayList<>();
+               if(warningStrings.size() > 0) {
+                       for(int i=0; i<warningStrings.size(); i++) {
+                               res.add(warningStrings.get(i));
                                if(bWantTrace) {
-                                       report.add(traceStrings.get(i));
+                                       res.add(warningTraceStrings.get(i));
                                }
                        }
-                       return report;
                }
-               return new ArrayList<>();
+               return res;
        }
        
        public static int errorsCaught() {
                return exceptionStrings.size();
        }
        
+       public static int warningsCaught() {
+               return warningStrings.size();
+       }
+       
        public static void setWantTrace(boolean b) {
                bWantTrace = b;
        }
index 1150e19..5b17b9a 100644 (file)
@@ -86,9 +86,9 @@ public abstract class ScalarUnit {
                        ValidateUtils.strToNum(matcher.group(1));
                        String scalarUnit = _checkUnitInScalarStandardUnits(matcher.group(2));
                        value = matcher.group(1) + " " + scalarUnit;
-                       Object on1 = ValidateUtils.strToNum(matcher.group(1));
-                       Object on2 = SCALAR_UNIT_DICT.get(matcher.group(2)); 
-                       Object on3 = SCALAR_UNIT_DICT.get(unit);
+                       Object on1 = ValidateUtils.strToNum(matcher.group(1)) != null ? ValidateUtils.strToNum(matcher.group(1)) : 0;
+                       Object on2 = SCALAR_UNIT_DICT.get(matcher.group(2)) != null ? SCALAR_UNIT_DICT.get(matcher.group(2)) : 0
+                       Object on3 = SCALAR_UNIT_DICT.get(unit) != null ? SCALAR_UNIT_DICT.get(unit) : 0;
                        
                        Double n1 = new Double(on1.toString());
                        Double n2 = new Double(on2.toString());
index c21bd7b..5fa7547 100644 (file)
@@ -35,11 +35,12 @@ public class Schema {
        public static final String VERSION = "version";
        public static final String PORTDEF = "PortDef";
        public static final String PORTSPEC = "PortSpec"; //??? PortSpec.SHORTNAME
+       public static final String JSON = "json";
 
        public static final String PROPERTY_TYPES[] = {
                INTEGER, STRING, BOOLEAN, FLOAT, RANGE,NUMBER, TIMESTAMP, LIST, MAP,
                SCALAR_UNIT_SIZE, SCALAR_UNIT_FREQUENCY, SCALAR_UNIT_TIME,
-               VERSION, PORTDEF, PORTSPEC};
+               VERSION, PORTDEF, PORTSPEC, JSON};
        
        @SuppressWarnings("unused")
        private static final String SCALAR_UNIT_SIZE_DEFAULT = "B";
index 4dae5eb..0ac842c 100644 (file)
@@ -1,18 +1,74 @@
 package org.openecomp.test;\r
 \r
-import java.util.ArrayList;\r
+import java.io.File;\r
+import java.io.FileWriter;\r
+import java.io.IOException;\r
+import java.text.SimpleDateFormat;\r
 import java.util.Arrays;\r
+import java.util.Date;\r
+import java.util.List;\r
 \r
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;\r
 import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;\r
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;\r
 import org.openecomp.sdc.toscaparser.api.common.ExceptionCollector;\r
+import org.openecomp.sdc.toscaparser.api.parameters.Input;\r
 \r
 public class CsarToscaTester {\r
        public static void main(String[] args) throws Exception {\r
                ClassLoader loader = CsarToscaTester.class.getClassLoader();\r
-               System.out.println("CsarToscaParser - path to CSAR is "+Arrays.toString(args));\r
+               System.out.println("CsarToscaParser - path to CSAR's Directory is " + Arrays.toString(args));\r
                SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();\r
-               factory.getSdcCsarHelper(args[0]);\r
-               ArrayList<String> exceptionReport = ExceptionCollector.getExceptionReport();\r
-               System.out.println("Errors during CSAR parsing are: "+(exceptionReport != null ? exceptionReport.toString() : "none"));\r
+               \r
+               File folder = new File(args[0].toString());\r
+               File[] listOfFiles = folder.listFiles();\r
+               FileWriter fw;\r
+               \r
+               Date now = new Date();\r
+               SimpleDateFormat dateFormat = new SimpleDateFormat("d-MM-y-HH_mm_ss");\r
+               String time = dateFormat.format(now);\r
+               File dir = new File(args[1].toString() + "/csar-reports-" + time);\r
+               dir.mkdir();\r
+               \r
+               \r
+               for (File file : listOfFiles) {\r
+                       if (file.isFile()) {  \r
+                       System.out.println("File " + file.getAbsolutePath());\r
+                       ExceptionCollector.clear();\r
+\r
+                       ISdcCsarHelper csarHelper = factory.getSdcCsarHelper(file.getAbsolutePath());\r
+                       List<NodeTemplate> vflist = csarHelper.getServiceVfList();\r
+                       List<Input> inputs = csarHelper.getServiceInputs();\r
+                       List<String> exceptionReport = ExceptionCollector.getCriticalsReport();\r
+                       System.out.println("CRITICALS during CSAR parsing are: " + (exceptionReport != null ? exceptionReport.toString() : "none"));\r
+                       List<String> warningsReport = ExceptionCollector.getWarningsReport();\r
+                       System.out.println("WARNINGS during CSAR parsing are: " + (warningsReport != null ? warningsReport.toString() : "none"));\r
+                       \r
+                               \r
+                       if (!exceptionReport.isEmpty())  {\r
+                               \r
+                                       try {\r
+                                               fw = new FileWriter(new File(dir + "/critical-" + file.getName() + ".txt"));\r
+                                               for (String exception : exceptionReport) {\r
+                                                       fw.write(exception);\r
+                                                       fw.write("\r\n");\r
+                                               }\r
+                                               fw.close();\r
+                                               \r
+                                               fw = new FileWriter(new File(dir + "/warning-" + file.getName() + ".txt"));\r
+                                               for (String warning : warningsReport) {\r
+                                                       fw.write(warning);\r
+                                                       fw.write("\r\n");\r
+                                               }\r
+                                               fw.close();\r
+                                               \r
+                                               \r
+                                       } catch (IOException ex) {\r
+                                               ex.printStackTrace();\r
+                                       }\r
+                               }\r
+                    }\r
+                       \r
+               }               \r
        }\r
 }\r
index 7cc9022..e1c1802 100644 (file)
@@ -20,6 +20,7 @@ package org.openecomp.sdc.tosca.parser.api;
 
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.openecomp.sdc.toscaparser.api.Group;
@@ -72,7 +73,33 @@ public interface ISdcCsarHelper {
         * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
         */
        public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
-       
+
+       /**
+        * Get any property leaf value for node template by full path separated by #.<br>
+        * For example, for node template with this property:<br><br>
+        *   network_assignments:<br>
+        &nbsp;&nbsp;ecomp_generated_network_assignment: true<br>
+        &nbsp;&nbsp;is_shared_network: false<br>
+        &nbsp;&nbsp;is_external_network: false<br>
+        &nbsp;&nbsp;ipv4_subnet_default_assignments:<br>
+        &nbsp;&nbsp;&nbsp;&nbsp;use_ipv4: true<br>
+        &nbsp;&nbsp;&nbsp;&nbsp;ip_network_address_plan: 1.2.3.4<br>
+        &nbsp;&nbsp;&nbsp;&nbsp;dhcp_enabled: true<br>
+        &nbsp;&nbsp;&nbsp;&nbsp;ip_version: 4<br>
+        &nbsp;&nbsp;&nbsp;&nbsp;cidr_mask: 24<br>
+        &nbsp;&nbsp;&nbsp;&nbsp;min_subnets_count: 1<br>
+        &nbsp;&nbsp;ipv6_subnet_default_assignments:<br>
+        &nbsp;&nbsp;&nbsp;&nbsp;use_ipv6: false<br><br>
+
+        * calling<br>
+        * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br>
+        * will return "false".
+        * @param nodeTemplate - nodeTemplate where the property should be looked up.
+        * @param pathToPropertyLeafValue - the full path of the required property.
+        * @return the leaf value as Object, or null if there's no such property, or it's not a leaf.
+        */
+       public Object getNodeTemplatePropertyAsObject(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
+
        /**
         * Get any property leaf value for a group definition by full path separated by #.
         * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
@@ -82,6 +109,14 @@ public interface ISdcCsarHelper {
         */
        public String getGroupPropertyLeafValue(Group group, String propertyName);
 
+       /**
+        * Get any property leaf value for a group definition by full path separated by #.
+        * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
+        * @param group - group where the property should be looked up.
+        * @param propertyName - the name of the required property.
+        * @return the leaf value as Object, or null if there's no such property, or it's not a leaf.
+        */
+       public Object getGroupPropertyAsObject(Group group, String propertyName);
 
        /**
         * Get all VL node templates of the CSAR service.
@@ -133,7 +168,16 @@ public interface ISdcCsarHelper {
         * @return input leaf value for the service.
         */
        public String getServiceInputLeafValueOfDefault(String inputLeafValuePath);
-       
+
+       /**
+        * Get input leaf value for the CSAR service, by full path separated by #.<br>
+        * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
+        * The expected format is "input_name#default[optionally #rest_of_path]"
+        * @param inputLeafValuePath by full path separated by #.
+        * @return input leaf value for the service as Service.
+        */
+       public Object getServiceInputLeafValueOfDefaultAsObject(String inputLeafValuePath);
+
        /**
         * Get the type name of the CSAR service's substitution mappings element.<br> 
         * 
@@ -247,6 +291,15 @@ public interface ISdcCsarHelper {
         */
        public List<Input> getServiceInputs();
 
+       
 
        public String getConformanceLevel();
+       
+       
+       /**
+        * Get the map of CP-related props from
+        * @param vfc - VFC to look for CP-related props.
+        * @return map of CP node template name to a map of CP-related properties key-value for this CP.
+        */
+       public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc);
 }
index 9280322..b9ce069 100644 (file)
 
 package org.openecomp.sdc.tosca.parser.impl;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.Map.Entry;
-import java.util.Optional;
 import java.util.stream.Collectors;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
+//import org.json.JSONObject;
 import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.openecomp.sdc.tosca.parser.utils.GeneralUtility;
 import org.openecomp.sdc.tosca.parser.utils.SdcToscaUtility;
@@ -46,109 +43,169 @@ import org.openecomp.sdc.toscaparser.api.parameters.Input;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SdcCsarHelperImpl implements ISdcCsarHelper {
-
-       private static final String PATH_DELIMITER = "#";
-       private ToscaTemplate toscaTemplate;
-       private static Logger log = LoggerFactory.getLogger(SdcCsarHelperImpl.class.getName());
-
-       public SdcCsarHelperImpl(ToscaTemplate toscaTemplate) {
-               this.toscaTemplate = toscaTemplate;
-       }
-
-       @Override
-       //Sunny flow  - covered with UT, flat and nested
-       public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String leafValuePath) {
-               if (nodeTemplate == null)  {
-                       log.error("getNodeTemplatePropertyLeafValue - nodeTemplate is null");
-                       return null;
-               }
-               if (GeneralUtility.isEmptyString(leafValuePath))  {
-                       log.error("getNodeTemplatePropertyLeafValue - leafValuePath is null or empty");
-                       return null;
-               }
-               log.debug("getNodeTemplatePropertyLeafValue - nodeTemplate is : {}, leafValuePath is {} ", nodeTemplate, leafValuePath);
-               String[] split = getSplittedPath(leafValuePath);
-               LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
-               log.debug("getNodeTemplatePropertyLeafValue - properties of nodeTemplate are : {}", properties);
-               return processProperties(split, properties);
-       }
-       @Override
-       //Sunny flow - covered with UT
-       public List<NodeTemplate> getServiceVlList() {
-               List<NodeTemplate> serviceVlList = getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), Types.TYPE_VL);
-               log.debug("getServiceVlList - the VL list is {}", serviceVlList);
-               return serviceVlList;
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       public List<NodeTemplate> getServiceVfList() {
-               List<NodeTemplate> serviceVfList = getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), Types.TYPE_VF);
-               log.debug("getServiceVfList - the VF list is {}", serviceVfList);
-               return serviceVfList;
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       public String getMetadataPropertyValue(Metadata metadata, String metadataPropertyName) {
-               if (GeneralUtility.isEmptyString(metadataPropertyName))  {
-                       log.error("getMetadataPropertyValue - the metadataPropertyName is null or empty");
-                       return null;
-               }
-               if (metadata == null)  {
-                       log.error("getMetadataPropertyValue - the metadata is null");
-                       return null;
-               }
-               String metadataPropertyValue = metadata.getValue(metadataPropertyName);
-               log.debug("getMetadataPropertyValue - metadata is {} metadataPropertyName is {} the value is : {}", metadata, metadataPropertyName , metadataPropertyValue);
-               return metadataPropertyValue;
-       }
-
-
-       @Override
-       //Sunny flow - covered with UT
-       public List<NodeTemplate> getServiceNodeTemplatesByType(String nodeType) {
-               if (GeneralUtility.isEmptyString(nodeType)) {
-                       log.error("getServiceNodeTemplatesByType - nodeType - is null or empty");
-                       return new ArrayList<>();
-               }
-
-               List<NodeTemplate> res = new ArrayList<>();
-               List<NodeTemplate> nodeTemplates = toscaTemplate.getNodeTemplates();
-               for (NodeTemplate nodeTemplate : nodeTemplates){
-                       if (nodeType.equals(nodeTemplate.getTypeDefinition().getType())){
-                               res.add(nodeTemplate);
-                       }
-               }
-
-               log.debug("getServiceNodeTemplatesByType - For Node Type : {} -  NodeTemplate list value is: {}", nodeType,  res);
-               return res;
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       public List<NodeTemplate> getVfcListByVf(String vfCustomizationId) {
-               if (GeneralUtility.isEmptyString(vfCustomizationId)) {
-                       log.error("getVfcListByVf - vfCustomizationId - is null or empty");
-                       return new ArrayList<>();
-               }
+import static org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID;
 
-               List<NodeTemplate> serviceVfList = getServiceVfList();
-               NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
-               log.debug("getVfcListByVf - serviceVfList value: {}, vfInstance value: {}", serviceVfList, vfInstance);
-               return getNodeTemplateBySdcType(vfInstance, Types.TYPE_VFC);
-       }
+public class SdcCsarHelperImpl implements ISdcCsarHelper {
 
-       @Override
-       //Sunny flow - covered with UT
-       public List<Group> getVfModulesByVf(String vfCustomizationUuid) {
-               List<NodeTemplate> serviceVfList = getServiceVfList();
-               log.debug("getVfModulesByVf - VF list is {}", serviceVfList);
-               NodeTemplate nodeTemplateByCustomizationUuid = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationUuid);
-               log.debug("getVfModulesByVf - getNodeTemplateByCustomizationUuid is {}, customizationUuid {}", nodeTemplateByCustomizationUuid, vfCustomizationUuid);
-               if (nodeTemplateByCustomizationUuid != null){
-                       /*SubstitutionMappings substitutionMappings = nodeTemplateByCustomizationUuid.getSubstitutionMappings();
+    private static final String PATH_DELIMITER = "#";
+    private static final String PREFIX = "port_";
+    private static final String[] SUFFIX = new String[]{"_network_role_tag", "_ip_requirements", "_subnetpoolid"};
+    private ToscaTemplate toscaTemplate;
+    private static Logger log = LoggerFactory.getLogger(SdcCsarHelperImpl.class.getName());
+
+    public SdcCsarHelperImpl(ToscaTemplate toscaTemplate) {
+        this.toscaTemplate = toscaTemplate;
+    }
+
+    @Override
+    //Sunny flow  - covered with UT, flat and nested
+    public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String leafValuePath) {
+        if (nodeTemplate == null) {
+            log.error("getNodeTemplatePropertyLeafValue - nodeTemplate is null");
+            return null;
+        }
+        if (GeneralUtility.isEmptyString(leafValuePath)) {
+            log.error("getNodeTemplatePropertyLeafValue - leafValuePath is null or empty");
+            return null;
+        }
+        log.debug("getNodeTemplatePropertyLeafValue - nodeTemplate is : {}, leafValuePath is {} ", nodeTemplate, leafValuePath);
+        String[] split = getSplittedPath(leafValuePath);
+        LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
+        log.debug("getNodeTemplatePropertyLeafValue - properties of nodeTemplate are : {}", properties);
+        Object property = processProperties(split, properties);
+        return property == null ? null : String.valueOf(property);
+    }
+
+    @Override
+    public Object getNodeTemplatePropertyAsObject(NodeTemplate nodeTemplate, String leafValuePath) {
+        if (nodeTemplate == null) {
+            log.error("getNodeTemplatePropertyAsObject - nodeTemplate is null");
+            return null;
+        }
+        if (GeneralUtility.isEmptyString(leafValuePath)) {
+            log.error("getNodeTemplatePropertyAsObject - leafValuePath is null or empty");
+            return null;
+        }
+        log.debug("getNodeTemplatePropertyAsObject - nodeTemplate is : {}, leafValuePath is {} ", nodeTemplate, leafValuePath);
+        String[] split = getSplittedPath(leafValuePath);
+        LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
+        log.debug("getNodeTemplatePropertyAsObject - properties of nodeTemplate are : {}", properties);
+        return processProperties(split, properties);
+    }
+
+    public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc) {
+
+        List<String> paths = new ArrayList<>();
+        paths.add("network_role_tag");
+        paths.add("ip_requirements#ip_count_required#count");
+        paths.add("ip_requirements#dhcp_enabled");
+        paths.add("ip_requirements#ip_version");
+        paths.add("subnetpoolid");
+
+        Map<String, Property> props = vfc.getProperties();
+
+        Map<String, Map<String, Object>> cps = new HashMap<>();
+
+        for (Map.Entry<String, Property> entry : props.entrySet()) {
+            String fullCpName = entry.getKey();
+
+            if (fullCpName.startsWith(PREFIX) &&
+                    Arrays.stream(SUFFIX).parallel().anyMatch(fullCpName::endsWith))
+            {
+                //this is CP - get all it's properties according to paths list
+                String cpName = fullCpName.replaceAll("^("+PREFIX+")", "").replaceAll("("+String.join("|", SUFFIX)+")$", "");
+                cps.put(cpName, new HashMap<>());
+                for (String path: paths) {
+                    String fullPathToSearch = PREFIX + cpName + "_" + path;
+                    String value = getNodeTemplatePropertyLeafValue(vfc, fullPathToSearch);
+                    if (value != null) {
+                        value = StringUtils.stripStart(value, "[");
+                        value = StringUtils.stripEnd(value, "]");
+                        cps.get(cpName).put(path, value);
+                    }
+                }
+            }
+        }
+
+        return cps;
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public List<NodeTemplate> getServiceVlList() {
+        List<NodeTemplate> serviceVlList = getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), Types.TYPE_VL);
+        log.debug("getServiceVlList - the VL list is {}", serviceVlList);
+        return serviceVlList;
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public List<NodeTemplate> getServiceVfList() {
+        List<NodeTemplate> serviceVfList = getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), Types.TYPE_VF);
+        log.debug("getServiceVfList - the VF list is {}", serviceVfList);
+        return serviceVfList;
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public String getMetadataPropertyValue(Metadata metadata, String metadataPropertyName) {
+        if (GeneralUtility.isEmptyString(metadataPropertyName)) {
+            log.error("getMetadataPropertyValue - the metadataPropertyName is null or empty");
+            return null;
+        }
+        if (metadata == null) {
+            log.error("getMetadataPropertyValue - the metadata is null");
+            return null;
+        }
+        String metadataPropertyValue = metadata.getValue(metadataPropertyName);
+        log.debug("getMetadataPropertyValue - metadata is {} metadataPropertyName is {} the value is : {}", metadata, metadataPropertyName, metadataPropertyValue);
+        return metadataPropertyValue;
+    }
+
+
+    @Override
+    //Sunny flow - covered with UT
+    public List<NodeTemplate> getServiceNodeTemplatesByType(String nodeType) {
+        if (GeneralUtility.isEmptyString(nodeType)) {
+            log.error("getServiceNodeTemplatesByType - nodeType - is null or empty");
+            return new ArrayList<>();
+        }
+
+        List<NodeTemplate> res = new ArrayList<>();
+        List<NodeTemplate> nodeTemplates = toscaTemplate.getNodeTemplates();
+        for (NodeTemplate nodeTemplate : nodeTemplates) {
+            if (nodeType.equals(nodeTemplate.getTypeDefinition().getType())) {
+                res.add(nodeTemplate);
+            }
+        }
+
+        log.debug("getServiceNodeTemplatesByType - For Node Type : {} -  NodeTemplate list value is: {}", nodeType, res);
+        return res;
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public List<NodeTemplate> getVfcListByVf(String vfCustomizationId) {
+        if (GeneralUtility.isEmptyString(vfCustomizationId)) {
+            log.error("getVfcListByVf - vfCustomizationId - is null or empty");
+            return new ArrayList<>();
+        }
+
+        List<NodeTemplate> serviceVfList = getServiceVfList();
+        NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
+        log.debug("getVfcListByVf - serviceVfList value: {}, vfInstance value: {}", serviceVfList, vfInstance);
+        return getNodeTemplateBySdcType(vfInstance, Types.TYPE_VFC);
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public List<Group> getVfModulesByVf(String vfCustomizationUuid) {
+        List<NodeTemplate> serviceVfList = getServiceVfList();
+        log.debug("getVfModulesByVf - VF list is {}", serviceVfList);
+        NodeTemplate nodeTemplateByCustomizationUuid = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationUuid);
+        log.debug("getVfModulesByVf - getNodeTemplateByCustomizationUuid is {}, customizationUuid {}", nodeTemplateByCustomizationUuid, vfCustomizationUuid);
+        if (nodeTemplateByCustomizationUuid != null) {
+            /*SubstitutionMappings substitutionMappings = nodeTemplateByCustomizationUuid.getSubstitutionMappings();
                        if (substitutionMappings != null){
                                List<Group> groups = substitutionMappings.getGroups();
                                if (groups != null){
@@ -157,255 +214,307 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
                                        return collect;
                                }
                        }*/
-                       String name = nodeTemplateByCustomizationUuid.getName();
-                       String normaliseComponentInstanceName = SdcToscaUtility.normaliseComponentInstanceName(name);
-                       List<Group> serviceLevelGroups = toscaTemplate.getTopologyTemplate().getGroups();
-                       log.debug("getVfModulesByVf - VF node template name {}, normalized name {}. Searching groups on service level starting with VF normalized name...", name, normaliseComponentInstanceName);
-                       if (serviceLevelGroups != null){
-                               List<Group> collect = serviceLevelGroups
-                                               .stream()
-                                               .filter(x -> "org.openecomp.groups.VfModule".equals(x.getTypeDefinition().getType()) && x.getName().startsWith(normaliseComponentInstanceName))
-                                               .collect(Collectors.toList());
-                               log.debug("getVfModulesByVf - VfModules are {}", collect);
-                               return collect;
-                       }
-               }
-               return new ArrayList<>();
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       public String getServiceInputLeafValueOfDefault(String inputLeafValuePath) {
-               if (GeneralUtility.isEmptyString(inputLeafValuePath)) {
-                       log.error("getServiceInputLeafValueOfDefault - inputLeafValuePath is null or empty");
-                       return null;
-               }
-
-               String[] split = getSplittedPath(inputLeafValuePath);
-               if (split.length < 2 || !split[1].equals("default")){
-                       log.error("getServiceInputLeafValue - inputLeafValuePath should be of format <input name>#default[optionally #<rest of path>] ");
-                       return null;
-               }
-
-               List<Input> inputs = toscaTemplate.getInputs();
-               log.debug("getServiceInputLeafValue - the leafValuePath is  {} , the inputs are {}", inputLeafValuePath, inputs);
-               if (inputs != null){
-                       Optional<Input> findFirst = inputs.stream().filter(x -> x.getName().equals(split[0])).findFirst();
-                       if (findFirst.isPresent()){
-                               log.debug("getServiceInputLeafValue - find first item is {}", findFirst.get());
-                               Input input = findFirst.get();
-                               Object current = input.getDefault();
-                               return iterateProcessPath(2, current, split);
-                       }
-               }
-               log.error("getServiceInputLeafValue - value not found");
-               return null;
-       }
-       
-       private String iterateProcessPath(Integer index, Object current, String[] split)  {
-               if (current == null)  {
-                       log.error("iterateProcessPath - this input has no default");
-                       return null;
-               }
-               if (split.length > index)  {
-                       for (int i = index; i < split.length; i++) {
-                               if (current instanceof Map){
-                                       current = ((Map<String, Object>)current).get(split[i]);
-                               } else {
-                                       log.error("iterateProcessPath - found an unexpected leaf where expected to find a complex type");
-                                       return null;
-                               }
-                       }
-               }
-               if (current != null)  {
-                       log.debug("iterateProcessPath - the input default leaf value is {}", String.valueOf(current));
-                       return String.valueOf(current);
-               }
-               log.error("iterateProcessPath - Path not Found");
-               return null;
-       }
-
-       private String[] getSplittedPath(String inputLeafValuePath) {
-               return inputLeafValuePath.split(PATH_DELIMITER);
-       }
-
-
-       @Override
-       //Sunny flow - covered with UT
-       public String getServiceSubstitutionMappingsTypeName() {
-               SubstitutionMappings substitutionMappings = toscaTemplate.getTopologyTemplate().getSubstitutionMappings();
-               if (substitutionMappings == null) {
-                       log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings defined");
-                       return null;
-               }
-               log.debug("getServiceSubstitutionMappingsTypeName - SubstitutionMappings value: {}", substitutionMappings);
-
-               NodeType nodeType = substitutionMappings.getNodeDefinition();
-               if (nodeType == null) {
-                       log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings node defined");
-                       return null;
-               }
-               log.debug("getServiceSubstitutionMappingsTypeName - nodeType value: {}", nodeType);
-
-               return nodeType.getType();
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       public Metadata getServiceMetadata() {
-               return toscaTemplate.getMetaData();
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       public List<Input> getServiceInputs() {
-               return toscaTemplate.getInputs();
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       public String getGroupPropertyLeafValue(Group group, String leafValuePath) {
-               if (group == null) {
-                       log.error("getGroupPropertyLeafValue - group is null");
-                       return null;
-               }
-
-               if (GeneralUtility.isEmptyString(leafValuePath)) {
-                       log.error("getGroupPropertyLeafValue - leafValuePath is null or empty");
-                       return null;
-               }
-
-               String[] split = getSplittedPath(leafValuePath);
-               LinkedHashMap<String,Property> properties = group.getProperties();
-               return processProperties(split, properties);
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       public List<NodeTemplate> getCpListByVf(String vfCustomizationId) {
-               List<NodeTemplate> cpList = new ArrayList<>();
-               if (GeneralUtility.isEmptyString(vfCustomizationId)){
-                       log.error("getCpListByVf vfCustomizationId string is empty");
-                       return cpList;
-               }
-
-               List<NodeTemplate> serviceVfList = getServiceVfList();
-               if (serviceVfList == null || serviceVfList.size() == 0){
-                       log.error("getCpListByVf Vfs not exist for vfCustomizationId {}",vfCustomizationId);
-                       return cpList;
-               }
-               NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
-               log.debug("getCpListByVf vf list is {}", vfInstance);
-               if (vfInstance == null) {
-                       log.debug("getCpListByVf vf list is null");
-                       return cpList;
-               }
-               cpList = getNodeTemplateBySdcType(vfInstance, Types.TYPE_CP);
-               if(cpList == null || cpList.size()==0)
-                       log.debug("getCpListByVf cps not exist for vfCustomizationId {}",vfCustomizationId);
-               return cpList;
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       public List<NodeTemplate> getMembersOfVfModule(NodeTemplate vf, Group serviceLevelVfModule) {
-               if (vf == null) {
-                       log.error("getMembersOfVfModule - vf is null");
-                       return new ArrayList<>();
-               }
-
-               if (serviceLevelVfModule == null || serviceLevelVfModule.getMetadata() == null || serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID) == null) {
-                       log.error("getMembersOfVfModule - vfModule or its metadata is null. Cannot match a VF group based on invariantUuid from missing metadata.");
-                       return new ArrayList<>();
-               }
-               
-               
-               SubstitutionMappings substitutionMappings = vf.getSubMappingToscaTemplate();
-               if (substitutionMappings != null){
-                       List<Group> groups = substitutionMappings.getGroups();
-                       if (groups != null){
-                               Optional<Group> findFirst = groups
-                               .stream()
-                               .filter(x -> (x.getMetadata() != null && serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID).equals(x.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)))).findFirst();
-                               if (findFirst.isPresent()){
-                                       log.debug("getMembersOfVfModule - Found VF level group with vfModuleModelInvariantUUID {}", serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID));
-                                       List<String> members = findFirst.get().getMembers();
-                                       log.debug("getMembersOfVfModule - members section is {}", members);
-                                       if (members != null){
-                                               List<NodeTemplate> collect = substitutionMappings.getNodeTemplates().stream().filter(x -> members.contains(x.getName())).collect(Collectors.toList());
-                                               log.debug("getMembersOfVfModule - Node templates are {}", collect);
-                                               return collect;
-                                       }
-                               }
-                       }
-               }
-               return new ArrayList<>();
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       public List<Pair<NodeTemplate, NodeTemplate>> getNodeTemplatePairsByReqName(
-                       List<NodeTemplate> listOfReqNodeTemplates, List<NodeTemplate> listOfCapNodeTemplates, String reqName) {
-               if (listOfReqNodeTemplates == null || listOfCapNodeTemplates == null || reqName == null){
-                       //TODO error message
-                       return new ArrayList<>();
-               }
-
-               List<Pair<NodeTemplate, NodeTemplate>> pairsList = new ArrayList<>();
-
-               if (listOfReqNodeTemplates != null){
-                       for (NodeTemplate reqNodeTemplate : listOfReqNodeTemplates) {
-                               List<Object> requirements = reqNodeTemplate.getRequirements();
-                               for (Object reqEntry : requirements) {
-                                       LinkedHashMap<String, Object> reqEntryHash = (LinkedHashMap<String, Object>) reqEntry;
-                                       Map<String, Object> reqEntryMap = (Map<String, Object>) reqEntryHash.get(reqName);
-                                       if (reqEntryMap != null){
-                                               Object node = reqEntryMap.get("node");
-                                               if (node != null){
-                                                       String nodeString = (String)node;
-                                                       Optional<NodeTemplate> findFirst = listOfCapNodeTemplates.stream().filter(x -> x.getName().equals(nodeString)).findFirst();
-                                                       if (findFirst.isPresent()){
-                                                               pairsList.add(new ImmutablePair<NodeTemplate, NodeTemplate>(reqNodeTemplate, findFirst.get()));
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-               return pairsList;
-       }
-
-       @Override
-       //Sunny flow - covered with UT
-       //TODO constant strings
-       public List<NodeTemplate> getAllottedResources() {
-               List<NodeTemplate> nodeTemplates = null;
-               nodeTemplates = toscaTemplate.getTopologyTemplate().getNodeTemplates();
-               if (nodeTemplates.isEmpty()) {
-                       log.error("getAllottedResources nodeTemplates not exist");
-               }
-               nodeTemplates = nodeTemplates.stream().filter(
-                               x -> x.getMetaData() != null && x.getMetaData().getValue("category").equals("Allotted Resource"))
-                               .collect(Collectors.toList());
-               if (nodeTemplates.isEmpty()) {
-                       log.debug("getAllottedResources -  allotted resources not exist");
-               } else {
-                       log.debug("getAllottedResources - the allotted resources list is {}", nodeTemplates);
-               }
-
-               return nodeTemplates;
-       }
-       @Override
-       //Sunny flow - covered with UT
-       public String getTypeOfNodeTemplate(NodeTemplate nodeTemplate) {
-               if(nodeTemplate == null){
-
-                       log.error("getTypeOfNodeTemplate nodeTemplate is null");
-                       return null;
-               }
-               log.debug("getTypeOfNodeTemplate node template type is {}",nodeTemplate.getTypeDefinition().getType());
-               return nodeTemplate.getTypeDefinition().getType();
-       }
+            String name = nodeTemplateByCustomizationUuid.getName();
+            String normaliseComponentInstanceName = SdcToscaUtility.normaliseComponentInstanceName(name);
+            List<Group> serviceLevelGroups = toscaTemplate.getTopologyTemplate().getGroups();
+            log.debug("getVfModulesByVf - VF node template name {}, normalized name {}. Searching groups on service level starting with VF normalized name...", name, normaliseComponentInstanceName);
+            if (serviceLevelGroups != null) {
+                List<Group> collect = serviceLevelGroups
+                        .stream()
+                        .filter(x -> "org.openecomp.groups.VfModule".equals(x.getTypeDefinition().getType()) && x.getName().startsWith(normaliseComponentInstanceName))
+                        .collect(Collectors.toList());
+                log.debug("getVfModulesByVf - VfModules are {}", collect);
+                return collect;
+            }
+        }
+        return new ArrayList<>();
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public String getServiceInputLeafValueOfDefault(String inputLeafValuePath) {
+        if (GeneralUtility.isEmptyString(inputLeafValuePath)) {
+            log.error("getServiceInputLeafValueOfDefault - inputLeafValuePath is null or empty");
+            return null;
+        }
+
+        String[] split = getSplittedPath(inputLeafValuePath);
+        if (split.length < 2 || !split[1].equals("default")) {
+            log.error("getServiceInputLeafValue - inputLeafValuePath should be of format <input name>#default[optionally #<rest of path>] ");
+            return null;
+        }
+
+        List<Input> inputs = toscaTemplate.getInputs();
+        log.debug("getServiceInputLeafValue - the leafValuePath is  {} , the inputs are {}", inputLeafValuePath, inputs);
+        if (inputs != null) {
+            Optional<Input> findFirst = inputs.stream().filter(x -> x.getName().equals(split[0])).findFirst();
+            if (findFirst.isPresent()) {
+                log.debug("getServiceInputLeafValue - find first item is {}", findFirst.get());
+                Input input = findFirst.get();
+                Object current = input.getDefault();
+                Object property = iterateProcessPath(2, current, split);
+                return property == null ? null : String.valueOf(property);
+            }
+        }
+        log.error("getServiceInputLeafValue - value not found");
+        return null;
+    }
+
+    @Override
+    public Object getServiceInputLeafValueOfDefaultAsObject(String inputLeafValuePath) {
+        if (GeneralUtility.isEmptyString(inputLeafValuePath)) {
+            log.error("getServiceInputLeafValueOfDefaultAsObject - inputLeafValuePath is null or empty");
+            return null;
+        }
+
+        String[] split = getSplittedPath(inputLeafValuePath);
+        if (split.length < 2 || !split[1].equals("default")) {
+            log.error("getServiceInputLeafValueOfDefaultAsObject - inputLeafValuePath should be of format <input name>#default[optionally #<rest of path>] ");
+            return null;
+        }
+
+        List<Input> inputs = toscaTemplate.getInputs();
+        log.debug("getServiceInputLeafValueOfDefaultAsObject - the leafValuePath is  {} , the inputs are {}", inputLeafValuePath, inputs);
+        if (inputs != null) {
+            Optional<Input> findFirst = inputs.stream().filter(x -> x.getName().equals(split[0])).findFirst();
+            if (findFirst.isPresent()) {
+                log.debug("getServiceInputLeafValueOfDefaultAsObject - find first item is {}", findFirst.get());
+                Input input = findFirst.get();
+                Object current = input.getDefault();
+                return iterateProcessPath(2, current, split);
+            }
+        }
+        log.error("getServiceInputLeafValueOfDefaultAsObject - value not found");
+        return null;
+    }
+
+    private Object iterateProcessPath(Integer index, Object current, String[] split) {
+        if (current == null) {
+            log.error("iterateProcessPath - this input has no default");
+            return null;
+        }
+        if (split.length > index) {
+            for (int i = index; i < split.length; i++) {
+                if (current instanceof Map) {
+                    current = ((Map<String, Object>) current).get(split[i]);
+                } else if (current instanceof List) {
+                    current = ((List) current).get(0);
+                    i--;
+                }
+                 else {
+                        log.error("iterateProcessPath - found an unexpected leaf where expected to find a complex type");
+                        return null;
+                }
+            }
+        }
+        if (current != null) {
+            log.debug("iterateProcessPath - the input default leaf value is {}", String.valueOf(current));
+            return current;
+        }
+        log.error("iterateProcessPath - Path not Found");
+        return null;
+    }
+
+    private String[] getSplittedPath(String inputLeafValuePath) {
+        return inputLeafValuePath.split(PATH_DELIMITER);
+    }
+
+
+    @Override
+    //Sunny flow - covered with UT
+    public String getServiceSubstitutionMappingsTypeName() {
+        SubstitutionMappings substitutionMappings = toscaTemplate.getTopologyTemplate().getSubstitutionMappings();
+        if (substitutionMappings == null) {
+            log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings defined");
+            return null;
+        }
+        log.debug("getServiceSubstitutionMappingsTypeName - SubstitutionMappings value: {}", substitutionMappings);
+
+        NodeType nodeType = substitutionMappings.getNodeDefinition();
+        if (nodeType == null) {
+            log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings node defined");
+            return null;
+        }
+        log.debug("getServiceSubstitutionMappingsTypeName - nodeType value: {}", nodeType);
+
+        return nodeType.getType();
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public Metadata getServiceMetadata() {
+        return toscaTemplate.getMetaData();
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public List<Input> getServiceInputs() {
+        return toscaTemplate.getInputs();
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public String getGroupPropertyLeafValue(Group group, String leafValuePath) {
+        if (group == null) {
+            log.error("getGroupPropertyLeafValue - group is null");
+            return null;
+        }
+
+        if (GeneralUtility.isEmptyString(leafValuePath)) {
+            log.error("getGroupPropertyLeafValue - leafValuePath is null or empty");
+            return null;
+        }
+
+        String[] split = getSplittedPath(leafValuePath);
+        LinkedHashMap<String, Property> properties = group.getProperties();
+        Object property = processProperties(split, properties);
+        return property == null ? null : String.valueOf(property);
+    }
+
+    @Override
+    public Object getGroupPropertyAsObject(Group group, String leafValuePath) {
+        if (group == null) {
+            log.error("getGroupPropertyAsObject - group is null");
+            return null;
+        }
+
+        if (GeneralUtility.isEmptyString(leafValuePath)) {
+            log.error("getGroupPropertyAsObject - leafValuePath is null or empty");
+            return null;
+        }
+
+        String[] split = getSplittedPath(leafValuePath);
+        LinkedHashMap<String, Property> properties = group.getProperties();
+        return processProperties(split, properties);
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public List<NodeTemplate> getCpListByVf(String vfCustomizationId) {
+        List<NodeTemplate> cpList = new ArrayList<>();
+        if (GeneralUtility.isEmptyString(vfCustomizationId)) {
+            log.error("getCpListByVf vfCustomizationId string is empty");
+            return cpList;
+        }
+
+        List<NodeTemplate> serviceVfList = getServiceVfList();
+        if (serviceVfList == null || serviceVfList.size() == 0) {
+            log.error("getCpListByVf Vfs not exist for vfCustomizationId {}", vfCustomizationId);
+            return cpList;
+        }
+        NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
+        log.debug("getCpListByVf vf list is {}", vfInstance);
+        if (vfInstance == null) {
+            log.debug("getCpListByVf vf list is null");
+            return cpList;
+        }
+        cpList = getNodeTemplateBySdcType(vfInstance, Types.TYPE_CP);
+        if (cpList == null || cpList.size() == 0)
+            log.debug("getCpListByVf cps not exist for vfCustomizationId {}", vfCustomizationId);
+        return cpList;
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public List<NodeTemplate> getMembersOfVfModule(NodeTemplate vf, Group serviceLevelVfModule) {
+        if (vf == null) {
+            log.error("getMembersOfVfModule - vf is null");
+            return new ArrayList<>();
+        }
+
+        if (serviceLevelVfModule == null || serviceLevelVfModule.getMetadata() == null || serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID) == null) {
+            log.error("getMembersOfVfModule - vfModule or its metadata is null. Cannot match a VF group based on invariantUuid from missing metadata.");
+            return new ArrayList<>();
+        }
+
+
+        SubstitutionMappings substitutionMappings = vf.getSubMappingToscaTemplate();
+        if (substitutionMappings != null) {
+            List<Group> groups = substitutionMappings.getGroups();
+            if (groups != null) {
+                Optional<Group> findFirst = groups
+                        .stream()
+                        .filter(x -> (x.getMetadata() != null && serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID).equals(x.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)))).findFirst();
+                if (findFirst.isPresent()) {
+                    log.debug("getMembersOfVfModule - Found VF level group with vfModuleModelInvariantUUID {}", serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID));
+                    List<String> members = findFirst.get().getMembers();
+                    log.debug("getMembersOfVfModule - members section is {}", members);
+                    if (members != null) {
+                        List<NodeTemplate> collect = substitutionMappings.getNodeTemplates().stream().filter(x -> members.contains(x.getName())).collect(Collectors.toList());
+                        log.debug("getMembersOfVfModule - Node templates are {}", collect);
+                        return collect;
+                    }
+                }
+            }
+        }
+        return new ArrayList<>();
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public List<Pair<NodeTemplate, NodeTemplate>> getNodeTemplatePairsByReqName(
+            List<NodeTemplate> listOfReqNodeTemplates, List<NodeTemplate> listOfCapNodeTemplates, String reqName) {
+        if (listOfReqNodeTemplates == null || listOfCapNodeTemplates == null || reqName == null) {
+            //TODO error message
+            return new ArrayList<>();
+        }
+
+        List<Pair<NodeTemplate, NodeTemplate>> pairsList = new ArrayList<>();
+
+        if (listOfReqNodeTemplates != null) {
+            for (NodeTemplate reqNodeTemplate : listOfReqNodeTemplates) {
+                List<Object> requirements = reqNodeTemplate.getRequirements();
+                for (Object reqEntry : requirements) {
+                    LinkedHashMap<String, Object> reqEntryHash = (LinkedHashMap<String, Object>) reqEntry;
+                    Map<String, Object> reqEntryMap = (Map<String, Object>) reqEntryHash.get(reqName);
+                    if (reqEntryMap != null) {
+                        Object node = reqEntryMap.get("node");
+                        if (node != null) {
+                            String nodeString = (String) node;
+                            Optional<NodeTemplate> findFirst = listOfCapNodeTemplates.stream().filter(x -> x.getName().equals(nodeString)).findFirst();
+                            if (findFirst.isPresent()) {
+                                pairsList.add(new ImmutablePair<NodeTemplate, NodeTemplate>(reqNodeTemplate, findFirst.get()));
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return pairsList;
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    //TODO constant strings
+    public List<NodeTemplate> getAllottedResources() {
+        List<NodeTemplate> nodeTemplates = null;
+        nodeTemplates = toscaTemplate.getTopologyTemplate().getNodeTemplates();
+        if (nodeTemplates.isEmpty()) {
+            log.error("getAllottedResources nodeTemplates not exist");
+        }
+        nodeTemplates = nodeTemplates.stream().filter(
+                x -> x.getMetaData() != null && x.getMetaData().getValue("category").equals("Allotted Resource"))
+                .collect(Collectors.toList());
+        if (nodeTemplates.isEmpty()) {
+            log.debug("getAllottedResources -  allotted resources not exist");
+        } else {
+            log.debug("getAllottedResources - the allotted resources list is {}", nodeTemplates);
+        }
+
+        return nodeTemplates;
+    }
+
+    @Override
+    //Sunny flow - covered with UT
+    public String getTypeOfNodeTemplate(NodeTemplate nodeTemplate) {
+        if (nodeTemplate == null) {
+
+            log.error("getTypeOfNodeTemplate nodeTemplate is null");
+            return null;
+        }
+        log.debug("getTypeOfNodeTemplate node template type is {}", nodeTemplate.getTypeDefinition().getType());
+        return nodeTemplate.getTypeDefinition().getType();
+    }
 
        @Override
        public String getConformanceLevel() {
@@ -426,69 +535,69 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
                }
        }
 
-       /************************************* helper functions ***********************************/
-       private List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate nodeTemplate, String sdcType){
-               if (nodeTemplate == null)  {
-                       log.error("getNodeTemplateBySdcType - nodeTemplate is null or empty");
-                       return new ArrayList<>();
-               }
-
-               if (GeneralUtility.isEmptyString(sdcType))  {
-                       log.error("getNodeTemplateBySdcType - sdcType is null or empty");
-                       return new ArrayList<>();
-               }
-
-               SubstitutionMappings substitutionMappings = nodeTemplate.getSubMappingToscaTemplate();
-
-               if (substitutionMappings != null) {
-                       List<NodeTemplate> nodeTemplates = substitutionMappings.getNodeTemplates();
-                       if (nodeTemplates != null && nodeTemplates.size() > 0)
-                               return nodeTemplates.stream().filter(x -> (x.getMetaData() != null && sdcType.equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(Collectors.toList());
-                       else
-                               log.debug("getNodeTemplateBySdcType - SubstitutionMappings' node Templates not exist");
-               } else
-                       log.debug("getNodeTemplateBySdcType - SubstitutionMappings not exist");
-
-               return new ArrayList<>();
-       }
-
-       private List<NodeTemplate> getNodeTemplateBySdcType(TopologyTemplate topologyTemplate, String sdcType){
-               if (GeneralUtility.isEmptyString(sdcType))  {
-                       log.error("getNodeTemplateBySdcType - sdcType is null or empty");
-                       return new ArrayList<>();
-               }
-
-               if (topologyTemplate == null) {
-                       log.error("getNodeTemplateBySdcType - topologyTemplate is null");
-                       return new ArrayList<>();
-               }
-
-               List<NodeTemplate> nodeTemplates = topologyTemplate.getNodeTemplates();
-
-               if (nodeTemplates != null && nodeTemplates.size() > 0)
-                       return nodeTemplates.stream().filter(x -> (x.getMetaData() != null && sdcType.equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(Collectors.toList());
-
-               log.debug("getNodeTemplateBySdcType - topologyTemplate's nodeTemplates not exist");
-               return new ArrayList<>();
-       }
-
-       //Assumed to be unique property for the list
-       private NodeTemplate getNodeTemplateByCustomizationUuid(List<NodeTemplate> nodeTemplates, String customizationId){
-               log.debug("getNodeTemplateByCustomizationUuid - nodeTemplates {}, customizationId {}", nodeTemplates, customizationId);
-               Optional<NodeTemplate> findFirst = nodeTemplates.stream().filter(x -> (x.getMetaData() != null && customizationId.equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)))).findFirst();
-               return findFirst.isPresent() ? findFirst.get() : null;
-       }
-
-       private String processProperties(String[] split, LinkedHashMap<String, Property> properties) {
-               log.debug("processProperties - the leafValuePath is  {} , the properties are {}", Arrays.toString(split), properties.toString());
-               Optional<Entry<String, Property>> findFirst = properties.entrySet().stream().filter(x -> x.getKey().equals(split[0])).findFirst();
-               if (findFirst.isPresent()){
-                       log.debug("processProperties - find first item is {}", findFirst.get());
-                       Property property = findFirst.get().getValue();
-                       Object current = property.getValue();
-                       return iterateProcessPath(1, current, split);
-               }
-               log.error("processProperties - Dont find property");
-               return null;
-       }
+    /************************************* helper functions ***********************************/
+    private List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate nodeTemplate, String sdcType) {
+        if (nodeTemplate == null) {
+            log.error("getNodeTemplateBySdcType - nodeTemplate is null or empty");
+            return new ArrayList<>();
+        }
+
+        if (GeneralUtility.isEmptyString(sdcType)) {
+            log.error("getNodeTemplateBySdcType - sdcType is null or empty");
+            return new ArrayList<>();
+        }
+
+        SubstitutionMappings substitutionMappings = nodeTemplate.getSubMappingToscaTemplate();
+
+        if (substitutionMappings != null) {
+            List<NodeTemplate> nodeTemplates = substitutionMappings.getNodeTemplates();
+            if (nodeTemplates != null && nodeTemplates.size() > 0)
+                return nodeTemplates.stream().filter(x -> (x.getMetaData() != null && sdcType.equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(Collectors.toList());
+            else
+                log.debug("getNodeTemplateBySdcType - SubstitutionMappings' node Templates not exist");
+        } else
+            log.debug("getNodeTemplateBySdcType - SubstitutionMappings not exist");
+
+        return new ArrayList<>();
+    }
+
+    private List<NodeTemplate> getNodeTemplateBySdcType(TopologyTemplate topologyTemplate, String sdcType) {
+        if (GeneralUtility.isEmptyString(sdcType)) {
+            log.error("getNodeTemplateBySdcType - sdcType is null or empty");
+            return new ArrayList<>();
+        }
+
+        if (topologyTemplate == null) {
+            log.error("getNodeTemplateBySdcType - topologyTemplate is null");
+            return new ArrayList<>();
+        }
+
+        List<NodeTemplate> nodeTemplates = topologyTemplate.getNodeTemplates();
+
+        if (nodeTemplates != null && nodeTemplates.size() > 0)
+            return nodeTemplates.stream().filter(x -> (x.getMetaData() != null && sdcType.equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(Collectors.toList());
+
+        log.debug("getNodeTemplateBySdcType - topologyTemplate's nodeTemplates not exist");
+        return new ArrayList<>();
+    }
+
+    //Assumed to be unique property for the list
+    private NodeTemplate getNodeTemplateByCustomizationUuid(List<NodeTemplate> nodeTemplates, String customizationId) {
+        log.debug("getNodeTemplateByCustomizationUuid - nodeTemplates {}, customizationId {}", nodeTemplates, customizationId);
+        Optional<NodeTemplate> findFirst = nodeTemplates.stream().filter(x -> (x.getMetaData() != null && customizationId.equals(x.getMetaData().getValue(PROPERTY_NAME_CUSTOMIZATIONUUID)))).findFirst();
+        return findFirst.isPresent() ? findFirst.get() : null;
+    }
+
+    private Object processProperties(String[] split, LinkedHashMap<String, Property> properties) {
+        log.debug("processProperties - the leafValuePath is  {} , the properties are {}", Arrays.toString(split), properties.toString());
+        Optional<Entry<String, Property>> findFirst = properties.entrySet().stream().filter(x -> x.getKey().equals(split[0])).findFirst();
+        if (findFirst.isPresent()) {
+            log.debug("processProperties - find first item is {}", findFirst.get());
+            Property property = findFirst.get().getValue();
+            Object current = property.getValue();
+            return iterateProcessPath(1, current, split);
+        }
+        log.error("processProperties - property not found");
+        return null;
+    }
 }
index 373ff97..0eb58f8 100644 (file)
@@ -1,6 +1,7 @@
 package org.openecomp.sdc.impl;
 
 import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -8,12 +9,13 @@ import java.util.List;
 import java.util.Map;
 
 import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
 import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
-import org.testng.ITestContext;
+import org.openecomp.sdc.toscaparser.api.common.ExceptionCollector;
+import org.openecomp.sdc.toscaparser.api.common.JToscaException;
 import org.testng.annotations.AfterMethod;
-import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.BeforeSuite;
 
 public abstract class BasicTest {
 
@@ -22,35 +24,18 @@ public abstract class BasicTest {
     static ISdcCsarHelper rainyCsarHelperSingleVf;
     static ISdcCsarHelper rainyCsarHelperMultiVfs;
     static ISdcCsarHelper fdntCsarHelper;
+    static ISdcCsarHelper complexCps;
     static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
-    @BeforeSuite
-    public static void init(ITestContext context) throws Exception {
+    
+    @BeforeClass
+    public static void init() throws SdcToscaParserException, JToscaException, IOException {
 
         factory = SdcToscaParserFactory.getInstance();
-        long startTime = System.currentTimeMillis();
-        long estimatedTime = System.currentTimeMillis() - startTime;
-        System.out.println("Time to init factory " + estimatedTime);
-
-        String fileStr1 = BasicTest.class.getClassLoader().getResource("csars/service-ServiceFdnt-with-allotted.csar").getFile();
-        File file1 = new File(fileStr1);
-        startTime = System.currentTimeMillis();
-
-        fdntCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
-
-        estimatedTime = System.currentTimeMillis() - startTime;
-        System.out.println("init CSAR Execution time: " + estimatedTime);
-
-        String fileStr2 = BasicTest.class.getClassLoader().getResource("csars/service-ServiceFdnt-csar-rainy.csar").getFile();
-        File file2 = new File(fileStr2);
-        rainyCsarHelperMultiVfs = factory.getSdcCsarHelper(file2.getAbsolutePath());
-
-        String fileStr3 = BasicTest.class.getClassLoader().getResource("csars/service-ServiceFdnt-csar.csar").getFile();
-        File file3 = new File(fileStr3);
-        rainyCsarHelperSingleVf = factory.getSdcCsarHelper(file3.getAbsolutePath());
-        
-        /* Objects for QA Validation Tests */
-        
-       fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
+        fdntCsarHelper = getCsarHelper("csars/service-ServiceFdnt-with-allotted.csar");
+        rainyCsarHelperMultiVfs = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar");
+        rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar");
+        complexCps = getCsarHelper("csars/1service-ServiceWithPorts.csar");
+        fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
                {
                        HashMap<String, List<String>> FDNT ;
                        
@@ -106,18 +91,27 @@ public abstract class BasicTest {
                                        "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
                                        "dnt_fw_rsg_si_1.feature"));
                        
+                       
                        put("FDNT", FDNT);                      
                }
        };
     };
 
-    @AfterSuite
-    public static void after(){
-        long startTime = System.currentTimeMillis();
-        long estimatedTime = System.currentTimeMillis() - startTime;
-        System.out.println("close Execution time: "+estimatedTime);
-    };
-
+       private static ISdcCsarHelper getCsarHelper(String path) throws JToscaException, IOException, SdcToscaParserException {
+               System.out.println("Parsing CSAR "+path+"...");
+               String fileStr1 = BasicTest.class.getClassLoader().getResource(path).getFile();
+        File file1 = new File(fileStr1);
+        ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
+        List<String> exceptionReport = ExceptionCollector.getCriticalsReport();
+               if (!exceptionReport.isEmpty()){
+               System.out.println("TOSCA Errors found in CSAR - failing the tests...");
+               System.out.println(exceptionReport.toString());
+               ExceptionCollector.clear();
+               //throw new SdcToscaParserException("CSAR didn't pass validation");
+        }
+               return sdcCsarHelper;
+       }
+    
     @BeforeMethod
     public void setupTest(Method method) {
         System.out.println("#### Starting Test " + method.getName() + " ###########");
index 706c864..58e967a 100644 (file)
@@ -5,6 +5,7 @@ import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
 import org.openecomp.sdc.toscaparser.api.Group;
 import org.openecomp.sdc.toscaparser.api.elements.Metadata;
 
+import java.util.Arrays;
 import java.util.List;
 
 import static org.testng.Assert.*;
@@ -96,4 +97,13 @@ public class ToscaParserGroupTest extends BasicTest{
     }
     //endregion
 
+    //region getGroupPropertyAsObject
+    @Test
+    public void testGetGroupPropertyAsObject() {
+        List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+        Object volumeGroup = fdntCsarHelper.getGroupPropertyAsObject(vfModulesByVf.get(0), "volume_group");
+        assertEquals(false, volumeGroup);
+    }
+    //getGroupPropertyAsObject
+
 }
index 9a78ed5..c9215a2 100644 (file)
@@ -6,6 +6,7 @@ import static org.testng.Assert.assertNull;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.testng.annotations.Test;
@@ -304,4 +305,30 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
        }
        //endregion
 
+       //region getCpPropertiesFromVfc
+       @Test
+       public void testGetCpPropertiesFromVfc() {
+               List<NodeTemplate> vfcs = complexCps.getVfcListByVf(VF_CUSTOMIZATION_UUID);
+               Map<String, Map<String, Object>> cps = complexCps.getCpPropertiesFromVfc(vfcs.get(0));
+
+               assertEquals("1", cps.get("port_fe1_sigtran").get("ip_requirements#ip_count_required#count"));
+               assertEquals("true", cps.get("port_fe1_sigtran").get("ip_requirements#dhcp_enabled"));
+               assertEquals("4", cps.get("port_fe1_sigtran").get("ip_requirements#ip_version"));
+
+               assertEquals("2", cps.get("port_fe_cluster").get("ip_requirements#ip_count_required#count"));
+               assertEquals("true", cps.get("port_fe_cluster").get("ip_requirements#dhcp_enabled"));
+               assertEquals("4", cps.get("port_fe_cluster").get("ip_requirements#ip_version"));
+       }
+       //endregion
+
+       //region getNodeTemplatePropertyAsObject
+       @Test
+       public void testGetNodeTemplatePropertyAsObject() {
+               List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+               assertEquals("2", fdntCsarHelper.getNodeTemplatePropertyAsObject(serviceVfList.get(0), "availability_zone_max_count"));
+               assertEquals(3, fdntCsarHelper.getNodeTemplatePropertyAsObject(serviceVfList.get(0), "max_instances"));
+               assertEquals("some code", fdntCsarHelper.getNodeTemplatePropertyAsObject(serviceVfList.get(0), "nf_naming_code"));
+       }
+       //endregion
+
 }
index d357d21..0599dcc 100644 (file)
@@ -47,4 +47,11 @@ public class ToscaParserServiceInputTest extends BasicTest {
     }
     //endregion
 
+    //region getServiceInputLeafValueOfDefaultAsObject
+    @Test
+    public void testGetServiceInputLeafValueOfDefaultAsObject() {
+        Object serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default");
+        assertEquals("test service naming", serviceInputLeafValue);
+    }
+    //endregion
 }
diff --git a/sdc-tosca-parser/src/test/resources/csars/1service-ServiceWithPorts.csar b/sdc-tosca-parser/src/test/resources/csars/1service-ServiceWithPorts.csar
new file mode 100644 (file)
index 0000000..fa6577b
Binary files /dev/null and b/sdc-tosca-parser/src/test/resources/csars/1service-ServiceWithPorts.csar differ