From 4f81700f5d8826d59164c4976a26631c2113e38f Mon Sep 17 00:00:00 2001 From: "k.kedron" Date: Mon, 9 Mar 2020 17:08:53 +0100 Subject: Added new unit tests Added new unit tests to GraphMLDataAnalyzer class. Fixed the Sonar issue. Issue-ID: SDC-2327 Signed-off-by: Krystian Kedron Change-Id: I9a61dff2e9b0be1733de00b06c255abb8a3d5a8f --- .../sdc/asdctool/impl/GraphMLDataAnalyzerTest.java | 45 +++++++++++++++------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'asdctool/src/test/java') diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzerTest.java index 7757b475bc..bffc0daee1 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzerTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzerTest.java @@ -7,9 +7,9 @@ * 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. @@ -22,20 +22,37 @@ package org.openecomp.sdc.asdctool.impl; import org.junit.Test; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.openecomp.sdc.asdctool.impl.GraphMLDataAnalyzer.EXCEL_EXTENSION; +import static org.openecomp.sdc.asdctool.impl.GraphMLDataAnalyzer.GRAPH_ML_EXTENSION; +import static org.testng.AssertJUnit.assertNotNull; + public class GraphMLDataAnalyzerTest { - private GraphMLDataAnalyzer createTestSubject() { - return new GraphMLDataAnalyzer(); - } + public static final String FILE_NAME = "export"; + + @Test + public void testAnalyzeGraphMLDataNoFile() { + String[] args = new String[]{"noExistFile"}; + + // default test + GraphMLDataAnalyzer graph = new GraphMLDataAnalyzer(); + String result = graph.analyzeGraphMLData(args); + + assertNull(result); + } + + @Test + public void testAnalyzeGraphMLData() { + String path = getClass().getClassLoader().getResource(FILE_NAME + GRAPH_ML_EXTENSION).getPath(); + String[] args = new String[]{path}; - @Test - public void testAnalyzeGraphMLData() throws Exception { - GraphMLDataAnalyzer testSubject; - String[] args = new String[] { "export", "src/main/resources/config/janusgraph.properties", "./" }; - String result; + // default test + GraphMLDataAnalyzer graph = new GraphMLDataAnalyzer(); + String result = graph.analyzeGraphMLData(args); - // default test - testSubject = createTestSubject(); - result = testSubject.analyzeGraphMLData(args); - } + assertNotNull(result); + assertTrue(result.endsWith(EXCEL_EXTENSION)); + } } -- cgit 1.2.3-korg