aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-tosca-parser/src/test
diff options
context:
space:
mode:
authorPavel Aharoni <pa0916@att.com>2017-05-11 19:32:07 +0300
committerPavel Aharoni <pa0916@att.com>2017-05-11 19:32:07 +0300
commit8caef088a9e5467cd0cb462acb217edceedac8fe (patch)
treee47c41688833daf2ac76e53324992be1f15d2e56 /sdc-tosca-parser/src/test
parentaf2d8ef12f6b75ae837fffdeaf5d152756cec6d6 (diff)
[SDC-19] VFC to CP props
Change-Id: I217934251fd8eeaf883b60161826306d6b7eaf3c Signed-off-by: Pavel Aharoni <pa0916@att.com>
Diffstat (limited to 'sdc-tosca-parser/src/test')
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java66
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java10
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java27
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java7
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/1service-ServiceWithPorts.csarbin0 -> 47257 bytes
5 files changed, 74 insertions, 36 deletions
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java
index 373ff97..0eb58f8 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java
@@ -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() + " ###########");
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 706c864..58e967a 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
@@ -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
+
}
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 9a78ed5..c9215a2 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
@@ -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
+
}
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 d357d21..0599dcc 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
@@ -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
index 0000000..fa6577b
--- /dev/null
+++ b/sdc-tosca-parser/src/test/resources/csars/1service-ServiceWithPorts.csar
Binary files differ