fix(接口自动化): 修复IF条件为空时无法保存问题

This commit is contained in:
fit2-zhao 2021-07-19 12:26:22 +08:00 committed by fit2-zhao
parent 9dee308d8e
commit 986d24724a
3 changed files with 18 additions and 18 deletions

View File

@ -85,7 +85,6 @@ public class HarScenarioParser extends HarScenarioAbstractParser<ScenarioImport>
if (request != null) { if (request != null) {
results.add(request); results.add(request);
} }
request.setRequestResult(getRequestResult(request,item));
} }
scenario.setHashTree(results); scenario.setHashTree(results);
} }

View File

@ -77,6 +77,7 @@ public class MsIfController extends MsTestElement {
} }
public String getContentValue() { public String getContentValue() {
try {
String content = this.variable; String content = this.variable;
Pattern regex = Pattern.compile("\\$\\{([^}]*)\\}"); Pattern regex = Pattern.compile("\\$\\{([^}]*)\\}");
Matcher matcher = regex.matcher(content); Matcher matcher = regex.matcher(content);
@ -91,11 +92,14 @@ public class MsIfController extends MsTestElement {
return this.variable; return this.variable;
} }
return stringBuilder.toString(); return stringBuilder.toString();
} catch (Exception e) {
return null;
}
} }
public String getCondition() { public String getCondition() {
String key = getContentValue(); String key = getContentValue();
String variable = key.equals(this.variable) ? "\"" + this.variable + "\"" : "vars.get('" + key + "')"; String variable = (StringUtils.isEmpty(key) || key.equals(this.variable)) ? "\"" + this.variable + "\"" : "vars.get('" + key + "')";
String operator = this.operator; String operator = this.operator;
String value; String value;
if (StringUtils.equals(operator, "<") || StringUtils.equals(operator, ">")) { if (StringUtils.equals(operator, "<") || StringUtils.equals(operator, ">")) {

View File

@ -109,9 +109,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
@JSONField(ordinal = 34) @JSONField(ordinal = 34)
private List<KeyValue> arguments; private List<KeyValue> arguments;
@JSONField(ordinal = 35)
private Object requestResult;
@JSONField(ordinal = 36) @JSONField(ordinal = 36)
private MsAuthManager authManager; private MsAuthManager authManager;