testData = testClass.getAnnotation(DataLoader.class);
} else {
testData = method.getAnnotation(DataLoader.class);
}
if (testData != null) {
TestInfo testInfo = DataLoaderUtil.determineLoader(testData, currentTestClass);
Loader dataLoader = testInfo.getDataLoader();
if (testInfo.getDataLoader() == null) {
Assert.fail("The framework currently does not support the specified Loader type. "
+ "You can provide the custom Loader by choosing LoaderType.CUSTOM in TestData "
+ "annotation and providing your custom loader using DataLoader annotation.");
} else {
if (testInfo.getFilePaths() == null || testInfo.getFilePaths().length == 0) {
// implies that there exists a CUSTOM loader that loads the data using Java classes
Map<String, List<Map<String, Object>>> data = dataLoader.loadData(new EmptyResource());
// We also maintain the copy of the actual data for our write functionality.
fillWritableData(writableData , data , testData.appendData());
DataContext.setData(DataConverter.appendClassName(data, currentTestClass.getJavaClass()), testData.appendData());
DataContext.setConvertedData(DataConverter.convert(data, currentTestClass.getJavaClass()) , testData.appendData());
} else {
ResourceLoader resourceLoader = new ResourceLoaderStrategy(currentTestClass.getJavaClass());
for (String filePath : testInfo.getFilePaths()) {
Resource resource = resourceLoader.getResource(filePath);
try {
if (resource.exists()) {
Map<String, List<Map<String, Object>>> data = dataLoader.loadData(resource);
// We also maintain the copy of the actual data for our write functionality.