aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-distribution-ci
diff options
context:
space:
mode:
authorPavel Aharoni <pa0916@att.com>2017-05-11 19:32:07 +0300
committerPavel Aharoni <pa0916@att.com>2017-05-11 19:32:07 +0300
commit8caef088a9e5467cd0cb462acb217edceedac8fe (patch)
treee47c41688833daf2ac76e53324992be1f15d2e56 /sdc-distribution-ci
parentaf2d8ef12f6b75ae837fffdeaf5d152756cec6d6 (diff)
[SDC-19] VFC to CP props
Change-Id: I217934251fd8eeaf883b60161826306d6b7eaf3c Signed-off-by: Pavel Aharoni <pa0916@att.com>
Diffstat (limited to 'sdc-distribution-ci')
-rw-r--r--sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java66
1 files changed, 61 insertions, 5 deletions
diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java
index 4dae5eb..0ac842c 100644
--- a/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java
+++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java
@@ -1,18 +1,74 @@
package org.openecomp.test;
-import java.util.ArrayList;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
import org.openecomp.sdc.toscaparser.api.common.ExceptionCollector;
+import org.openecomp.sdc.toscaparser.api.parameters.Input;
public class CsarToscaTester {
public static void main(String[] args) throws Exception {
ClassLoader loader = CsarToscaTester.class.getClassLoader();
- System.out.println("CsarToscaParser - path to CSAR is "+Arrays.toString(args));
+ System.out.println("CsarToscaParser - path to CSAR's Directory is " + Arrays.toString(args));
SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
- factory.getSdcCsarHelper(args[0]);
- ArrayList<String> exceptionReport = ExceptionCollector.getExceptionReport();
- System.out.println("Errors during CSAR parsing are: "+(exceptionReport != null ? exceptionReport.toString() : "none"));
+
+ File folder = new File(args[0].toString());
+ File[] listOfFiles = folder.listFiles();
+ FileWriter fw;
+
+ Date now = new Date();
+ SimpleDateFormat dateFormat = new SimpleDateFormat("d-MM-y-HH_mm_ss");
+ String time = dateFormat.format(now);
+ File dir = new File(args[1].toString() + "/csar-reports-" + time);
+ dir.mkdir();
+
+
+ for (File file : listOfFiles) {
+ if (file.isFile()) {
+ System.out.println("File " + file.getAbsolutePath());
+ ExceptionCollector.clear();
+
+ ISdcCsarHelper csarHelper = factory.getSdcCsarHelper(file.getAbsolutePath());
+ List<NodeTemplate> vflist = csarHelper.getServiceVfList();
+ List<Input> inputs = csarHelper.getServiceInputs();
+ List<String> exceptionReport = ExceptionCollector.getCriticalsReport();
+ System.out.println("CRITICALS during CSAR parsing are: " + (exceptionReport != null ? exceptionReport.toString() : "none"));
+ List<String> warningsReport = ExceptionCollector.getWarningsReport();
+ System.out.println("WARNINGS during CSAR parsing are: " + (warningsReport != null ? warningsReport.toString() : "none"));
+
+
+ if (!exceptionReport.isEmpty()) {
+
+ try {
+ fw = new FileWriter(new File(dir + "/critical-" + file.getName() + ".txt"));
+ for (String exception : exceptionReport) {
+ fw.write(exception);
+ fw.write("\r\n");
+ }
+ fw.close();
+
+ fw = new FileWriter(new File(dir + "/warning-" + file.getName() + ".txt"));
+ for (String warning : warningsReport) {
+ fw.write(warning);
+ fw.write("\r\n");
+ }
+ fw.close();
+
+
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ }
}
}