summaryrefslogtreecommitdiffstats
path: root/sdc-tosca-parser
diff options
context:
space:
mode:
authorPavel Aharoni <pa0916@att.com>2017-05-04 20:04:08 +0300
committerPavel Aharoni <pa0916@att.com>2017-05-04 20:04:08 +0300
commitf09c2646860e66de2d91bccd61217ce22abfe75d (patch)
treef181ac6c71ddf9a480ffeb38efa0b4517df19b2b /sdc-tosca-parser
parent04e7fa443307328986942c66fbcb01693c8f9ccb (diff)
[SDC-15] allotted resource CSAR fixes
Change-Id: I31dcd0a6b697357fed0e7f8c431b5317339b3c74 Signed-off-by: Pavel Aharoni <pa0916@att.com>
Diffstat (limited to 'sdc-tosca-parser')
-rw-r--r--sdc-tosca-parser/pom.xml8
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java2
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java4
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserTestSuite.java58
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-allotted-resources-4.csarbin39949 -> 0 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-cp-vfc-req-cap-8.csarbin40116 -> 0 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-flat-input-9-1.csarbin40109 -> 0 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-group-meta-10.csarbin40119 -> 0 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-groups-status-supported-case-3.csarbin39943 -> 0 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-inputs-9.csarbin40130 -> 0 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-nt-props-1.csarbin39948 -> 0 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-nt-tt-metadata-2.csarbin39938 -> 0 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-service-vl-7.csarbin40014 -> 0 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-two-vfs-5.csarbin39964 -> 0 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csarbin0 -> 44991 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-vmme-csar.csarbin74074 -> 0 bytes
16 files changed, 32 insertions, 40 deletions
diff --git a/sdc-tosca-parser/pom.xml b/sdc-tosca-parser/pom.xml
index 56cc293..f05622f 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.8-SNAPSHOT</version>
+ <version>1.1.9-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.0-SNAPSHOT</version>
+ <version>0.1.1-SNAPSHOT</version>
</dependency>
@@ -111,12 +111,12 @@
<scope>test</scope>
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
<scope>test</scope>
- </dependency>
+ </dependency> -->
</dependencies>
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 b5fb6af..000b381 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
@@ -385,7 +385,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
log.error("getAllottedResources nodeTemplates not exist");
}
nodeTemplates = nodeTemplates.stream().filter(
- x -> x.getMetaData() != null && x.getMetaData().getValue("category").equals("Allotted Resources"))
+ x -> x.getMetaData() != null && x.getMetaData().getValue("category").equals("Allotted Resource"))
.collect(Collectors.toList());
if (nodeTemplates.isEmpty()) {
log.debug("getAllottedResources - allotted resources not exist");
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 469ddd2..7c30616 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
@@ -20,7 +20,7 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
public void testNumberOfVfSunnyFlow() throws SdcToscaParserException {
List<NodeTemplate> serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList();
assertNotNull(serviceVfList);
- assertEquals(1, serviceVfList.size());
+ assertEquals(2, serviceVfList.size());
}
@Test
@@ -136,7 +136,7 @@ public class ToscaParserNodeTemplateTest extends BasicTest {
@Test
public void testGetAllottedResources() {
List<NodeTemplate> allottedResources = ToscaParserTestSuite.fdntCsarHelper.getAllottedResources();
- assertEquals(0, allottedResources.size());
+ assertEquals(1, allottedResources.size());
}
@Test
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
index d4b474f..83e7d13 100644
--- 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
@@ -1,16 +1,18 @@
package org.openecomp.sdc.impl;
-import org.junit.*;
-import org.junit.runners.Suite;
+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;
-import java.io.File;
-import java.io.IOException;
-
@RunWith( Suite.class )
@Suite.SuiteClasses( {
ToscaParserNodeTemplateTest.class,
@@ -31,34 +33,24 @@ public class ToscaParserTestSuite {
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 = ToscaParserTestSuite.class.getClassLoader().getResource("csars/service-ServiceFdnt-csar-0904-2.csar").getFile();
+ 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);
- startTime = System.currentTimeMillis();
-
- fdntCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
-
- estimatedTime = System.currentTimeMillis() - startTime;
- System.out.println("init CSAR Execution time: " + estimatedTime);
-
- String fileStr2 = ToscaParserTestSuite.class.getClassLoader().getResource("csars/service-ServiceFdnt-csar-rainy.csar").getFile();
- File file2 = new File(fileStr2);
- rainyCsarHelperMultiVfs = factory.getSdcCsarHelper(file2.getAbsolutePath());
-
- String fileStr3 = ToscaParserTestSuite.class.getClassLoader().getResource("csars/service-ServiceFdnt-csar.csar").getFile();
- File file3 = new File(fileStr3);
- rainyCsarHelperSingleVf = factory.getSdcCsarHelper(file3.getAbsolutePath());
- };
-
- @AfterClass
- public static void after(){
- long startTime = System.currentTimeMillis();
- long estimatedTime = System.currentTimeMillis() - startTime;
- System.out.println("close Execution time: "+estimatedTime);
- };
-
+ 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/csars/service-ServiceFdnt-csar-allotted-resources-4.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-allotted-resources-4.csar
deleted file mode 100644
index 7b4cff2..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-allotted-resources-4.csar
+++ /dev/null
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-cp-vfc-req-cap-8.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-cp-vfc-req-cap-8.csar
deleted file mode 100644
index be254a0..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-cp-vfc-req-cap-8.csar
+++ /dev/null
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-flat-input-9-1.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-flat-input-9-1.csar
deleted file mode 100644
index 4ae4c6f..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-flat-input-9-1.csar
+++ /dev/null
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-group-meta-10.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-group-meta-10.csar
deleted file mode 100644
index 5bcf960..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-group-meta-10.csar
+++ /dev/null
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-groups-status-supported-case-3.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-groups-status-supported-case-3.csar
deleted file mode 100644
index 7286663..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-groups-status-supported-case-3.csar
+++ /dev/null
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-inputs-9.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-inputs-9.csar
deleted file mode 100644
index c1c2855..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-inputs-9.csar
+++ /dev/null
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-nt-props-1.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-nt-props-1.csar
deleted file mode 100644
index ceac90a..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-nt-props-1.csar
+++ /dev/null
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-nt-tt-metadata-2.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-nt-tt-metadata-2.csar
deleted file mode 100644
index 3cda214..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-nt-tt-metadata-2.csar
+++ /dev/null
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-service-vl-7.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-service-vl-7.csar
deleted file mode 100644
index db3af99..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-service-vl-7.csar
+++ /dev/null
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-two-vfs-5.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-two-vfs-5.csar
deleted file mode 100644
index 565929a..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-csar-two-vfs-5.csar
+++ /dev/null
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
new file mode 100644
index 0000000..41ee2c7
--- /dev/null
+++ b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-vmme-csar.csar b/sdc-tosca-parser/src/test/resources/csars/service-vmme-csar.csar
deleted file mode 100644
index 416707c..0000000
--- a/sdc-tosca-parser/src/test/resources/csars/service-vmme-csar.csar
+++ /dev/null
Binary files differ