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