use of com.testsigma.sdk.annotation.RunTimeData in project testsigma by testsigmahq.
the class AddonAction method initRunTimeDataVariable.
private void initRunTimeDataVariable() throws AutomatorException {
try {
for (Field field : clazz.getDeclaredFields()) {
RunTimeData runTimeData = field.getAnnotation(RunTimeData.class);
if (runTimeData != null) {
log.info("Initializing Run Time Data for Addon Plugin Action Step - " + runTimeData);
Object runTimeDataInstance = addonService.getRunTimeDataInstance();
FieldUtils.writeField(instance, field.getName(), runTimeDataInstance, true);
log.info("Setting run time data to the main instance - " + field.getName());
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new AutomatorException(e.getMessage(), e);
}
}
use of com.testsigma.sdk.annotation.RunTimeData in project testsigma by testsigmahq.
the class AddonAction method saveRunTimeData.
private void saveRunTimeData() throws AutomatorException {
log.info("Saving run time data and sending run time data to provider");
try {
for (Field field : clazz.getDeclaredFields()) {
RunTimeData runTimeData = field.getAnnotation(RunTimeData.class);
if (runTimeData != null) {
Field runTimeField = getField(instance.getClass(), field.getName());
runTimeField.setAccessible(true);
if (runTimeField != null && runTimeField.get(instance) != null) {
Field valueField = getField(runTimeField.get(instance).getClass(), "value");
valueField.setAccessible(true);
String value = (String) valueField.get(runTimeField.get(instance));
Field variableNameField = getField(runTimeField.get(instance).getClass(), "key");
variableNameField.setAccessible(true);
String variableName = (String) variableNameField.get(runTimeField.get(instance));
if (variableName != null) {
runtimeDataProvider.storeRuntimeVariable(variableName, value);
log.info("Setting run time data to RunTimeData Provider - " + field.getName());
} else {
log.info("Skipping run time data to RunTimeData Provider - as the variable name is empty" + field.getName());
}
}
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new AutomatorException(e.getMessage(), e);
}
}
Aggregations