blob: 1847e184fba9ed8ed93480be9489f9e5235524b6 [file] [log] [blame]
Aharoni, Pavel (pa0916)ca3cb012018-10-22 15:29:57 +03001/*-
2 * ============LICENSE_START=======================================================
3 * OSAM
4 * ================================================================================
5 * Copyright (C) 2018 AT&T
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
19 */
20
21
22
23//package org.onap.vid.services;
24//import org.apache.commons.io.IOUtils;
25//import org.onap.vid.services.CsvServiceImpl;
26//import org.skyscreamer.jsonassert.JSONAssert;
27//import org.skyscreamer.jsonassert.JSONCompareMode;
28//import org.testng.Assert;
29//import org.testng.annotations.DataProvider;
30//import org.testng.annotations.Test;
31//import org.json.JSONObject;
32//
33//import javax.ws.rs.BadRequestException;
34//import java.io.IOException;
35//import java.lang.reflect.Method;
36//import java.net.URL;
37//import java.util.List;
38//
39//@Test
40//public class CsvServiceTest {
41//
42// private CsvServiceImpl csvService = new CsvServiceImpl();
43// private final static String CSV_FOLDER = "csv_files/{CSV_FILE}";
44// private final static String VALID_CSV = "csv_to_json.csv";
45// private final static String ONE_LINE_CSV = "one_line.csv";
46// private final static String EMPTY_CSV = "empty_file.csv";
47// private final static String MISSING_CONTENT_CSV = "missing_content.csv";
48// private final static String MISSING_VALUES_CSV = "missing_values.csv";
49//
50//
51///*
52// @Test
53// public void parseValidCsv() throws IllegalAccessException, IOException, InstantiationException {
54// String expectedJson = getExpectation("vnfConfigUpdatePayload.json");
55// readAndParse(VALID_CSV,16,expectedJson);
56//
57// }*/
58//
59// private String getExpectation(String modelFileName) throws IOException {
60// // load expected result
61// final URL resource = this.getClass().getResource("/" + modelFileName);
62// String expected = IOUtils.toString(resource, "UTF-8");
63// return expected;
64// }
65///*
66// @Test
67// public void parseOneLineCsv() throws IllegalAccessException, IOException, InstantiationException {
68// String expectedJson ="{\"payload\":{\"request-parameters\":{\"vnf-name\":\"ibcx0099v\"}}}";
69// readAndParse(ONE_LINE_CSV,1,expectedJson);
70// }*/
71//
72// @DataProvider
73// public static Object[][] invalidFiles(Method test) {
74// return new Object[][]{
75// {MISSING_CONTENT_CSV}, {MISSING_VALUES_CSV}
76// };
77// }
78///*
79// @Test(dataProvider = "invalidFiles", expectedExceptions = {BadRequestException.class}, expectedExceptionsMessageRegExp = "Invalid csv file")
80// public void parseMissingContentCsv(String invalidFile) throws IllegalAccessException, IOException, InstantiationException {
81// readAndParse(invalidFile, 2, null);
82// }
83//
84//
85// @Test
86// public void parseEmptyCsv() throws IllegalAccessException, IOException, InstantiationException {
87// String expectedJson ="{}";
88// readAndParse(EMPTY_CSV,0,expectedJson);
89// }
90//
91// private void readAndParse(String fileName, int expectedNumRows, String expectedJson) throws IllegalAccessException, IOException, InstantiationException {
92// final URL resource = CsvServiceTest.class.getClassLoader().getResource(CSV_FOLDER.replaceFirst("\\{CSV_FILE\\}", fileName));
93// Assert.assertNotNull(resource, "The csv file was not found");
94// List<String[]> content = csvService.readCsv(resource.getPath());
95// Assert.assertEquals(content.size(), expectedNumRows, "The number of non-empty lines in file is wrong");
96// JSONObject json = csvService.convertCsvToJson (content);
97// JSONAssert.assertEquals(expectedJson, json, JSONCompareMode.STRICT);
98//
99// }*/
100//
101//
102//}