summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--jtosca/pom.xml9
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java10
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/prereq/CSAR.java176
-rw-r--r--jtosca/src/test/java/org.openecomp.sdc.toscaparser/JToscaMetadataParse.java26
-rw-r--r--jtosca/src/test/resources/csars/csar_hello_world.csar (renamed from sdc-tosca-parser/src/test/resources/csars/csar_hello_world.zip)bin936 -> 936 bytes
-rw-r--r--pom.xml2
-rw-r--r--sdc-distribution-ci/pom.xml2
-rw-r--r--sdc-distribution-client/pom.xml2
-rw-r--r--sdc-tosca-parser/pom.xml21
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ConformanceLevel.java25
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java4
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/Version.java48
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/config/Configuration.java16
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/config/ConfigurationManager.java51
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java19
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java105
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/utils/GeneralUtility.java53
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/utils/YamlToObjectConverter.java123
-rw-r--r--sdc-tosca-parser/src/main/resources/config/configuration.yaml3
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/BasicTest.java134
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java21
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGeneralUtilTest.java23
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java28
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java35
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java118
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java18
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java118
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserTestSuite.java56
-rw-r--r--sdc-tosca-parser/src/test/resources/config/configuration.yaml3
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-0904-2.csarbin41245 -> 41437 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csarbin39700 -> 39892 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar.csarbin39979 -> 40171 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csarbin44976 -> 45194 bytes
34 files changed, 943 insertions, 308 deletions
diff --git a/.gitignore b/.gitignore
index 68f22e6..74f7cda 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,5 @@ target/
*.class
*.orig
.idea/*
+
+sdc-tosca-parser/test-output/**/*
diff --git a/jtosca/pom.xml b/jtosca/pom.xml
index f74988b..ce50fec 100644
--- a/jtosca/pom.xml
+++ b/jtosca/pom.xml
@@ -9,7 +9,7 @@
</parent>
<artifactId>jtosca</artifactId>
- <version>0.1.2-SNAPSHOT</version>
+ <version>0.1.3-SNAPSHOT</version>
<dependencies>
@@ -34,5 +34,10 @@
<scope>test</scope>
</dependency> -->
- </dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ </dependency>
+ </dependencies>
</project> \ No newline at end of file
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java
index 942ca96..d1b0179 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java
@@ -82,8 +82,9 @@ public class ToscaTemplate extends Object {
private ArrayList<TopologyTemplate> nestedToscaTemplatesWithTopology;
private ToscaGraph graph;
private String csarTempDir;
- private int nestingLoopCounter;
-
+ private int nestingLoopCounter;
+ private LinkedHashMap<String, LinkedHashMap<String, Object>> metaProperties;
+
@SuppressWarnings("unchecked")
public ToscaTemplate(String _path,
LinkedHashMap<String,Object> _parsedParams,
@@ -480,6 +481,7 @@ public class ToscaTemplate extends Object {
if (csar.validate()) {
try {
csar.decompress();
+ metaProperties = csar.getMetaProperties();
}
catch (IOException e) {
log.error("ToscaTemplate - _getPath - IOException trying to decompress {}", _path);
@@ -554,6 +556,10 @@ public class ToscaTemplate extends Object {
public ArrayList<NodeTemplate> getNodeTemplates() {
return nodeTemplates;
}
+
+ public LinkedHashMap<String, Object> getMetaProperties(String propertiesFile) {
+ return metaProperties.get(propertiesFile);
+ }
private boolean _isSubMappedNode(NodeTemplate nt,LinkedHashMap<String,Object> toscaTpl) {
// Return True if the nodetemple is substituted
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/prereq/CSAR.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/prereq/CSAR.java
index 159ad66..2ab5d26 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/prereq/CSAR.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/prereq/CSAR.java
@@ -12,10 +12,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
@@ -31,6 +28,7 @@ import org.yaml.snakeyaml.Yaml;
public class CSAR {
private static Logger log = LoggerFactory.getLogger(CSAR.class.getName());
+ private static final ArrayList<String> META_PROPERTIES_FILES = new ArrayList<>(Arrays.asList("TOSCA-Metadata/TOSCA.meta", "csar.meta"));
private String path;
private boolean isFile;
@@ -38,9 +36,10 @@ public class CSAR {
private boolean errorCaught;
private String csar;
private String tempDir;
- private Metadata metaData;
+// private Metadata metaData;
private File tempFile;
-
+ private LinkedHashMap<String, LinkedHashMap<String, Object>> metaProperties;
+
public CSAR(String csarPath, boolean aFile) {
path = csarPath;
isFile = aFile;
@@ -49,8 +48,9 @@ public class CSAR {
csar = null;
tempDir = null;
tempFile = null;
+ metaProperties = new LinkedHashMap<>();
}
-
+
@SuppressWarnings("unchecked")
public boolean validate() {
isValidated = true;
@@ -89,8 +89,23 @@ public class CSAR {
return false;
}
- ZipFile zf = null;
+ _parseAndValidateMetaProperties();
+
+ if(errorCaught) {
+ return false;
+ }
+
+ // validate that external references in the main template actually exist and are accessible
+ _validateExternalReferences();
+ return !errorCaught;
+
+ }
+
+ private void _parseAndValidateMetaProperties() {
+
+ ZipFile zf = null;
+
try {
// validate that it is a valid zip file
@@ -99,85 +114,79 @@ public class CSAR {
raf.close();
// check if Zip's magic number
if (n != 0x504B0304) {
- throw new IOException(String.format("\"%s\" is not a valid zip file", csar));
+ throw new IOException(String.format("\"%s\" is not a valid zip file", csar));
}
-
+
// validate that it contains the metadata file in the correct location
zf = new ZipFile(csar);
ZipEntry ze = zf.getEntry("TOSCA-Metadata/TOSCA.meta");
- if(ze == null) {
+ if (ze == null) {
throw new IOException(String.format(
"\"%s\" is not a valid CSAR as it does not contain the " +
- "required file \"TOSCA.meta\" in the folder \"TOSCA-Metadata\"", csar));
+ "required file \"TOSCA.meta\" in the folder \"TOSCA-Metadata\"", csar));
}
-
+
+ //Going over expected metadata files and parsing them
+ for (String metaFile: META_PROPERTIES_FILES) {
+
+ byte ba[] = new byte[4096];
+ ze = zf.getEntry(metaFile);
+ if (ze != null) {
+ InputStream inputStream = zf.getInputStream(ze);
+ n = inputStream.read(ba, 0, 4096);
+
+ String md = new String(ba);
+ md = md.substring(0, (int) n);
+ Yaml yaml = new Yaml();
+ Object mdo = yaml.load(md);
+ if (!(mdo instanceof LinkedHashMap)) {
+ throw new IOException(String.format(
+ "The file \"%s\" in the" +
+ " CSAR \"%s\" does not contain valid YAML content", ze.getName(), csar));
+ }
+
+ String[] split = ze.getName().split("/");
+ String fileName = split[split.length - 1];
+
+ if (!metaProperties.containsKey(fileName)) {
+ metaProperties.put(fileName, (LinkedHashMap<String, Object>) mdo);
+ }
+ }
+ }
+
// verify it has "Entry-Definition"
- ZipInputStream zipIn = new ZipInputStream(new FileInputStream(csar));
- byte ba[] = new byte[4096];
- while ((ze = zipIn.getNextEntry()) != null) {
- if (ze.getName().equals("TOSCA-Metadata/TOSCA.meta")) {
- n = zipIn.read(ba,0,4096);
- zipIn.close();
- break;
- }
+ String edf = _getMetadata("Entry-Definitions");
+ if (edf == null) {
+ throw new IOException(String.format(
+ "The CSAR \"%s\" is missing the required metadata " +
+ "\"Entry-Definitions\" in \"TOSCA-Metadata/TOSCA.meta\"", csar));
}
- String md = new String(ba);
- md = md.substring(0, (int)n);
- Yaml yaml = new Yaml();
- Object mdo = yaml.load(md);
- if(!(mdo instanceof LinkedHashMap)) {
- throw new IOException(String.format(
- "The file \"TOSCA-Metadata/TOSCA.meta\" in the" +
- " CSAR \"%s\" does not contain valid YAML content",csar));
- }
-
- metaData = new Metadata((Map<String, Object>) mdo);
- String edf = metaData.getValue("Entry-Definitions");
- if(edf == null) {
- throw new IOException(String.format(
- "The CSAR \"%s\" is missing the required metadata " +
- "\"Entry-Definitions\" in \"TOSCA-Metadata/TOSCA.meta\"",csar));
- }
-
- //validate that "Entry-Definitions' metadata value points to an existing file in the CSAR
- boolean foundEDF = false;
- Enumeration<? extends ZipEntry> entries = zf.entries();
- while (entries.hasMoreElements()) {
- ze = entries.nextElement();
- if (ze.getName().equals(edf)) {
- foundEDF = true;
- break;
- }
- }
- if(!foundEDF) {
- throw new IOException(String.format(
- "The \"Entry-Definitions\" file defined in the CSAR \"%s\" does not exist",csar));
- }
-
- }
- catch(Exception e) {
+ //validate that "Entry-Definitions' metadata value points to an existing file in the CSAR
+ boolean foundEDF = false;
+ Enumeration<? extends ZipEntry> entries = zf.entries();
+ while (entries.hasMoreElements()) {
+ ze = entries.nextElement();
+ if (ze.getName().equals(edf)) {
+ foundEDF = true;
+ break;
+ }
+ }
+ if (!foundEDF) {
+ throw new IOException(String.format(
+ "The \"Entry-Definitions\" file defined in the CSAR \"%s\" does not exist", csar));
+ }
+ } catch (Exception e) {
ExceptionCollector.appendException("ValidationError: " + e.getMessage());
- errorCaught = true;;
+ errorCaught = true;
}
-
+
try {
- if(zf != null) {
+ if (zf != null) {
zf.close();
}
+ } catch (IOException e) {
}
- catch(IOException e) {
- }
-
- if(errorCaught) {
- return false;
- }
-
- // validate that external references in the main template actually exist and are accessible
- _validateExternalReferences();
-
- return !errorCaught;
-
}
public void cleanup() {
@@ -190,15 +199,12 @@ public class CSAR {
}
}
- public Metadata getMetadata() {
- return metaData;
- }
-
private String _getMetadata(String key) {
if(!isValidated) {
validate();
}
- return metaData.getValue(key);
+ Object value = _getMetaProperty("TOSCA.meta").get(key);
+ return value != null ? value.toString() : null;
}
public String getAuthor() {
@@ -208,8 +214,16 @@ public class CSAR {
public String getVersion() {
return _getMetadata("CSAR-Version");
}
-
- public String getMainTemplate() {
+
+ public LinkedHashMap<String, LinkedHashMap<String, Object>> getMetaProperties() {
+ return metaProperties;
+ }
+
+ private LinkedHashMap<String, Object> _getMetaProperty(String propertiesFile) {
+ return metaProperties.get(propertiesFile);
+ }
+
+ public String getMainTemplate() {
String entryDef = _getMetadata("Entry-Definitions");
ZipFile zf;
boolean ok = false;
@@ -259,8 +273,10 @@ public class CSAR {
if(desc != null) {
return desc;
}
- metaData.setValue("Description",(String)getMainTemplateYaml().get("description"));
- return metaData.getValue("Description");
+
+ Map<String, Object> metaData = metaProperties.get("TOSCA.meta");
+ metaData.put("Description", getMainTemplateYaml().get("description"));
+ return _getMetadata("Description");
}
public String getTempDir() {
diff --git a/jtosca/src/test/java/org.openecomp.sdc.toscaparser/JToscaMetadataParse.java b/jtosca/src/test/java/org.openecomp.sdc.toscaparser/JToscaMetadataParse.java
new file mode 100644
index 0000000..584a0fd
--- /dev/null
+++ b/jtosca/src/test/java/org.openecomp.sdc.toscaparser/JToscaMetadataParse.java
@@ -0,0 +1,26 @@
+package org.openecomp.sdc.toscaparser;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.util.LinkedHashMap;
+
+import org.junit.Test;
+import org.openecomp.sdc.toscaparser.api.ToscaTemplate;
+import org.openecomp.sdc.toscaparser.api.common.JToscaException;
+
+public class JToscaMetadataParse {
+
+ @Test
+ public void testMetadataParsedCorrectly() throws JToscaException {
+ String fileStr = JToscaMetadataParse.class.getClassLoader().getResource("csars/csar_hello_world.csar").getFile();
+ File file = new File(fileStr);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ LinkedHashMap<String, Object> metadataProperties = toscaTemplate.getMetaProperties("TOSCA.meta");
+ assertNotNull(metadataProperties);
+ Object entryDefinition = metadataProperties.get("Entry-Definitions");
+ assertNotNull(entryDefinition);
+ assertEquals("tosca_helloworld.yaml", entryDefinition);
+ }
+}
diff --git a/sdc-tosca-parser/src/test/resources/csars/csar_hello_world.zip b/jtosca/src/test/resources/csars/csar_hello_world.csar
index 43ffbbc..43ffbbc 100644
--- a/sdc-tosca-parser/src/test/resources/csars/csar_hello_world.zip
+++ b/jtosca/src/test/resources/csars/csar_hello_world.csar
Binary files differ
diff --git a/pom.xml b/pom.xml
index f03c0fe..2b3583e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
<artifactId>sdc-main-distribution-client</artifactId>
- <version>1.1.9-SNAPSHOT</version>
+ <version>1.1.10-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
diff --git a/sdc-distribution-ci/pom.xml b/sdc-distribution-ci/pom.xml
index c7b544c..f76457c 100644
--- a/sdc-distribution-ci/pom.xml
+++ b/sdc-distribution-ci/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
<artifactId>sdc-main-distribution-client</artifactId>
- <version>1.1.9-SNAPSHOT</version>
+ <version>1.1.10-SNAPSHOT</version>
</parent>
<artifactId>sdc-distribution-ci</artifactId>
diff --git a/sdc-distribution-client/pom.xml b/sdc-distribution-client/pom.xml
index ea13907..d7f0ea7 100644
--- a/sdc-distribution-client/pom.xml
+++ b/sdc-distribution-client/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
<artifactId>sdc-main-distribution-client</artifactId>
- <version>1.1.9-SNAPSHOT</version>
+ <version>1.1.10-SNAPSHOT</version>
</parent>
<artifactId>sdc-distribution-client</artifactId>
diff --git a/sdc-tosca-parser/pom.xml b/sdc-tosca-parser/pom.xml
index 6b370ce..f027a96 100644
--- a/sdc-tosca-parser/pom.xml
+++ b/sdc-tosca-parser/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
<artifactId>sdc-main-distribution-client</artifactId>
- <version>1.1.9-SNAPSHOT</version>
+ <version>1.1.10-SNAPSHOT</version>
</parent>
<artifactId>sdc-tosca-parser</artifactId>
@@ -71,7 +71,7 @@
<dependency>
<groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
<artifactId>jtosca</artifactId>
- <version>0.1.2-SNAPSHOT</version>
+ <version>0.1.3-SNAPSHOT</version>
</dependency>
@@ -90,10 +90,17 @@
<scope>test</scope>
</dependency>
+ <!--<dependency>-->
+ <!--<groupId>junit</groupId>-->
+ <!--<artifactId>junit</artifactId>-->
+ <!--<version>4.12</version>-->
+ <!--<scope>test</scope>-->
+ <!--</dependency>-->
+
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>6.11</version>
<scope>test</scope>
</dependency>
@@ -108,7 +115,7 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
- <scope>test</scope>
+ <!--<scope>test</scope>-->
</dependency>
<!-- <dependency>
@@ -128,7 +135,7 @@
<version>2.19.1</version>
<configuration>
<includes>
- <include>**/ToscaParserTestSuite.class</include>
+ <include>**/ToscaParser***Test.class</include>
</includes>
</configuration>
</plugin>
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ConformanceLevel.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ConformanceLevel.java
new file mode 100644
index 0000000..a026938
--- /dev/null
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ConformanceLevel.java
@@ -0,0 +1,25 @@
+package org.openecomp.sdc.tosca.parser.api;
+
+public class ConformanceLevel {
+
+ private String minVersion;
+ private String maxVersion;
+
+ public String getMaxVersion() {
+ return maxVersion;
+ }
+
+ public void setMaxVersion(String maxVersion) {
+ this.maxVersion = maxVersion;
+ }
+
+ public String getMinVersion() {
+ return minVersion;
+ }
+
+ public void setMinVersion(String minVersion) {
+ this.minVersion = minVersion;
+ }
+
+
+}
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
index dd0e96c..7cc9022 100644
--- a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
@@ -246,5 +246,7 @@ public interface ISdcCsarHelper {
* @return - the service inputs list.
*/
public List<Input> getServiceInputs();
-
+
+
+ public String getConformanceLevel();
}
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/Version.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/Version.java
new file mode 100644
index 0000000..473e3a8
--- /dev/null
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/Version.java
@@ -0,0 +1,48 @@
+package org.openecomp.sdc.tosca.parser.api;
+
+public class Version implements Comparable<Version> {
+
+ private String version;
+
+ public final String get() {
+ return this.version;
+ }
+
+ public Version(String version) {
+ if(version == null)
+ throw new IllegalArgumentException("Version can not be null");
+ if(!version.matches("[0-9]+(\\.[0-9]+)*"))
+ throw new IllegalArgumentException("Invalid version format");
+ this.version = version;
+ }
+
+ @Override public int compareTo(Version that) {
+ if(that == null)
+ return 1;
+ String[] thisParts = this.get().split("\\.");
+ String[] thatParts = that.get().split("\\.");
+ int length = Math.max(thisParts.length, thatParts.length);
+ for(int i = 0; i < length; i++) {
+ int thisPart = i < thisParts.length ?
+ Integer.parseInt(thisParts[i]) : 0;
+ int thatPart = i < thatParts.length ?
+ Integer.parseInt(thatParts[i]) : 0;
+ if(thisPart < thatPart)
+ return -1;
+ if(thisPart > thatPart)
+ return 1;
+ }
+ return 0;
+ }
+
+ @Override public boolean equals(Object that) {
+ if(this == that)
+ return true;
+ if(that == null)
+ return false;
+ if(this.getClass() != that.getClass())
+ return false;
+ return this.compareTo((Version) that) == 0;
+ }
+
+}
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/config/Configuration.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/config/Configuration.java
new file mode 100644
index 0000000..1d00d14
--- /dev/null
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/config/Configuration.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.tosca.parser.config;
+
+import org.openecomp.sdc.tosca.parser.api.ConformanceLevel;
+
+public class Configuration {
+
+ private ConformanceLevel conformanceLevel;
+
+ public ConformanceLevel getConformanceLevel() {
+ return conformanceLevel;
+ }
+
+ public void setConformanceLevel(ConformanceLevel conformanceLevel) {
+ this.conformanceLevel = conformanceLevel;
+ }
+}
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/config/ConfigurationManager.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/config/ConfigurationManager.java
new file mode 100644
index 0000000..7cd9ed2
--- /dev/null
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/config/ConfigurationManager.java
@@ -0,0 +1,51 @@
+package org.openecomp.sdc.tosca.parser.config;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Resources;
+import org.openecomp.sdc.tosca.parser.utils.YamlToObjectConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URL;
+
+public class ConfigurationManager {
+
+ private static Logger log = LoggerFactory.getLogger(ConfigurationManager.class.getName());
+
+ private static final String CONFIGURATION_FILE = "config/configuration.yaml";
+ private static volatile ConfigurationManager instance;
+ private Configuration configuration;
+
+
+ private ConfigurationManager() {
+ URL url = Resources.getResource(CONFIGURATION_FILE);
+ String configFileContents = null;
+ try {
+ configFileContents = Resources.toString(url, Charsets.UTF_8);
+ } catch (IOException e) {
+ log.error("ConfigurationManager - Failed to load configuration file");
+ }
+ YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter();
+ this.configuration = yamlToObjectConverter.convertFromString(configFileContents, Configuration.class);
+ }
+
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public static ConfigurationManager getInstance() {
+ if (instance == null) {
+ synchronized (ConfigurationManager.class){
+ if (instance == null){
+ instance = new ConfigurationManager();
+ }
+ }
+ }
+ return instance;
+ }
+
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+}
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 000b381..9280322 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
@@ -407,6 +407,25 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return nodeTemplate.getTypeDefinition().getType();
}
+ @Override
+ public String getConformanceLevel() {
+ LinkedHashMap<String, Object> csarMeta = toscaTemplate.getMetaProperties("csar.meta");
+ if (csarMeta == null){
+ log.warn("No csar.meta file is found in CSAR - this file should hold the conformance level of the CSAR. This might be OK for older CSARs.");
+ return null;
+ }
+
+ Object conformanceLevel = csarMeta.get("SDC-TOSCA-Definitions-Version");
+ if (conformanceLevel != null){
+ String confLevelStr = conformanceLevel.toString();
+ log.debug("CSAR conformance level is {}", confLevelStr);
+ return confLevelStr;
+ } else {
+ log.error("Invalid csar.meta file - no entry found for SDC-TOSCA-Definitions-Version key. This entry should hold the conformance level.");
+ return null;
+ }
+ }
+
/************************************* helper functions ***********************************/
private List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate nodeTemplate, String sdcType){
if (nodeTemplate == null) {
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java
index 3f62e12..62b5acb 100644
--- a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java
@@ -1,49 +1,74 @@
package org.openecomp.sdc.tosca.parser.impl;
-import java.io.IOException;
-import java.util.List;
-
+import org.openecomp.sdc.tosca.parser.api.ConformanceLevel;
import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.config.Configuration;
+import org.openecomp.sdc.tosca.parser.config.ConfigurationManager;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
-import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.tosca.parser.utils.GeneralUtility;
import org.openecomp.sdc.toscaparser.api.ToscaTemplate;
import org.openecomp.sdc.toscaparser.api.common.JToscaException;
-public class SdcToscaParserFactory{
-
- private static SdcToscaParserFactory instance;
-
- private SdcToscaParserFactory(){}
-
- /**
- * Get an SdcToscaParserFactory instance.
- * After parsing work is done, it must be closed using the close() method.
- */
- public static SdcToscaParserFactory getInstance() {
- if (instance == null) {
- synchronized (SdcToscaParserFactory.class) {
- if (instance == null) {
- instance = new SdcToscaParserFactory();
- }
- }
- }
- return instance;
- }
-
- /**
- * Get an ISdcCsarHelper object for this CSAR file.
- * @param csarPath - the path to CSAR file.
- * @return ISdcCsarHelper object.
- * @throws SdcToscaParserException - in case the path or CSAR are invalid.
- * @throws JToscaException
- */
- public ISdcCsarHelper getSdcCsarHelper(String csarPath) throws SdcToscaParserException, JToscaException, IOException{
- //TODO add logic to check if legal file and csar
- synchronized (SdcToscaParserFactory.class) {
- ToscaTemplate tosca = new ToscaTemplate(csarPath, null, true, null);
- SdcCsarHelperImpl sdcCsarHelperImpl = new SdcCsarHelperImpl(tosca);
- return sdcCsarHelperImpl;
- }
- }
+import java.io.IOException;
+
+public class SdcToscaParserFactory {
+
+ private static volatile SdcToscaParserFactory instance;
+ private static Configuration configuration;
+
+ private SdcToscaParserFactory() {
+
+ }
+
+ /**
+ * Get an SdcToscaParserFactory instance.
+ * After parsing work is done, it must be closed using the close() method.
+ */
+ public static SdcToscaParserFactory getInstance() throws IOException {
+ if (instance == null) {
+ synchronized (SdcToscaParserFactory.class) {
+ if (instance == null) {
+ instance = new SdcToscaParserFactory();
+ configuration = ConfigurationManager.getInstance().getConfiguration();
+ }
+ }
+ }
+ return instance;
+ }
+
+ /**
+ * Get an ISdcCsarHelper object for this CSAR file.
+ *
+ * @param csarPath - the absolute path to CSAR file.
+ * @return ISdcCsarHelper object.
+ * @throws SdcToscaParserException - in case the path or CSAR are invalid.
+ * @throws JToscaException
+ */
+ public ISdcCsarHelper getSdcCsarHelper(String csarPath) throws JToscaException, IOException, SdcToscaParserException {
+ //TODO add logic to check if legal file and csar
+ synchronized (SdcToscaParserFactory.class) {
+
+
+ ToscaTemplate tosca = new ToscaTemplate(csarPath, null, true, null);
+ SdcCsarHelperImpl sdcCsarHelperImpl = new SdcCsarHelperImpl(tosca);
+ if (sdcCsarHelperImpl != null) {
+ validateCsarVersion(sdcCsarHelperImpl.getConformanceLevel());
+ }
+ return sdcCsarHelperImpl;
+ }
+ }
+
+ private void validateCsarVersion(String cSarVersion) throws SdcToscaParserException {
+ ConformanceLevel level = configuration.getConformanceLevel();
+ String minVersion = level.getMinVersion();
+ String maxVersion = level.getMaxVersion();
+ if (cSarVersion != null) {
+ if ((GeneralUtility.conformanceLevelCompare(cSarVersion, minVersion) < 0) || (GeneralUtility.conformanceLevelCompare(cSarVersion, maxVersion) > 0)) {
+ throw new SdcToscaParserException("Model is not supported. Parser supports versions " + minVersion + " to " + maxVersion);
+ }
+ } else {
+ throw new SdcToscaParserException("Model is not supported. Parser supports versions " + minVersion + " to " + maxVersion);
+ }
+ }
} \ No newline at end of file
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/utils/GeneralUtility.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/utils/GeneralUtility.java
index e4d92f5..da066fc 100644
--- a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/utils/GeneralUtility.java
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/utils/GeneralUtility.java
@@ -1,8 +1,53 @@
package org.openecomp.sdc.tosca.parser.utils;
+import java.util.Arrays;
+
public class GeneralUtility {
-
- public static boolean isEmptyString(String str){
- return str == null || str.trim().isEmpty();
- }
+
+ public static boolean isEmptyString(String str) {
+ return str == null || str.trim().isEmpty();
+ }
+
+
+ /**
+ * Compares two version strings.
+ * <p>
+ * Use this instead of String.compareTo() for a non-lexicographical
+ * comparison that works for version strings. e.g. "1.10".compareTo("1.6").
+ *
+ * @param str1 a string of ordinal numbers separated by decimal points.
+ * @param str2 a string of ordinal numbers separated by decimal points.
+ * @return The result is a negative integer if str1 is _numerically_ less than str2.
+ * The result is a positive integer if str1 is _numerically_ greater than str2.
+ * The result is zero if the strings are _numerically_ equal.
+ * @note It does not work if "1.10" is supposed to be equal to "1.10.0".
+ */
+ public static int conformanceLevelCompare(String str1, String str2) {
+ String[] vals1 = str1.split("\\.");
+ String[] vals2 = str2.split("\\.");
+ int i = 0;
+ // set index to first non-equal ordinal or length of shortest version string
+ while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) {
+ i++;
+ }
+ // compare first non-equal ordinal number
+ if (i < vals1.length && i < vals2.length) {
+ int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i]));
+ return Integer.signum(diff);
+ }
+ //in case of 0 after the . e.g: "3" = "3.0" or "3.0.0.0" = "3.0"
+ str2 = str2.substring(i).replace(".", "");
+ str1 = str1.substring(i).replace(".", "");
+ if ((!(str1.equals(""))) && Integer.valueOf(str1) == 0){
+ vals1 = Arrays.copyOf(vals1, i);
+ }
+ if ((!(str2.equals(""))) && Integer.valueOf(str2) == 0){
+ vals2 = Arrays.copyOf(vals2, i);
+ }
+
+ // the strings are equal or one string is a substring of the other
+ // e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4"
+ return Integer.signum(vals1.length - vals2.length);
+ }
+
}
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/utils/YamlToObjectConverter.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/utils/YamlToObjectConverter.java
new file mode 100644
index 0000000..44444d2
--- /dev/null
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/utils/YamlToObjectConverter.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-distribution-client
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.tosca.parser.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+
+public class YamlToObjectConverter {
+
+ private static Logger log = LoggerFactory
+ .getLogger(YamlToObjectConverter.class.getName());
+
+ private static HashMap<String, Yaml> yamls = new HashMap<String, Yaml>();
+
+ private static Yaml defaultYaml = new Yaml();
+
+ private static <T> Yaml getYamlByClassName(Class<T> className) {
+
+ Yaml yaml = yamls.get(className.getName());
+ if (yaml == null) {
+ yaml = defaultYaml;
+ }
+
+ return yaml;
+ }
+
+ public <T> T convert(String dirPath, Class<T> className,
+ String configFileName) {
+
+ T config = null;
+
+ try {
+
+ String fullFileName = dirPath + File.separator + configFileName;
+
+ config = convert(fullFileName, className);
+
+ } catch (Exception e) {
+ log.error("Failed to convert yaml file " + configFileName
+ + " to object.", e);
+ }
+
+ return config;
+ }
+
+ public <T> T convert(String fullFileName, Class<T> className) {
+
+ T config = null;
+
+ Yaml yaml = getYamlByClassName(className);
+
+ InputStream in = null;
+ try {
+
+ File f = new File(fullFileName);
+ if (false == f.exists()) {
+ log.warn("The file " + fullFileName
+ + " cannot be found. Ignore reading configuration.");
+ return null;
+ }
+ in = Files.newInputStream(Paths.get(fullFileName));
+
+ config = yaml.loadAs(in, className);
+
+ // System.out.println(config.toString());
+ } catch (Exception e) {
+ log.error("Failed to convert yaml file " + fullFileName
+ + " to object.", e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return config;
+ }
+
+ public <T> T convertFromString(String yamlContents, Class<T> className) {
+
+ T config = null;
+
+ Yaml yaml = getYamlByClassName(className);
+
+ try {
+ config = yaml.loadAs(yamlContents, className);
+ } catch (Exception e){
+ log.error("Failed to convert YAML {} to object." , yamlContents, e);
+ }
+
+ return config;
+ }
+}
diff --git a/sdc-tosca-parser/src/main/resources/config/configuration.yaml b/sdc-tosca-parser/src/main/resources/config/configuration.yaml
new file mode 100644
index 0000000..379e962
--- /dev/null
+++ b/sdc-tosca-parser/src/main/resources/config/configuration.yaml
@@ -0,0 +1,3 @@
+conformanceLevel:
+ minVersion: '3.0'
+ maxVersion: '3.0' \ No newline at end of file
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 450e6b1..373ff97 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,22 +1,130 @@
package org.openecomp.sdc.impl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TestName;
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
-public class BasicTest {
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.testng.ITestContext;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
- @Rule
- public TestName testName = new TestName();
+public abstract class BasicTest {
- @Before
- public void setup(){
- System.out.println("#### Starting Test " + testName.getMethodName() + " ###########");
+ public static final String VF_CUSTOMIZATION_UUID = "56179cd8-de4a-4c38-919b-bbc4452d2d73";
+ static SdcToscaParserFactory factory;
+ static ISdcCsarHelper rainyCsarHelperSingleVf;
+ static ISdcCsarHelper rainyCsarHelperMultiVfs;
+ static ISdcCsarHelper fdntCsarHelper;
+ static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
+ @BeforeSuite
+ public static void init(ITestContext context) throws Exception {
+
+ 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>>>(){
+ {
+ HashMap<String, List<String>> FDNT ;
+
+ FDNT = new HashMap<String, List<String>>();
+ FDNT.put("VF Name", Arrays.asList("FDNT 1"));
+ FDNT.put("capabilities", Arrays.asList(
+ "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI",
+ "dnt_fw_rhrg.host_DNT_FW_SERVER",
+ "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
+ "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
+ "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
+ "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
+ "dnt_fw_rhrg.os_DNT_FW_SERVER",
+ "dnt_fw_rhrg.feature",
+ "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
+ "dnt_fw_rhrg.binding_DNT_FW_SERVER",
+ "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
+ "dnt_fw_rsg_si_1.feature"));
+ FDNT.put("requirements", Arrays.asList(
+ "DNT_FW_RSG_SI_1.dependency",
+ "DNT_FW_RHRG.dependency",
+ "DNT_FW_RHRG.link_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
+ "DNT_FW_RHRG.link_DNT_FW_CORE_DIRECT_RVMI",
+ "DNT_FW_RHRG.link_DNT_FW_OAM_PROTECTED_RVMI",
+ "DNT_FW_RHRG.link_DNT_FW_INT_DNS_TRUSTED_RVMI",
+ "DNT_FW_RHRG.link_DNT_FW_NIMBUS_HSL_RVMI",
+ "DNT_FW_RSG_SI_1.port",
+ "DNT_FW_RHRG.local_storage_DNT_FW_SERVER"));
+ FDNT.put("capabilitiesTypes", Arrays.asList(
+ "tosca.capabilities.network.Bindable",
+ "tosca.capabilities.OperatingSystem",
+ "tosca.capabilities.network.Bindable",
+ "tosca.capabilities.Scalable",
+ "tosca.capabilities.Endpoint.Admin",
+ "tosca.capabilities.network.Bindable",
+ "tosca.capabilities.network.Bindable",
+ "tosca.capabilities.network.Bindable",
+ "tosca.capabilities.Node",
+ "tosca.capabilities.Container",
+ "tosca.nodes.SoftwareComponent",
+ "tosca.capabilities.network.Bindable"));
+ FDNT.put("capabilityProperties", Arrays.asList(
+ "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI:none",
+ "dnt_fw_rhrg.host_DNT_FW_SERVER:num_cpus,integer,false;",
+ "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
+ "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
+ "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
+ "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
+ "dnt_fw_rhrg.os_DNT_FW_SERVER",
+ "dnt_fw_rhrg.feature",
+ "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
+ "dnt_fw_rhrg.binding_DNT_FW_SERVER",
+ "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);
+ };
+
+ @BeforeMethod
+ public void setupTest(Method method) {
+ System.out.println("#### Starting Test " + method.getName() + " ###########");
}
- @After
- public void tearDown(){
- System.out.println("#### Ended test " + testName.getMethodName() + " ###########");
+ @AfterMethod
+ public void tearDown(Method method){
+ System.out.println("#### Ended test " + method.getName() + " ###########");
}
}
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java
new file mode 100644
index 0000000..0e6387d
--- /dev/null
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserConfigurationTest.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.impl;
+
+import org.testng.annotations.Test;
+import org.openecomp.sdc.tosca.parser.config.Configuration;
+import org.openecomp.sdc.tosca.parser.config.ConfigurationManager;
+
+import java.io.IOException;
+
+import static org.testng.Assert.assertNotNull;
+
+public class ToscaParserConfigurationTest extends BasicTest {
+
+ @Test
+ public void testConfigurationConformanceLevel() throws IOException {
+ Configuration config = ConfigurationManager.getInstance().getConfiguration();
+ assertNotNull(config);
+ assertNotNull(config.getConformanceLevel());
+ assertNotNull(config.getConformanceLevel().getMaxVersion());
+ assertNotNull(config.getConformanceLevel().getMinVersion());
+ }
+}
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGeneralUtilTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGeneralUtilTest.java
new file mode 100644
index 0000000..b903867
--- /dev/null
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGeneralUtilTest.java
@@ -0,0 +1,23 @@
+package org.openecomp.sdc.impl;
+
+import org.testng.annotations.Test;
+import org.openecomp.sdc.tosca.parser.utils.GeneralUtility;
+
+import static org.testng.Assert.assertTrue;
+
+public class ToscaParserGeneralUtilTest extends BasicTest {
+
+ @Test
+ public void testVersionCompare() {
+ assertTrue(GeneralUtility.conformanceLevelCompare("2", "3.0") < 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("0.5", "0.5") == 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("0.5", "0.6") < 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("1.5", "2.6") < 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("0.2", "0.1") > 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("2", "1.15") > 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("2", "2.0.0") == 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("2.0", "2.0.0.0") == 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("2.", "2.0.0.0") == 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("2.0", "2.0.0.2") < 0);
+ }
+}
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 0bda21e..706c864 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
@@ -1,20 +1,20 @@
package org.openecomp.sdc.impl;
-import org.junit.Test;
+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.elements.Metadata;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.testng.Assert.*;
public class ToscaParserGroupTest extends BasicTest{
//region getVfModulesByVf
@Test
public void testVfModulesFromVf(){
- List<Group> vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID);
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
assertEquals(2, vfModulesByVf.size());
for (Group group : vfModulesByVf){
assertTrue(group.getName().startsWith("fdnt1"));
@@ -25,7 +25,7 @@ public class ToscaParserGroupTest extends BasicTest{
@Test
public void testGetGroupMetadata(){
- List<Group> vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID);
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
boolean found = false;
for (Group group : vfModulesByVf){
if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")){
@@ -40,7 +40,7 @@ public class ToscaParserGroupTest extends BasicTest{
@Test
public void testGetGroupEmptyMetadata(){
- List<Group> vfModulesByVf = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getVfModulesByVf("56179cd8-de4a-4c38-919b-bbc4452d2d72");
+ List<Group> vfModulesByVf = rainyCsarHelperMultiVfs.getVfModulesByVf("56179cd8-de4a-4c38-919b-bbc4452d2d72");
boolean found = false;
for (Group group : vfModulesByVf){
if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")){
@@ -54,14 +54,14 @@ public class ToscaParserGroupTest extends BasicTest{
@Test
public void testGetVfModuleNonExisitingVf() {
- List<Group> vfModulesByVf = ToscaParserTestSuite.rainyCsarHelperSingleVf.getVfModulesByVf("dummy");
+ List<Group> vfModulesByVf = rainyCsarHelperSingleVf.getVfModulesByVf("dummy");
assertNotNull(vfModulesByVf);
assertEquals(0, vfModulesByVf.size());
}
@Test
public void testGetVfModuleNullVf() {
- List<Group> vfModulesByVf = ToscaParserTestSuite.rainyCsarHelperSingleVf.getVfModulesByVf(null);
+ List<Group> vfModulesByVf = rainyCsarHelperSingleVf.getVfModulesByVf(null);
assertNotNull(vfModulesByVf);
assertEquals(0, vfModulesByVf.size());
}
@@ -70,28 +70,28 @@ public class ToscaParserGroupTest extends BasicTest{
//region getGroupPropertyLeafValue
@Test
public void testGroupFlatProperty() throws SdcToscaParserException {
- List<Group> vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID);
- String volumeGroup = ToscaParserTestSuite.fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "volume_group");
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ String volumeGroup = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "volume_group");
assertEquals("false", volumeGroup);
}
@Test
public void testGroupPropertyLeafValueByNullProperty() {
- List<Group> vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID);
- String groupProperty = ToscaParserTestSuite.fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), null);
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), null);
assertNull(groupProperty);
}
@Test
public void testGroupPropertyLeafValueByDummyProperty() {
- List<Group> vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID);
- String groupProperty = ToscaParserTestSuite.fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "XXX");
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "XXX");
assertNull(groupProperty);
}
@Test
public void testGroupPropertyLeafValueByNullGroup() {
- String groupProperty = ToscaParserTestSuite.fdntCsarHelper.getGroupPropertyLeafValue(null, "volume_group");
+ String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(null, "volume_group");
assertNull(groupProperty);
}
//endregion
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
index 9321bc6..802d5b8 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
@@ -1,18 +1,18 @@
package org.openecomp.sdc.impl;
-import org.junit.Test;
+import org.testng.annotations.Test;
import org.openecomp.sdc.toscaparser.api.elements.Metadata;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
public class ToscaParserMetadataTest extends BasicTest {
//region getServiceMetadata
@Test
public void testGetServiceMetadata() {
- Metadata serviceMetadata = ToscaParserTestSuite.fdntCsarHelper.getServiceMetadata();
+ Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata();
assertNotNull(serviceMetadata);
assertEquals("78c72999-1003-4a35-8534-bbd7d96fcae3", serviceMetadata.getValue("invariantUUID"));
assertEquals("Service FDNT", serviceMetadata.getValue("name"));
@@ -21,7 +21,7 @@ public class ToscaParserMetadataTest extends BasicTest {
@Test
public void testServiceMetadata() {
- Metadata metadata = ToscaParserTestSuite.rainyCsarHelperSingleVf.getServiceMetadata();
+ Metadata metadata = rainyCsarHelperSingleVf.getServiceMetadata();
assertNull(metadata);
}
//endregion
@@ -29,30 +29,39 @@ public class ToscaParserMetadataTest extends BasicTest {
//region getMetadataPropertyValue
@Test
public void testGetMetadataProperty(){
- Metadata serviceMetadata = ToscaParserTestSuite.fdntCsarHelper.getServiceMetadata();
- String metadataPropertyValue = ToscaParserTestSuite.fdntCsarHelper.getMetadataPropertyValue(serviceMetadata, "invariantUUID");
+ Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata();
+ String metadataPropertyValue = fdntCsarHelper.getMetadataPropertyValue(serviceMetadata, "invariantUUID");
assertEquals("78c72999-1003-4a35-8534-bbd7d96fcae3", metadataPropertyValue);
}
@Test
public void testGetNullMetadataPropertyValue() {
- String value = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getMetadataPropertyValue(null, "XXX");
+ String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(null, "XXX");
assertNull(value);
}
@Test
public void testGetMetadataByNullPropertyValue() {
- Metadata metadata = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceMetadata();
- String value = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, null);
+ Metadata metadata = rainyCsarHelperMultiVfs.getServiceMetadata();
+ String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, null);
assertNull(value);
}
@Test
public void testGetMetadataByEmptyPropertyValue() {
- Metadata metadata = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceMetadata();
- String value = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, "");
+ Metadata metadata = rainyCsarHelperMultiVfs.getServiceMetadata();
+ String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, "");
assertNull(value);
}
//endregion
+ //region getConformanceLevel
+ @Test
+ public void testSunnyGetConformanceLevel() {
+ String conformanceLevel = fdntCsarHelper.getConformanceLevel();
+ assertNotNull(conformanceLevel);
+ assertEquals("3.0", conformanceLevel);
+ }
+ //endregion
+
}
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 8c748f6..9a78ed5 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
@@ -1,14 +1,14 @@
package org.openecomp.sdc.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Test;
+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;
@@ -18,7 +18,7 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
//region getServiceVfList
@Test
public void testNumberOfVfSunnyFlow() throws SdcToscaParserException {
- List<NodeTemplate> serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList();
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
assertNotNull(serviceVfList);
assertEquals(2, serviceVfList.size());
}
@@ -26,7 +26,7 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
@Test
public void testSingleVFWithNotMetadata() throws SdcToscaParserException {
//If there is no metadata on VF level - There is no VF's because the type is taken from metadata values.
- List<NodeTemplate> serviceVfList = ToscaParserTestSuite.rainyCsarHelperSingleVf.getServiceVfList();
+ List<NodeTemplate> serviceVfList = rainyCsarHelperSingleVf.getServiceVfList();
assertNotNull(serviceVfList);
assertEquals(0, serviceVfList.size());
}
@@ -35,54 +35,54 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
//region getNodeTemplatePropertyLeafValue
@Test
public void testNodeTemplateFlatProperty() throws SdcToscaParserException {
- List<NodeTemplate> serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList();
- assertEquals("2", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "availability_zone_max_count"));
- assertEquals("3", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "max_instances"));
- assertEquals("some code", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_naming_code"));
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ assertEquals("2", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "availability_zone_max_count"));
+ assertEquals("3", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "max_instances"));
+ assertEquals("some code", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_naming_code"));
}
@Test
public void testNodeTemplateNestedProperty() throws SdcToscaParserException {
- List<NodeTemplate> serviceVlList = ToscaParserTestSuite.fdntCsarHelper.getServiceVlList();
+ List<NodeTemplate> serviceVlList = fdntCsarHelper.getServiceVlList();
NodeTemplate nodeTemplate = serviceVlList.get(0);
//System.out.println("node template " + nodeTemplate.toString());
- assertEquals("24", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#cidr_mask"));
- assertEquals("7a6520b-9982354-ee82992c-105720", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_flows#vpn_binding"));
+ 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 = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList();
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
NodeTemplate nodeTemplate = serviceVfList.get(0);
//System.out.println("node template " + nodeTemplate.toString());
- assertEquals("true", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#ecomp_generated_naming"));
- assertEquals("FDNT_instance_VF_2", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#naming_policy"));
+ assertEquals("true", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#ecomp_generated_naming"));
+ assertEquals("FDNT_instance_VF_2", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#naming_policy"));
}
@Test
public void testNodeTemplateNestedPropertyNotExists() throws SdcToscaParserException {
- List<NodeTemplate> serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList();
- String nodeTemplatePropertyLeafValue = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_role#nf_naming#kuku");
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ String nodeTemplatePropertyLeafValue = fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_role#nf_naming#kuku");
assertNull(nodeTemplatePropertyLeafValue);
}
@Test
public void testNodeTemplateFlatPropertyByNotFoundProperty() throws SdcToscaParserException {
- List<NodeTemplate> serviceVfList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceVfList();
- String nodeTemplatePropertyLeafValue = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "XXXX");
+ List<NodeTemplate> serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList();
+ String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "XXXX");
assertNull(nodeTemplatePropertyLeafValue);
}
@Test
public void testNodeTemplateFlatPropertyByNullProperty() throws SdcToscaParserException {
- List<NodeTemplate> serviceVfList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceVfList();
- String nodeTemplatePropertyLeafValue = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), null);
+ List<NodeTemplate> serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList();
+ String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), null);
assertNull(nodeTemplatePropertyLeafValue);
}
@Test
public void testNodeTemplateFlatPropertyByNullNodeTemplate() throws SdcToscaParserException {
- String nodeTemplatePropertyLeafValue = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(null, "availability_zone_max_count");
+ String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(null, "availability_zone_max_count");
assertNull(nodeTemplatePropertyLeafValue);
}
//endregion
@@ -90,14 +90,14 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
//region getServiceVlList
@Test
public void testServiceVl() {
- List<NodeTemplate> vlList = ToscaParserTestSuite.fdntCsarHelper.getServiceVlList();
+ List<NodeTemplate> vlList = fdntCsarHelper.getServiceVlList();
assertEquals(1, vlList.size());
assertEquals("exVL", vlList.get(0).getName());
}
@Test
public void testNumberOfVLRainyFlow() throws SdcToscaParserException {
- List<NodeTemplate> serviceVlList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceVlList();
+ List<NodeTemplate> serviceVlList = rainyCsarHelperMultiVfs.getServiceVlList();
assertNotNull(serviceVlList);
assertEquals(0, serviceVlList.size());
}
@@ -106,21 +106,21 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
//region getServiceNodeTemplatesByType
@Test
public void testServiceNodeTemplatesByType() throws SdcToscaParserException {
- List<NodeTemplate> serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceNodeTemplatesByType("org.openecomp.resource.vf.Fdnt");
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceNodeTemplatesByType("org.openecomp.resource.vf.Fdnt");
assertNotNull(serviceVfList);
assertEquals(1, serviceVfList.size());
}
@Test
public void testServiceNodeTemplatesByNull() {
- List<NodeTemplate> nodeTemplates = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType(null);
+ List<NodeTemplate> nodeTemplates = rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType(null);
assertNotNull(nodeTemplates);
assertEquals(0, nodeTemplates.size());
}
@Test
public void testServiceNodeTemplatesByNotFoundProperty() {
- List<NodeTemplate> nodeTemplates = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType("XXX");
+ List<NodeTemplate> nodeTemplates = rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType("XXX");
assertNotNull(nodeTemplates);
assertEquals(0, nodeTemplates.size());
}
@@ -129,14 +129,14 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
//region getTypeOfNodeTemplate
@Test
public void testGetTypeOfNodeTemplate() {
- List<NodeTemplate> serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList();
- String typeOfNodeTemplate = ToscaParserTestSuite.fdntCsarHelper.getTypeOfNodeTemplate(serviceVfList.get(0));
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ String typeOfNodeTemplate = fdntCsarHelper.getTypeOfNodeTemplate(serviceVfList.get(0));
assertEquals("org.openecomp.resource.vf.Fdnt", typeOfNodeTemplate);
}
@Test
public void testGetTypeOfNullNodeTemplate() {
- String typeOfNodeTemplate = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getTypeOfNodeTemplate(null);
+ String typeOfNodeTemplate = rainyCsarHelperMultiVfs.getTypeOfNodeTemplate(null);
assertNull(typeOfNodeTemplate);
}
//endregion
@@ -144,13 +144,13 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
//region getAllottedResources
@Test
public void testGetAllottedResources() {
- List<NodeTemplate> allottedResources = ToscaParserTestSuite.fdntCsarHelper.getAllottedResources();
+ List<NodeTemplate> allottedResources = fdntCsarHelper.getAllottedResources();
assertEquals(1, allottedResources.size());
}
@Test
public void testGetAllottedResourcesZero() {
- List<NodeTemplate> allottedResources = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getAllottedResources();
+ List<NodeTemplate> allottedResources = rainyCsarHelperMultiVfs.getAllottedResources();
assertNotNull(allottedResources);
assertEquals(0, allottedResources.size());
}
@@ -159,20 +159,20 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
//region getVfcListByVf
@Test
public void testGetVfcFromVf() {
- List<NodeTemplate> vfcListByVf = ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID);
+ List<NodeTemplate> vfcListByVf = fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID);
assertEquals(2, vfcListByVf.size());
}
@Test
public void testVfcListByNull() {
- List<NodeTemplate> vfcList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getVfcListByVf(null);
+ List<NodeTemplate> vfcList = rainyCsarHelperMultiVfs.getVfcListByVf(null);
assertNotNull(vfcList);
assertEquals(0, vfcList.size());
}
@Test
public void testVfcListByNotFoundProperty() {
- List<NodeTemplate> vfcList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getVfcListByVf("XXX");
+ List<NodeTemplate> vfcList = rainyCsarHelperMultiVfs.getVfcListByVf("XXX");
assertNotNull(vfcList);
assertEquals(0, vfcList.size());
}
@@ -181,7 +181,7 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
//region getCpListByVf
@Test
public void testGetCpFromVf() {
- List<NodeTemplate> cpListByVf = ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID);
+ List<NodeTemplate> cpListByVf = fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID);
assertEquals(1, cpListByVf.size());
NodeTemplate nodeTemplate = cpListByVf.get(0);
assertEquals("DNT_PORT", nodeTemplate.getName());
@@ -189,14 +189,14 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
@Test
public void testGetCpFromVfByNullId() {
- List<NodeTemplate> cpListByVf = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getCpListByVf(null);
+ List<NodeTemplate> cpListByVf = rainyCsarHelperMultiVfs.getCpListByVf(null);
assertNotNull(cpListByVf);
assertEquals(0, cpListByVf.size());
}
@Test
public void testGetCpFromVfXxx() {
- List<NodeTemplate> cpListByVf = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getCpListByVf("XXXXX");
+ List<NodeTemplate> cpListByVf = rainyCsarHelperMultiVfs.getCpListByVf("XXXXX");
assertNotNull(cpListByVf);
assertEquals(0, cpListByVf.size());
}
@@ -205,7 +205,7 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
//region getNodeTemplatePairsByReqName
@Test
public void testGetNodeTemplatePairsByReqName() {
- List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName(ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), "binding");
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding");
assertNotNull(nodeTemplatePairsByReqName);
assertEquals(1, nodeTemplatePairsByReqName.size());
Pair<NodeTemplate, NodeTemplate> pair = nodeTemplatePairsByReqName.get(0);
@@ -217,40 +217,40 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
@Test
public void testGetNodeTemplatePairsByReqNameWithNullVF() {
- List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName(
- null, ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), "binding");
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ null, fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding");
assertNotNull(nodeTemplatePairsByReqName);
assertEquals(0, nodeTemplatePairsByReqName.size());
}
@Test
public void testGetNodeTemplatePairsByReqNameWithEmptyVF() {
- List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName(
- new ArrayList<>(), ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), "binding");
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ new ArrayList<>(), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding");
assertNotNull(nodeTemplatePairsByReqName);
assertEquals(0, nodeTemplatePairsByReqName.size());
}
@Test
public void testGetNodeTemplatePairsByReqNameWithNullCap() {
- List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName(
- ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), null, "binding");
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), null, "binding");
assertNotNull(nodeTemplatePairsByReqName);
assertEquals(0, nodeTemplatePairsByReqName.size());
}
@Test
public void testGetNodeTemplatePairsByReqNameWithEmptyCap() {
- List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName(
- ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), new ArrayList<>(), "binding");
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), new ArrayList<>(), "binding");
assertNotNull(nodeTemplatePairsByReqName);
assertEquals(0, nodeTemplatePairsByReqName.size());
}
@Test
public void testGetNodeTemplatePairsByReqNameWithNullReq() {
- List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName(
- ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), null);
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), null);
assertNotNull(nodeTemplatePairsByReqName);
assertEquals(0, nodeTemplatePairsByReqName.size());
}
@@ -258,8 +258,8 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
@Test
public void testGetNodeTemplatePairsByReqNameWithDummyReq() {
- List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePairsByReqName(
- ToscaParserTestSuite.fdntCsarHelper.getCpListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), ToscaParserTestSuite.fdntCsarHelper.getVfcListByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID), "XXX");
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "XXX");
assertNotNull(nodeTemplatePairsByReqName);
assertEquals(0, nodeTemplatePairsByReqName.size());
}
@@ -268,11 +268,11 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
//region getMembersOfVfModule
@Test
public void testGetMembersOfVfModule() {
- NodeTemplate vf = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList().get(0);
- List<Group> vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID);
+ NodeTemplate vf = fdntCsarHelper.getServiceVfList().get(0);
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
assertEquals(2, vfModulesByVf.size());
for (Group group : vfModulesByVf) {
- List<NodeTemplate> membersOfVfModule = ToscaParserTestSuite.fdntCsarHelper.getMembersOfVfModule(vf, group);
+ List<NodeTemplate> membersOfVfModule = fdntCsarHelper.getMembersOfVfModule(vf, group);
assertNotNull(membersOfVfModule);
if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")) {
assertEquals(1, membersOfVfModule.size());
@@ -289,16 +289,16 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
@Test
public void testMembersOfVfModuleByNullVf() {
- List<Group> vfModulesByVf = ToscaParserTestSuite.fdntCsarHelper.getVfModulesByVf(ToscaParserTestSuite.VF_CUSTOMIZATION_UUID);
- List<NodeTemplate> nodeTemplates = ToscaParserTestSuite.fdntCsarHelper.getMembersOfVfModule(null, vfModulesByVf.get(0));
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ List<NodeTemplate> nodeTemplates = fdntCsarHelper.getMembersOfVfModule(null, vfModulesByVf.get(0));
assertNotNull(nodeTemplates);
assertEquals(0, nodeTemplates.size());
}
@Test
public void testMembersOfVfModuleByNullGroup() {
- List<NodeTemplate> serviceVfList = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceVfList();
- List<NodeTemplate> nodeTemplates = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getMembersOfVfModule(serviceVfList.get(0), null);
+ List<NodeTemplate> serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList();
+ List<NodeTemplate> nodeTemplates = rainyCsarHelperMultiVfs.getMembersOfVfModule(serviceVfList.get(0), null);
assertNotNull(nodeTemplates);
assertEquals(0, nodeTemplates.size());
}
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 3444e53..d357d21 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
@@ -1,27 +1,27 @@
package org.openecomp.sdc.impl;
-import org.junit.Test;
+import org.testng.annotations.Test;
import org.openecomp.sdc.toscaparser.api.parameters.Input;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
public class ToscaParserServiceInputTest extends BasicTest {
//region getServiceInputs
@Test
public void testGetServiceInputs(){
- List<Input> serviceInputs = ToscaParserTestSuite.fdntCsarHelper.getServiceInputs();
+ List<Input> serviceInputs = fdntCsarHelper.getServiceInputs();
assertNotNull(serviceInputs);
assertEquals(1, serviceInputs.size());
}
@Test
public void testServiceInputs() {
- List<Input> inputs = ToscaParserTestSuite.rainyCsarHelperSingleVf.getServiceInputs();
+ List<Input> inputs = rainyCsarHelperSingleVf.getServiceInputs();
assertNotNull(inputs);
assertEquals(0, inputs.size());
}
@@ -30,19 +30,19 @@ public class ToscaParserServiceInputTest extends BasicTest {
//region getServiceInputLeafValueOfDefault
@Test
public void testGetServiceInputLeafValue(){
- String serviceInputLeafValue = ToscaParserTestSuite.fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default");
+ String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default");
assertEquals("test service naming", serviceInputLeafValue);
}
@Test
public void testGetServiceInputLeafValueNotExists(){
- String serviceInputLeafValue = ToscaParserTestSuite.fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default#kuku");
+ String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default#kuku");
assertNull(serviceInputLeafValue);
}
@Test
public void testGetServiceInputLeafValueNull(){
- String serviceInputLeafValue = ToscaParserTestSuite.fdntCsarHelper.getServiceInputLeafValueOfDefault(null);
+ String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault(null);
assertNull(serviceInputLeafValue);
}
//endregion
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java
index fc0aff5..c61f465 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java
@@ -1,24 +1,132 @@
package org.openecomp.sdc.impl;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+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.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.elements.CapabilityTypeDef;
+//import org.testng.ReporterConfig.Property;
+import org.testng.annotations.Test;
+import org.openecomp.sdc.toscaparser.api.Property;
+
+//import static org.junit.Assert.assertEquals;
+//import static org.junit.Assert.assertNull;
public class ToscaParserSubsMappingsTest extends BasicTest {
//region getServiceSubstitutionMappingsTypeName
@Test
public void testGetServiceSubstitutionMappingsTypeName() {
- String serviceSubstitutionMappingsTypeName = ToscaParserTestSuite.fdntCsarHelper.getServiceSubstitutionMappingsTypeName();
+ String serviceSubstitutionMappingsTypeName = fdntCsarHelper.getServiceSubstitutionMappingsTypeName();
assertEquals("org.openecomp.service.ServiceFdnt", serviceSubstitutionMappingsTypeName);
}
@Test
public void testServiceSubstitutionMappingsTypeName() {
- String substitutionMappingsTypeName = ToscaParserTestSuite.rainyCsarHelperMultiVfs.getServiceSubstitutionMappingsTypeName();
+ String substitutionMappingsTypeName = rainyCsarHelperMultiVfs.getServiceSubstitutionMappingsTypeName();
assertNull(substitutionMappingsTypeName);
}
//endregion
+
+ //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
+ }
+
+ //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
+ }
+
+ //@Test // - BUG 283387
+ public void testRequirmentsofVF() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ String sName = serviceVfList.get(0).getName();
+ assertEquals(sName,"FDNT 1");
+
+ List<String> ActualReqsValues = new ArrayList<>(Arrays.asList( ));
+
+ ArrayList<Object> lRequirements = serviceVfList.get(0).getRequirements();
+
+ assertEquals(fdntCsarHelper_Data.get("FDNT").get("requirements").size(),lRequirements.size()); //
+
+ // Continue from here after bug is fixed ! ! ! ! - Test the Requirements values
+ }
}
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserTestSuite.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserTestSuite.java
deleted file mode 100644
index 83e7d13..0000000
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserTestSuite.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.openecomp.sdc.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-
-import org.junit.BeforeClass;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-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.openecomp.sdc.toscaparser.api.common.ExceptionCollector;
-import org.openecomp.sdc.toscaparser.api.common.JToscaException;
-
-@RunWith( Suite.class )
-@Suite.SuiteClasses( {
- ToscaParserNodeTemplateTest.class,
- ToscaParserSubsMappingsTest.class,
- ToscaParserGroupTest.class,
- ToscaParserMetadataTest.class,
- ToscaParserServiceInputTest.class,
-} )
-public class ToscaParserTestSuite {
-
- public static final String VF_CUSTOMIZATION_UUID = "56179cd8-de4a-4c38-919b-bbc4452d2d73";
- static SdcToscaParserFactory factory;
- static ISdcCsarHelper rainyCsarHelperSingleVf;
- static ISdcCsarHelper rainyCsarHelperMultiVfs;
- static ISdcCsarHelper fdntCsarHelper;
-
- @BeforeClass
- public static void init() throws SdcToscaParserException, JToscaException, IOException {
-
- factory = SdcToscaParserFactory.getInstance();
- fdntCsarHelper = getCsarHelper("csars/service-ServiceFdnt-with-allotted.csar");
- rainyCsarHelperMultiVfs = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar");
- rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar");
- }
-
- private static ISdcCsarHelper getCsarHelper(String path) throws JToscaException, IOException, SdcToscaParserException {
- System.out.println("Parsing CSAR "+path+"...");
- String fileStr1 = ToscaParserTestSuite.class.getClassLoader().getResource(path).getFile();
- File file1 = new File(fileStr1);
- ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
- ArrayList<String> exceptionReport = ExceptionCollector.getExceptionReport();
- 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;
- }
-
-}
diff --git a/sdc-tosca-parser/src/test/resources/config/configuration.yaml b/sdc-tosca-parser/src/test/resources/config/configuration.yaml
new file mode 100644
index 0000000..379e962
--- /dev/null
+++ b/sdc-tosca-parser/src/test/resources/config/configuration.yaml
@@ -0,0 +1,3 @@
+conformanceLevel:
+ minVersion: '3.0'
+ maxVersion: '3.0' \ No newline at end of file
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-0904-2.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-0904-2.csar
index fc21af3..4f57b71 100644
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-0904-2.csar
+++ b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-0904-2.csar
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar
index 7752244..f3b3a46 100644
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar
+++ b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar.csar
index 6179316..983dc9b 100644
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar.csar
+++ b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar.csar
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar
index a343e84..ef6d03e 100644
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar
+++ b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar
Binary files differ