aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool/src/main/java/org
diff options
context:
space:
mode:
authork.kedron <k.kedron@partner.samsung.com>2020-03-09 17:08:53 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2020-03-10 10:24:06 +0000
commit4f81700f5d8826d59164c4976a26631c2113e38f (patch)
tree1d08b45d33301647429eba7541bd1002686a8f13 /asdctool/src/main/java/org
parent0574f88247e18e830663802c2167df3166e1792b (diff)
Added new unit tests
Added new unit tests to GraphMLDataAnalyzer class. Fixed the Sonar issue. Issue-ID: SDC-2327 Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com> Change-Id: I9a61dff2e9b0be1733de00b06c255abb8a3d5a8f
Diffstat (limited to 'asdctool/src/main/java/org')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
index 21e22be10c..312d862747 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
@@ -26,6 +26,7 @@ import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.jdom2.Document;
import org.jdom2.Element;
+import org.jdom2.JDOMException;
import org.jdom2.filter.ElementFilter;
import org.jdom2.input.SAXBuilder;
import org.jdom2.util.IteratorIterable;
@@ -34,6 +35,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -48,34 +50,37 @@ public class GraphMLDataAnalyzer {
private static final String[] COMPONENT_INSTANCES_SHEET_HEADER =
{"uniqueId", "name", "originUid", "originType", "containerUid"};
+ public static final String GRAPH_ML_EXTENSION = ".graphml";
+ public static final String EXCEL_EXTENSION = ".xls";
+
public String analyzeGraphMLData(String[] args) {
- String result = null;
+ String result;
try {
String mlFileLocation = args[0];
result = analyzeGraphMLData(mlFileLocation);
- log.info("Analyzed ML file=" + mlFileLocation + ", XLS result=" + result);
+ log.info("Analyzed ML file={}, XLS result={}", mlFileLocation, result);
} catch (Exception e) {
- log.error("analyze GraphML Data failed - {}", e);
+ log.error("Analyze GraphML Data failed!", e);
return null;
}
return result;
}
- private String analyzeGraphMLData(String mlFileLocation) throws Exception {
+ private String analyzeGraphMLData(String mlFileLocation) throws JDOMException, IOException {
// Parse ML file
SAXBuilder builder = new SAXBuilder();
File xmlFile = new File(mlFileLocation);
Document document = builder.build(xmlFile);
// XLS data file name
- String outputFile = mlFileLocation.replace(".graphml", ".xls");
+ String outputFile = mlFileLocation.replace(GRAPH_ML_EXTENSION, EXCEL_EXTENSION);
try (Workbook wb = new HSSFWorkbook(); FileOutputStream fileOut = new FileOutputStream(outputFile)) {
writeComponents(wb, document);
writeComponentInstances(wb, document);
wb.write(fileOut);
} catch (Exception e) {
- log.error("analyze GraphML Data failed - {}", e);
+ log.error("Analyze GraphML Data failed!", e);
}
return outputFile;
}