use of com.qaprosoft.carina.core.foundation.dataprovider.core.impl.BaseDataProvider in project carina by zebrunner.
the class DataProviderFactory method getDataProvider.
public static Object[][] getDataProvider(Annotation[] annotations, ITestContext context, ITestNGMethod m) {
Map<String, String> testNameArgsMap = Collections.synchronizedMap(new HashMap<>());
Map<String, String> testMethodOwnerArgsMap = Collections.synchronizedMap(new HashMap<>());
Map<String, String> testRailsArgsMap = Collections.synchronizedMap(new HashMap<>());
List<String> doNotRunTests = Collections.synchronizedList(new ArrayList<>());
Object[][] provider = new Object[][] {};
for (Annotation annotation : annotations) {
try {
Class<? extends Annotation> type = annotation.annotationType();
String providerClass = "";
for (Method method : type.getDeclaredMethods()) {
if (method.getName().equalsIgnoreCase("classname")) {
providerClass = (String) method.invoke(annotation);
break;
}
}
if (providerClass.isEmpty())
continue;
Class<?> clazz;
Object object = null;
try {
clazz = Class.forName(providerClass);
Constructor<?> ctor = clazz.getConstructor();
object = ctor.newInstance();
} catch (Exception e) {
LOGGER.error("DataProvider failure", e);
}
if (object instanceof com.qaprosoft.carina.core.foundation.dataprovider.core.impl.BaseDataProvider) {
BaseDataProvider activeProvider = (BaseDataProvider) object;
provider = ArrayUtils.addAll(provider, activeProvider.getDataProvider(annotation, context, m));
testNameArgsMap.putAll(activeProvider.getTestNameArgsMap());
testMethodOwnerArgsMap.putAll(activeProvider.getTestMethodOwnerArgsMap());
testRailsArgsMap.putAll(activeProvider.getTestRailsArgsMap());
doNotRunTests.addAll(activeProvider.getDoNotRunRowsIDs());
}
} catch (Exception e) {
LOGGER.error("DataProvider failure", e);
}
}
if (!GroupByMapper.getInstanceInt().isEmpty() || !GroupByMapper.getInstanceStrings().isEmpty()) {
provider = getGroupedList(provider);
}
context.setAttribute(SpecialKeywords.TEST_NAME_ARGS_MAP, testNameArgsMap);
// clear group by settings
GroupByMapper.getInstanceInt().clear();
GroupByMapper.getInstanceStrings().clear();
return provider;
}
use of com.qaprosoft.carina.core.foundation.dataprovider.core.impl.BaseDataProvider in project carina by qaprosoft.
the class DataProviderFactory method getDataProvider.
public static Object[][] getDataProvider(Annotation[] annotations, ITestContext context, ITestNGMethod m) {
Map<String, String> testNameArgsMap = Collections.synchronizedMap(new HashMap<>());
Map<String, String> testMethodOwnerArgsMap = Collections.synchronizedMap(new HashMap<>());
Map<String, String> testRailsArgsMap = Collections.synchronizedMap(new HashMap<>());
List<String> doNotRunTests = Collections.synchronizedList(new ArrayList<>());
Object[][] provider = new Object[][] {};
for (Annotation annotation : annotations) {
try {
Class<? extends Annotation> type = annotation.annotationType();
String providerClass = "";
for (Method method : type.getDeclaredMethods()) {
if (method.getName().equalsIgnoreCase("classname")) {
providerClass = (String) method.invoke(annotation);
break;
}
}
if (providerClass.isEmpty())
continue;
Class<?> clazz;
Object object = null;
try {
clazz = Class.forName(providerClass);
Constructor<?> ctor = clazz.getConstructor();
object = ctor.newInstance();
} catch (Exception e) {
LOGGER.error("DataProvider failure", e);
}
if (object instanceof com.qaprosoft.carina.core.foundation.dataprovider.core.impl.BaseDataProvider) {
BaseDataProvider activeProvider = (BaseDataProvider) object;
provider = ArrayUtils.addAll(provider, activeProvider.getDataProvider(annotation, context, m));
testNameArgsMap.putAll(activeProvider.getTestNameArgsMap());
testMethodOwnerArgsMap.putAll(activeProvider.getTestMethodOwnerArgsMap());
testRailsArgsMap.putAll(activeProvider.getTestRailsArgsMap());
doNotRunTests.addAll(activeProvider.getDoNotRunRowsIDs());
}
} catch (Exception e) {
LOGGER.error("DataProvider failure", e);
}
}
if (!GroupByMapper.getInstanceInt().isEmpty() || !GroupByMapper.getInstanceStrings().isEmpty()) {
provider = getGroupedList(provider);
}
context.setAttribute(SpecialKeywords.TEST_NAME_ARGS_MAP, testNameArgsMap);
// clear group by settings
GroupByMapper.getInstanceInt().clear();
GroupByMapper.getInstanceStrings().clear();
return provider;
}
Aggregations