aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java
diff options
context:
space:
mode:
authorOfir Sonsino <os0695@att.com>2018-01-31 17:19:00 +0200
committerOfir Sonsino <os0695@att.com>2018-01-31 17:19:00 +0200
commit1cfb08779ea0e00be69e072a940b3063e049fe6b (patch)
tree6602a900387c8393ed0dcd81c0539381632903c6 /vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java
parent2f20b001b9243e0f8b44aecc768ec265fd538732 (diff)
org.onap migration
Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d Issue-ID: VID-86 Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java
new file mode 100644
index 000000000..051a1cf45
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java
@@ -0,0 +1,80 @@
+//package org.onap.vid.services;
+//import org.apache.commons.io.IOUtils;
+//import org.onap.vid.services.CsvServiceImpl;
+//import org.skyscreamer.jsonassert.JSONAssert;
+//import org.skyscreamer.jsonassert.JSONCompareMode;
+//import org.testng.Assert;
+//import org.testng.annotations.DataProvider;
+//import org.testng.annotations.Test;
+//import org.json.JSONObject;
+//
+//import javax.ws.rs.BadRequestException;
+//import java.io.IOException;
+//import java.lang.reflect.Method;
+//import java.net.URL;
+//import java.util.List;
+//
+//@Test
+//public class CsvServiceTest {
+//
+// private CsvServiceImpl csvService = new CsvServiceImpl();
+// private final static String CSV_FOLDER = "csv_files/{CSV_FILE}";
+// private final static String VALID_CSV = "csv_to_json.csv";
+// private final static String ONE_LINE_CSV = "one_line.csv";
+// private final static String EMPTY_CSV = "empty_file.csv";
+// private final static String MISSING_CONTENT_CSV = "missing_content.csv";
+// private final static String MISSING_VALUES_CSV = "missing_values.csv";
+//
+//
+///*
+// @Test
+// public void parseValidCsv() throws IllegalAccessException, IOException, InstantiationException {
+// String expectedJson = getExpectation("vnfConfigUpdatePayload.json");
+// readAndParse(VALID_CSV,16,expectedJson);
+//
+// }*/
+//
+// private String getExpectation(String modelFileName) throws IOException {
+// // load expected result
+// final URL resource = this.getClass().getResource("/" + modelFileName);
+// String expected = IOUtils.toString(resource, "UTF-8");
+// return expected;
+// }
+///*
+// @Test
+// public void parseOneLineCsv() throws IllegalAccessException, IOException, InstantiationException {
+// String expectedJson ="{\"payload\":{\"request-parameters\":{\"vnf-name\":\"ibcx0099v\"}}}";
+// readAndParse(ONE_LINE_CSV,1,expectedJson);
+// }*/
+//
+// @DataProvider
+// public static Object[][] invalidFiles(Method test) {
+// return new Object[][]{
+// {MISSING_CONTENT_CSV}, {MISSING_VALUES_CSV}
+// };
+// }
+///*
+// @Test(dataProvider = "invalidFiles", expectedExceptions = {BadRequestException.class}, expectedExceptionsMessageRegExp = "Invalid csv file")
+// public void parseMissingContentCsv(String invalidFile) throws IllegalAccessException, IOException, InstantiationException {
+// readAndParse(invalidFile, 2, null);
+// }
+//
+//
+// @Test
+// public void parseEmptyCsv() throws IllegalAccessException, IOException, InstantiationException {
+// String expectedJson ="{}";
+// readAndParse(EMPTY_CSV,0,expectedJson);
+// }
+//
+// private void readAndParse(String fileName, int expectedNumRows, String expectedJson) throws IllegalAccessException, IOException, InstantiationException {
+// final URL resource = CsvServiceTest.class.getClassLoader().getResource(CSV_FOLDER.replaceFirst("\\{CSV_FILE\\}", fileName));
+// Assert.assertNotNull(resource, "The csv file was not found");
+// List<String[]> content = csvService.readCsv(resource.getPath());
+// Assert.assertEquals(content.size(), expectedNumRows, "The number of non-empty lines in file is wrong");
+// JSONObject json = csvService.convertCsvToJson (content);
+// JSONAssert.assertEquals(expectedJson, json, JSONCompareMode.STRICT);
+//
+// }*/
+//
+//
+//}