diff options
author | Ofir Sonsino <os0695@att.com> | 2018-01-31 17:19:00 +0200 |
---|---|---|
committer | Ofir Sonsino <os0695@att.com> | 2018-01-31 17:19:00 +0200 |
commit | 1cfb08779ea0e00be69e072a940b3063e049fe6b (patch) | |
tree | 6602a900387c8393ed0dcd81c0539381632903c6 /vid-automation/src/main/java/vid/automation/test/utils | |
parent | 2f20b001b9243e0f8b44aecc768ec265fd538732 (diff) |
org.onap migration
Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d
Issue-ID: VID-86
Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-automation/src/main/java/vid/automation/test/utils')
-rw-r--r-- | vid-automation/src/main/java/vid/automation/test/utils/ReadFile.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/vid-automation/src/main/java/vid/automation/test/utils/ReadFile.java b/vid-automation/src/main/java/vid/automation/test/utils/ReadFile.java new file mode 100644 index 00000000..7652e09b --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/utils/ReadFile.java @@ -0,0 +1,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; + } + } + +} |