blob: 7652e09b70541a1595ea2b255dda6c5fbfa337d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package vid.automation.test.utils;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.openecomp.sdc.ci.tests.utilities.FileHandling;
import vid.automation.test.model.User;
import vid.automation.test.model.UsersObject;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
public class ReadFile {
public static <T> T getJsonFile(String fileName, Class<T> clazz) throws IOException {
ObjectMapper mapper = new ObjectMapper();
T list;
try {
File testCaseFile = FileHandling.getConfigFile(fileName);
if(!testCaseFile.exists()) {
String basePath = System.getProperty("BASE_PATH");
testCaseFile = new File( basePath + File.separator + "conf" + File.separator + fileName);
}
list = (T) mapper.readValue(testCaseFile, clazz);
return list;
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
|