summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml4
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java73
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java121
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcTypes.java2
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java2
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java35
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java21
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java97
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java154
-rw-r--r--src/test/resources/csars/service-sunny-flow.csarbin45194 -> 45199 bytes
10 files changed, 394 insertions, 115 deletions
diff --git a/pom.xml b/pom.xml
index 280ef10..3ccca61 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
<artifactId>sdc-tosca</artifactId>
<name>SDC Tosca Parser</name>
<description>SDC Tosca Parser JAR file for use by consumers</description>
- <version>1.1.34-SNAPSHOT</version>
+ <version>1.1.50-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
@@ -97,7 +97,7 @@
<dependency>
<groupId>org.openecomp.sdc.jtosca</groupId>
<artifactId>jtosca</artifactId>
- <version>1.1.3-SNAPSHOT</version>
+ <version>1.1.10-SNAPSHOT</version>
</dependency>
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java b/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
index 06a66c6..df9e47d 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
@@ -25,8 +25,7 @@ import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.sdc.tosca.parser.impl.FilterType;
import org.openecomp.sdc.tosca.parser.impl.SdcTypes;
-import org.openecomp.sdc.toscaparser.api.Group;
-import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.*;
import org.openecomp.sdc.toscaparser.api.elements.Metadata;
import org.openecomp.sdc.toscaparser.api.parameters.Input;
@@ -203,18 +202,30 @@ public interface ISdcCsarHelper {
public String getServiceSubstitutionMappingsTypeName();
/**
- * Get the CSAR service metadata
- * @return - the service metadata object.
+ * Get service Metadata object.<br>
+ * This object represents the "metadata" section of a CSAR service.
+ * @return - the service Metadata object.
*/
public Metadata getServiceMetadata();
/**
* Get the CSAR service metadata as map.
* @return - the service metadata object as Map.
+ * @deprecated This function is deprecated since its not tosca compliant. <br>
+ * Tosca defines the Metadata section as map of string (not map of object).<br>
+ * This function is targeted to be removed as part of 1802.<br>
+ * Please use {@link #getServiceMetadataAllProperties() getServiceMetadataAllProperties()}.
*/
+ @Deprecated
public Map<String, Object> getServiceMetadataProperties();
/**
+ * Get the CSAR service metadata as map
+ * @return - the service metadata object as Map
+ */
+ public Map<String, String> getServiceMetadataAllProperties();
+
+ /**
* Get all VFC node templates from a specified VF.
* @param vfCustomizationId - customizationUuid of the VF node template.
* @return all VFC node templates from a specified VF
@@ -326,7 +337,8 @@ public interface ISdcCsarHelper {
* port_fe_oam={ip_requirements#ip_count_required#count=2, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4, subnetpoolid="subnet_2", network_role_tag="Mobility_OAM_protected"}}<br><br>
* @param vfc - VFC node template to look for CP-related props.
* @return map <b>CP node template name</b> to a map of <b>full path to a property on this CP</b> - <b> value of this property on this CP</b>.
- * @deprecated This function is deprecated since its flattened form doesn't provide solution for cp properties of type List.
+ * @deprecated This function is deprecated since its flattened form doesn't provide solution for cp properties of type List.
+ * Will be removed in 1802.
*/
@Deprecated
public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc);
@@ -367,9 +379,9 @@ public interface ISdcCsarHelper {
public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType);
/**
- * Get all node templates by sdcType for this CSAR service.
+ * Get all node templates by SDC type enum for this CSAR service.
*
- * @param sdcType - the SDC type of the node.
+ * @param sdcType - the SDC type of the node (for example, CP, VF...).
* @return service node templates of this SDC type.
*/
public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes sdcType);
@@ -394,4 +406,49 @@ public interface ISdcCsarHelper {
* @return return list of children node templates for node template.
*/
public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate nodeTemplate);
-}
+
+ /**
+ * Get node template on service level by node template name.
+ * @param nodeName - the name of the node template.
+ * @return service-level node template with this name, or null if no such node template was found.
+ */
+ public NodeTemplate getServiceNodeTemplateByNodeName(String nodeName);
+
+ /**
+ * Get node template Metadata object.<br>
+ * This object represents the "metadata" section of node template.
+ * @param nt - Node template to get its Metadata object.
+ * @return Metadata for this node template, or null if not found.
+ */
+ public Metadata getNodeTemplateMetadata(NodeTemplate nt);
+
+ /**
+ * Get CapabilityAssignments object for this node template.<br>
+ * This should be an entry point function for working with capability assignments of node template.<br>
+ * This object allows filtering capability assignments objects.<br>
+ * @param nt - Node Template to get its capability assignments.
+ * @return CapabilitiesAssignments that contains list of capability assignments for the node template.<br>
+ * If none found, an empty list will be returned.
+ */
+ public CapabilityAssignments getCapabilitiesOf(NodeTemplate nt);
+
+ /**
+ * Get RequirementAssignments object for this node template.<br>
+ * This should be an entry point function for working with requirement assignments of node template.<br>
+ * This object allows filtering requirement assignments objects.<br>
+ * @param nt - Node Template to get its requirement assignments.
+ * @return RequirementAssignments that contains list of requirement assignments for the node template.
+ * If none found, an empty list will be returned.
+ */
+ public RequirementAssignments getRequirementsOf(NodeTemplate nt);
+
+ /**
+ * Get any property leaf value for capability by full path separated by #.
+ * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a capability assignment.
+ * @param capability - capability assignment where the property should be looked up.
+ * @param pathToPropertyLeafValue - the full path of the required property.
+ * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
+ */
+ public String getCapabilityPropertyLeafValue(CapabilityAssignment capability, String pathToPropertyLeafValue);
+
+} \ No newline at end of file
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
index bfbbeee..c320f63 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -27,14 +27,11 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.toscaparser.api.CapabilityAssignments;
import org.openecomp.sdc.tosca.parser.utils.GeneralUtility;
+import org.openecomp.sdc.toscaparser.api.RequirementAssignments;
import org.openecomp.sdc.tosca.parser.utils.SdcToscaUtility;
-import org.openecomp.sdc.toscaparser.api.Group;
-import org.openecomp.sdc.toscaparser.api.NodeTemplate;
-import org.openecomp.sdc.toscaparser.api.Property;
-import org.openecomp.sdc.toscaparser.api.SubstitutionMappings;
-import org.openecomp.sdc.toscaparser.api.TopologyTemplate;
-import org.openecomp.sdc.toscaparser.api.ToscaTemplate;
+import org.openecomp.sdc.toscaparser.api.*;
import org.openecomp.sdc.toscaparser.api.elements.Metadata;
import org.openecomp.sdc.toscaparser.api.elements.NodeType;
import org.openecomp.sdc.toscaparser.api.functions.Function;
@@ -398,10 +395,18 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
@Override
//Sunny flow - covered with UT
public Map<String, Object> getServiceMetadataProperties() {
- if (toscaTemplate.getMetaData()==null){
+ if (toscaTemplate.getMetaData() == null){
return null;
}
- return toscaTemplate.getMetaData().getPropertyMap();
+ return new HashMap<>(toscaTemplate.getMetaData().getAllProperties());
+ }
+
+ @Override
+ public Map<String, String> getServiceMetadataAllProperties() {
+ if (toscaTemplate.getMetaData() == null){
+ return null;
+ }
+ return toscaTemplate.getMetaData().getAllProperties();
}
@Override
@@ -509,32 +514,37 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
@SuppressWarnings("unchecked")
public List<Pair<NodeTemplate, NodeTemplate>> getNodeTemplatePairsByReqName(
List<NodeTemplate> listOfReqNodeTemplates, List<NodeTemplate> listOfCapNodeTemplates, String reqName) {
- if (listOfReqNodeTemplates == null || listOfCapNodeTemplates == null || reqName == null) {
- //TODO error message
+
+ if (listOfReqNodeTemplates == null) {
+ log.error("getNodeTemplatePairsByReqName - listOfReqNodeTemplates is null");
+ return new ArrayList<>();
+ }
+
+ if (listOfCapNodeTemplates == null) {
+ log.error("getNodeTemplatePairsByReqName - listOfCapNodeTemplates is null");
+ return new ArrayList<>();
+ }
+
+ if (GeneralUtility.isEmptyString(reqName)) {
+ log.error("getNodeTemplatePairsByReqName - reqName is null or empty");
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()));
- }
- }
+ for (NodeTemplate reqNodeTemplate : listOfReqNodeTemplates) {
+ List<RequirementAssignment> requirements = reqNodeTemplate.getRequirements().getRequirementsByName(reqName).getAll();
+ for (RequirementAssignment reqEntry : requirements) {
+ String node = reqEntry.getNodeTemplateName();
+ if (node != null) {
+ Optional<NodeTemplate> findFirst = listOfCapNodeTemplates.stream().filter(x -> x.getName().equals(node)).findFirst();
+ if (findFirst.isPresent()) {
+ pairsList.add(new ImmutablePair<NodeTemplate, NodeTemplate>(reqNodeTemplate, findFirst.get()));
}
}
}
}
+
return pairsList;
}
@@ -729,6 +739,67 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return new ArrayList<>();
}
+ @Override
+ public NodeTemplate getServiceNodeTemplateByNodeName(String nodeName) {
+ if (GeneralUtility.isEmptyString(nodeName)) {
+ log.error("getServiceNodeTemplateByNodeName - nodeName - is null or empty");
+ return null;
+ }
+
+ List<NodeTemplate> nodeTemplates = getServiceNodeTemplates();
+ Optional<NodeTemplate> findFirst = nodeTemplates.stream().filter(nt -> nt.getName().equals(nodeName)).findFirst();
+
+ return findFirst.isPresent() ? findFirst.get() : null;
+ }
+
+ @Override
+ public Metadata getNodeTemplateMetadata(NodeTemplate nt) {
+ if (nt == null) {
+ log.error("getNodeTemplateMetadata - nt (node template) - is null");
+ return null;
+ }
+
+ return nt.getMetaData();
+ }
+
+ @Override
+ public CapabilityAssignments getCapabilitiesOf(NodeTemplate nt) {
+ if (nt == null) {
+ log.error("getCapabilitiesOf - nt (node template) - is null");
+ return null;
+ }
+
+ return nt.getCapabilities();
+ }
+
+ @Override
+ public RequirementAssignments getRequirementsOf(NodeTemplate nt) {
+ if (nt == null) {
+ log.error("getRequirementsOf - nt (node template) - is null");
+ return null;
+ }
+
+ return nt.getRequirements();
+ }
+
+ @Override
+ public String getCapabilityPropertyLeafValue(CapabilityAssignment capability, String pathToPropertyLeafValue) {
+ if (capability == null) {
+ log.error("getCapabilityPropertyLeafValue - capability is null");
+ return null;
+ }
+
+ if (GeneralUtility.isEmptyString(pathToPropertyLeafValue)) {
+ log.error("getCapabilityPropertyLeafValue - pathToPropertyLeafValue is null or empty");
+ return null;
+ }
+
+ String[] split = getSplittedPath(pathToPropertyLeafValue);
+ LinkedHashMap<String, Property> properties = capability.getProperties();
+ Object property = processProperties(split, properties);
+ return property == null || property instanceof Function ? null : String.valueOf(property);
+ }
+
/************************************* helper functions ***********************************/
private boolean isVNFType(NodeTemplate nt) {
return nt.getType().endsWith("VnfConfiguration");
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcTypes.java b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcTypes.java
index 9f885f4..5dc9101 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcTypes.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcTypes.java
@@ -25,7 +25,7 @@ import java.util.List;
public enum SdcTypes {
- CP, VL, VF, VFC, PNF, SERVICE, CVFC;
+ CP, VL, VF, VFC, PNF, SERVICE, CVFC, SERVICE_PROXY, CONFIGURATION;
public static List<SdcTypes> complexTypes = Arrays.asList(VF, PNF, SERVICE, CVFC);
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
index d7321d1..8435c12 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
@@ -20,7 +20,7 @@ public class ToscaParserGroupTest extends SdcToscaParserBasicTest{
for (Group group : vfModulesByVf){
assertTrue(group.getName().startsWith("fdnt1"));
assertNotNull(group.getMetadata());
- assertNotNull(group.getMetadata().getValue("vfModuleCustomizationUUID"));
+ assertNotNull(group.getMetadata().getValue("vfModuleModelCustomizationUUID"));
}
}
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
index cd80f3a..70bd9c9 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
@@ -1,8 +1,10 @@
package org.openecomp.sdc.impl;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
import org.testng.annotations.Test;
import org.openecomp.sdc.toscaparser.api.elements.Metadata;
+import java.util.List;
import java.util.Map;
import static org.testng.Assert.assertEquals;
@@ -81,4 +83,37 @@ public class ToscaParserMetadataTest extends SdcToscaParserBasicTest {
assertEquals(metadata.get("namingPolicy"),"test");
}
//endregion
+
+ //region getServiceMetadataAllProperties
+ @Test
+ public void testNullServiceMetadataAllPropertiesMap() {
+ Map<String, String> metadata = rainyCsarHelperSingleVf.getServiceMetadataAllProperties();
+ assertNull(metadata);
+ }
+
+ @Test
+ public void testServiceMetadataAllPropertiesMap() {
+ Map<String, String> metadata = fdntCsarHelper.getServiceMetadataAllProperties();
+ assertNotNull(metadata);
+ assertEquals(metadata.size(),9);
+ assertEquals(metadata.get("namingPolicy"),"test");
+ }
+ //endregion
+
+ //region getNodeTemplateMetadata
+ @Test
+ public void testGetNodeTemplateMetadata() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ Metadata metadata = fdntCsarHelper.getNodeTemplateMetadata(vfs.get(0));
+ assertNotNull(metadata);
+ assertEquals("VF", metadata.getValue("type"));
+ assertEquals("1.0", metadata.getValue("version"));
+ }
+
+ @Test
+ public void testGetNodeTemplateMetadataByNull() {
+ Metadata metadata = fdntCsarHelper.getNodeTemplateMetadata(null);
+ assertNull(metadata);
+ }
+ //endregion
}
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
index 80bf1b9..dc0fa70 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -729,6 +729,27 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
}
}
+ //region getServiceNodeTemplateByNodeName
+ @Test
+ public void testGetServiceNodeTemplateByRealNodeName() {
+ NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "FDNT 1");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "VF");
+ }
+
+ @Test
+ public void testGetServiceNodeTemplateByNullNodeName() {
+ NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName(null);
+ assertNull(nodeTemplate);
+ }
+
+ @Test
+ public void testGetServiceNodeTemplateByDummyNodeName() {
+ NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName("dummy");
+ assertNull(nodeTemplate);
+ }
+ //endregion
//region resolve get_input
@Test
public void testResolveGetInputForComplexTypeAndList() {
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java
new file mode 100644
index 0000000..797aa54
--- /dev/null
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java
@@ -0,0 +1,97 @@
+package org.openecomp.sdc.impl;
+
+import org.openecomp.sdc.tosca.parser.impl.SdcTypes;
+import org.openecomp.sdc.toscaparser.api.CapabilityAssignment;
+import org.openecomp.sdc.toscaparser.api.CapabilityAssignments;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.RequirementAssignments;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+public class ToscaParserReqAndCapTest extends SdcToscaParserBasicTest {
+
+ //region getCapabilitiesOf
+ @Test
+ public void testGetCapabilitiesOfNodeTemplate() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ CapabilityAssignments capabilityAssignments = fdntCsarHelper.getCapabilitiesOf(vfs.get(0));
+ assertNotNull(capabilityAssignments);
+ assertEquals(13, capabilityAssignments.getAll().size());
+ assertNotNull(capabilityAssignments.getCapabilityByName("DNT_FW_RHRG.binding_DNT_FW_INT_DNS_TRUSTED_RVMI"));
+ assertEquals(6, capabilityAssignments.getCapabilitiesByType("tosca.capabilities.network.Bindable").getAll().size());
+ }
+
+ @Test
+ public void testGetCapabilitiesOfNull() {
+ CapabilityAssignments capabilityAssignments = fdntCsarHelper.getCapabilitiesOf(null);
+ assertNull(capabilityAssignments);
+ }
+ //endregion
+
+ //region getRequirementsOf
+ @Test
+ public void testGetRequirementsOfNodeTemplate() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ List<NodeTemplate> cps = fdntCsarHelper.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP);
+ RequirementAssignments requirementAssignments = fdntCsarHelper.getRequirementsOf(cps.get(0));
+ assertNotNull(requirementAssignments);
+ assertEquals(1, requirementAssignments.getAll().size());
+ assertEquals("DNT_FW_RHRG", requirementAssignments.getRequirementsByName("binding").getAll().get(0).getNodeTemplateName());
+ }
+
+ @Test
+ public void testGetRequirementsOfNull() {
+ RequirementAssignments requirementAssignments = fdntCsarHelper.getRequirementsOf(null);
+ assertNull(requirementAssignments);
+ }
+ //endregion
+
+ //region getCapabilityPropertyLeafValue
+ @Test
+ public void testGetCapabilityPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "max_instances#type");
+ assertEquals("integer", propValue);
+ }
+
+ @Test
+ public void testGetCapabilityHierarchyPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.endpoint_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "ports#entry_schema#type");
+ assertEquals("PortSpec", propValue);
+ }
+
+ @Test
+ public void testGetCapabilityDummyPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "dummy");
+ assertNull(propValue);
+ }
+
+ @Test
+ public void testGetCapabilityNullPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, null);
+ assertNull(propValue);
+ }
+
+ @Test
+ public void testGetNullCapabilityPropertyLeafValue() {
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(null, "max_instances#type");
+ assertNull(propValue);
+ }
+ //endregion
+}
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java
index 6461a92..7570ced 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java
@@ -3,15 +3,13 @@ package org.openecomp.sdc.impl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
+import java.util.*;
import java.util.stream.Collectors;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
-import org.openecomp.sdc.toscaparser.api.Capability;
+import org.openecomp.sdc.toscaparser.api.CapabilityAssignment;
import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.RequirementAssignment;
import org.openecomp.sdc.toscaparser.api.elements.CapabilityTypeDef;
//import org.testng.ReporterConfig.Property;
import org.testng.annotations.Test;
@@ -38,81 +36,81 @@ public class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {
//Added by QA - Check for Capabilities in VF level (Capabilities QTY and Names).
//@Test // - BUG 283369
- public void testCapabilitiesofVFNames_QTY() throws SdcToscaParserException {
- List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
- String sName = serviceVfList.get(0).getName();
- assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
- LinkedHashMap<String, Capability> lCapabilitys = serviceVfList.get(0).getCapabilities();
- List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
- List<String> CapabilitiesNames = new ArrayList<String>(CPkeys.size());
-
- for (int i = 0; i < CPkeys.size(); i++) {
-
- Capability cCp = lCapabilitys.get(CPkeys.get(i));
-
- CapabilitiesNames.add(cCp.getName());
-
- assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive????
-
- //System.out.println(String.format("Value of key: %s , Value of capability: %s", keys.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
- //System.out.println(String.format("Value of key: %s , Value of capability: %s", ActualValues.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
- //System.out.println(String.format("*******%d*******",i));
- }
-
- for (int i = 0; i < CPkeys.size(); i++) {
- assertEquals(true, CapabilitiesNames.stream().map(String::toLowerCase).collect(Collectors.toList()).contains(fdntCsarHelper_Data.get("FDNT").get("capabilities").get(i).toLowerCase())); // Compare capabilities predefined list to actual one.
- }
-
- assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual
- }
+// public void testCapabilitiesofVFNames_QTY() throws SdcToscaParserException {
+// List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+// String sName = serviceVfList.get(0).getName();
+// assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
+// Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
+// List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
+// List<String> CapabilitiesNames = new ArrayList<String>(CPkeys.size());
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+//
+// CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
+//
+// CapabilitiesNames.add(cCp.getName());
+//
+// assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive????
+//
+// //System.out.println(String.format("Value of key: %s , Value of capability: %s", keys.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
+// //System.out.println(String.format("Value of key: %s , Value of capability: %s", ActualValues.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
+// //System.out.println(String.format("*******%d*******",i));
+// }
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+// assertEquals(true, CapabilitiesNames.stream().map(String::toLowerCase).collect(Collectors.toList()).contains(fdntCsarHelper_Data.get("FDNT").get("capabilities").get(i).toLowerCase())); // Compare capabilities predefined list to actual one.
+// }
+//
+// assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual
+// }
//Added by QA - Check for Capabilities in VF level (Capabilities Types and Properties).
//@Test
- public void testCapabilitiesofVFTypes_Properties() throws SdcToscaParserException {
- List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
- String sName = serviceVfList.get(0).getName();
- assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
- LinkedHashMap<String, Capability> lCapabilitys = serviceVfList.get(0).getCapabilities();
-
- List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
- List<String> CPPropkeys = new ArrayList<>(lCapabilitys.keySet());
- List<String> CapabilitiesTypes = new ArrayList<String>(CPkeys.size());
-
- //int iKeysSize = keys.size(); //for debug
-
- for (int i = 0; i < CPkeys.size(); i++) {
-
- Capability cCp = lCapabilitys.get(CPkeys.get(i));
- CapabilityTypeDef CpDef = cCp.getDefinition();
- CapabilitiesTypes.add(CpDef.getType());
-
- //LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties();
- LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties();
-
- List<String> CP_Propkeys = new ArrayList<>(lPropertiesR.keySet());
-
- for (int j = 0; j < CP_Propkeys.size(); j++) {
-
- Property p = lPropertiesR.get(CP_Propkeys.get(j));
-
- if(p != null){
- String sPType = p.getType();
- Boolean bPRequired = p.isRequired();
-
- System.out.println(sPType + " " + bPRequired);
-
- }
-
- }
-
- }
-
- for (int i = 0; i < CPkeys.size(); i++) {
-
- }
-
- assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual
- }
+// public void testCapabilitiesofVFTypes_Properties() throws SdcToscaParserException {
+// List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+// String sName = serviceVfList.get(0).getName();
+// assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
+// Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
+//
+// List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
+// List<String> CPPropkeys = new ArrayList<>(lCapabilitys.keySet());
+// List<String> CapabilitiesTypes = new ArrayList<String>(CPkeys.size());
+//
+// //int iKeysSize = keys.size(); //for debug
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+//
+// CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
+// CapabilityTypeDef CpDef = cCp.getDefinition();
+// CapabilitiesTypes.add(CpDef.getType());
+//
+// //LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties();
+// LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties();
+//
+// List<String> CP_Propkeys = new ArrayList<>(lPropertiesR.keySet());
+//
+// for (int j = 0; j < CP_Propkeys.size(); j++) {
+//
+// Property p = lPropertiesR.get(CP_Propkeys.get(j));
+//
+// if(p != null){
+// String sPType = p.getType();
+// Boolean bPRequired = p.isRequired();
+//
+// System.out.println(sPType + " " + bPRequired);
+//
+// }
+//
+// }
+//
+// }
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+//
+// }
+//
+// assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual
+// }
//@Test // - BUG 283387
public void testRequirmentsofVF() throws SdcToscaParserException {
@@ -122,7 +120,7 @@ public class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {
List<String> ActualReqsValues = new ArrayList<>(Arrays.asList( ));
- ArrayList<Object> lRequirements = serviceVfList.get(0).getRequirements();
+ List<RequirementAssignment> lRequirements = serviceVfList.get(0).getRequirements().getAll();
assertEquals(fdntCsarHelper_Data.get("FDNT").get("requirements").size(),lRequirements.size()); //
diff --git a/src/test/resources/csars/service-sunny-flow.csar b/src/test/resources/csars/service-sunny-flow.csar
index ef6d03e..48eb59b 100644
--- a/src/test/resources/csars/service-sunny-flow.csar
+++ b/src/test/resources/csars/service-sunny-flow.csar
Binary files differ