com.testvagrant.optimus.commons.filehandlers.TestFeedJsonParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optimus-lite Show documentation
Show all versions of optimus-lite Show documentation
Optimus Lite API to manage test devices and create appium driver based on platform
package com.testvagrant.optimus.commons.filehandlers;
import com.testvagrant.optimus.core.exceptions.TestFeedNotFoundException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.concurrent.atomic.AtomicReference;
import static com.testvagrant.optimus.commons.filehandlers.ResourcePaths.*;
public class TestFeedJsonParser {
public static final String[] validPaths =
new String[] {
TEST_RESOURCES, TEST_TEST_FEED_RESOURCES, MAIN_RESOURCES, MAIN_TEST_FEED_RESOURCES
};
public T deserialize(String name, Class tClass) {
try {
AtomicReference filePath = new AtomicReference<>("");
for (String path : validPaths) {
File file = FileFinder.fileFinder(path).find(name, ".json");
if (file != null && file.exists()) {
filePath.set(file.getPath());
break;
}
}
return GsonParser.toInstance().deserialize(new FileReader(filePath.get()), tClass);
} catch (FileNotFoundException e) {
throw new TestFeedNotFoundException(name, validPaths);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy