summaryrefslogtreecommitdiffstats
path: root/sdc-tosca-parser
diff options
context:
space:
mode:
Diffstat (limited to 'sdc-tosca-parser')
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java12
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java5
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java7
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java53
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java6
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-Renanatst2-csar.csarbin0 -> 321286 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-get-input.csarbin0 -> 45214 bytes
7 files changed, 66 insertions, 17 deletions
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
index c53dcec..cf4806d 100644
--- a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -41,6 +41,7 @@ import org.openecomp.sdc.toscaparser.api.TopologyTemplate;
import org.openecomp.sdc.toscaparser.api.ToscaTemplate;
import org.openecomp.sdc.toscaparser.api.elements.Metadata;
import org.openecomp.sdc.toscaparser.api.elements.NodeType;
+import org.openecomp.sdc.toscaparser.api.functions.Function;
import org.openecomp.sdc.toscaparser.api.parameters.Input;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -74,7 +75,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
String[] split = getSplittedPath(leafValuePath);
LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
Object property = processProperties(split, properties);
- return property == null ? null : String.valueOf(property);
+ return property == null || property instanceof Function ? null : String.valueOf(property);
}
@Override
@@ -124,11 +125,12 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
String fullPathToSearch = PREFIX + cpName + "_" + item;
Object value = getNodeTemplatePropertyAsObject(vfc, fullPathToSearch);
if (value != null) {
- if (!cps.containsKey(cpName))
+ if (!cps.containsKey(cpName)){
cps.put(cpName, new HashMap<>());
+ }
+ cps.get(cpName).put(item, value);
}
- cps.get(cpName).put(item, value);
}
}
}
@@ -250,7 +252,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
Input input = findFirst.get();
Object current = input.getDefault();
Object property = iterateProcessPath(2, current, split);
- return property == null ? null : String.valueOf(property);
+ return property == null || property instanceof Function? null : String.valueOf(property);
}
}
log.error("getServiceInputLeafValue - value not found");
@@ -360,7 +362,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
String[] split = getSplittedPath(leafValuePath);
LinkedHashMap<String, Property> properties = group.getProperties();
Object property = processProperties(split, properties);
- return property == null ? null : String.valueOf(property);
+ return property == null || property instanceof Function? null : String.valueOf(property);
}
@Override
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
index 6746df7..7ea231c 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
@@ -25,6 +25,7 @@ public abstract class SdcToscaParserBasicTest {
static ISdcCsarHelper rainyCsarHelperMultiVfs;
static ISdcCsarHelper fdntCsarHelper;
static ISdcCsarHelper complexCps;
+ static ISdcCsarHelper fdntCsarHelperWithInputs;
static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
@BeforeClass
@@ -34,7 +35,9 @@ public abstract class SdcToscaParserBasicTest {
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");
+ complexCps = getCsarHelper("csars/service-Renanatst2-csar.csar");
+ fdntCsarHelperWithInputs = getCsarHelper("csars/service-ServiceFdnt-with-get-input.csar");
+
fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
{
HashMap<String, List<String>> FDNT ;
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
index 01c888f..d7321d1 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
@@ -76,6 +76,13 @@ public class ToscaParserGroupTest extends SdcToscaParserBasicTest{
assertEquals("false", volumeGroup);
}
+// @Test
+// public void testGroupFlatGetInputProperty() throws SdcToscaParserException {
+// List<Group> vfModulesByVf = fdntCsarHelperWithInputs.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+// String volumeGroup = fdntCsarHelperWithInputs.getGroupPropertyLeafValue(vfModulesByVf.get(1), "volume_group");
+// assertEquals("false", volumeGroup);
+// }
+
@Test
public void testGroupPropertyLeafValueByNullProperty() {
List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
index dd895c3..61d8781 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -3,16 +3,18 @@ package org.openecomp.sdc.impl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
-import org.testng.annotations.Test;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.openecomp.sdc.toscaparser.api.Group;
import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.testng.annotations.Test;
public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
@@ -43,6 +45,12 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
}
@Test
+ public void testNodeTemplateFlatFunctionProperty() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelperWithInputs.getServiceVfList();
+ assertEquals(null, fdntCsarHelperWithInputs.getNodeTemplatePropertyLeafValue(serviceVfList.get(1), "target_network_role"));
+ }
+
+ @Test
public void testNodeTemplateNestedProperty() throws SdcToscaParserException {
List<NodeTemplate> serviceVlList = fdntCsarHelper.getServiceVlList();
NodeTemplate nodeTemplate = serviceVlList.get(0);
@@ -50,7 +58,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
assertEquals("24", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#cidr_mask"));
assertEquals("7a6520b-9982354-ee82992c-105720", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_flows#vpn_binding"));
}
-
+
@Test
public void testNodeTemplateNestedPropertyFromInput() throws SdcToscaParserException {
List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
@@ -308,20 +316,43 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
//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));
+ List<NodeTemplate> vfcs = complexCps.getVfcListByVf("f999e2ca-72c0-42d3-9b11-13f2122fb8ef");
+ boolean isChecked = false;
+ boolean isChecked1 = false;
+ for (int i = 0; i < vfcs.size(); i++) {
+
+ if(vfcs.get(i).getName().equalsIgnoreCase("abstract_ddc"))
+ {
+ isChecked = true;
+ Map<String, Map<String, Object>> cps = complexCps.getCpPropertiesFromVfc(vfcs.get(i));
- assertEquals(5, cps.size());
+ assertEquals(3,cps.size());
- 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(new Integer(1), cps.get("ddc_int_imbl__port").get("ip_requirements#ip_count_required#count"));
+ assertEquals(new Boolean(true), cps.get("ddc_int_imbl__port").get("ip_requirements#dhcp_enabled"));
+ assertEquals(new Integer(6), cps.get("ddc_int_imbl__port").get("ip_requirements#ip_version"));
+ assertEquals(null, cps.get("ddc_int_imbl__port").get("subnetpoolid"));
- 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"));
+ //assertEquals("\"int_imsp\"", cps.get("mon_ist_imsp__port").get("network_role_tag"));
+
+ }
+
+ if(vfcs.get(i).getName().equalsIgnoreCase("abstract_mda"))
+ {
+ isChecked1 = true;
+ Map<String, Map<String, Object>> cps1 = complexCps.getCpPropertiesFromVfc(vfcs.get(i));
+
+ assertEquals(new Integer(4), cps1.get("mda_int_imsp__port").get("ip_requirements#ip_version"));
+ assertEquals(null, cps1.get("mda_int_imsp__port").get("ip_requirements#ip_count_required#count"));
+
+ }
+
+ }
+ assertTrue(isChecked);
+ assertTrue(isChecked1);
}
+
@Test
public void testGetCpPropertiesFromVfcForNullVFC() {
Map<String, Map<String, Object>> cps = complexCps.getCpPropertiesFromVfc(null);
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java
index 0b172f5..ea5c2ef 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java
@@ -34,6 +34,12 @@ public class ToscaParserServiceInputTest extends SdcToscaParserBasicTest {
assertEquals("test service naming", serviceInputLeafValue);
}
+// @Test
+// public void testGetServiceInputLeafValueWithGetInput(){
+// String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("my_input#default");
+// assertEquals(null, serviceInputLeafValue);
+// }
+
@Test
public void testGetServiceInputLeafValueNotExists(){
String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default#kuku");
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-Renanatst2-csar.csar b/sdc-tosca-parser/src/test/resources/csars/service-Renanatst2-csar.csar
new file mode 100644
index 0000000..37baffb
--- /dev/null
+++ b/sdc-tosca-parser/src/test/resources/csars/service-Renanatst2-csar.csar
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar
new file mode 100644
index 0000000..53aea49
--- /dev/null
+++ b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar
Binary files differ