Skip to content

Commit

Permalink
code enhancement
Browse files Browse the repository at this point in the history
- passing null value field in map to avoid variable not declared error.
- evaluate expression without parameter
  • Loading branch information
cjayswal committed Dec 13, 2021
1 parent 538d197 commit 8172a48
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/com/qmetry/qaf/automation/data/BaseFormDataBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.qmetry.qaf.automation.ui.annotations.UiElement.Type;
import com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebElement;
import com.qmetry.qaf.automation.util.ClassUtil;
import com.qmetry.qaf.automation.util.JSONUtil;
import com.qmetry.qaf.automation.util.StringUtil;

/**
Expand All @@ -51,8 +52,8 @@
* @author Chirag Jayswal.
*/
public class BaseFormDataBean extends BaseDataBean {
private Field[] allFields;
protected final ElementInteractor interactor;
transient private Field[] allFields;
transient protected final ElementInteractor interactor;

public BaseFormDataBean() {
interactor = new ElementInteractor();
Expand Down Expand Up @@ -215,7 +216,7 @@ protected String getMappedViewLoc(Field fld) {

protected boolean checkParent(String parent, String depVal) {
String parentval = String.valueOf((Object)getBeanData(parent));
if (depVal.equalsIgnoreCase(parentval) || (isExpr(depVal) && resolveExpr(depVal))) {
if (depVal.equalsIgnoreCase(parentval) || resolveExpr(depVal)) {
return true;
}
return false;
Expand Down Expand Up @@ -254,7 +255,7 @@ private Boolean resolveExpr(String strExpr) {
strExpr = strExpr.replaceAll("\\$\\{" + param + "\\}", String.valueOf(paramVal));
}
try {
return (Boolean)StringUtil.eval(strExpr, new JSONObject(this).toMap());
return (Boolean)StringUtil.eval(strExpr, JSONUtil.toMap(JSONUtil.toString(this)));
} catch (ScriptException e) {
logger.error("Unable to evaluate dependency condition: " + strExpr, e);
throw new AutomationError("Unable to evaluate dependency condition: " + strExpr, e);
Expand Down

0 comments on commit 8172a48

Please sign in to comment.