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) {
results.add(request);
}
request.setRequestResult(getRequestResult(request,item));
}
scenario.setHashTree(results);
}

View File

@ -77,25 +77,29 @@ public class MsIfController extends MsTestElement {
}
public String getContentValue() {
String content = this.variable;
Pattern regex = Pattern.compile("\\$\\{([^}]*)\\}");
Matcher matcher = regex.matcher(content);
StringBuilder stringBuilder = new StringBuilder();
while (matcher.find()) {
stringBuilder.append(matcher.group(1) + ",");
try {
String content = this.variable;
Pattern regex = Pattern.compile("\\$\\{([^}]*)\\}");
Matcher matcher = regex.matcher(content);
StringBuilder stringBuilder = new StringBuilder();
while (matcher.find()) {
stringBuilder.append(matcher.group(1) + ",");
}
if (stringBuilder.length() > 0) {
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
}
if (StringUtils.isEmpty(stringBuilder.toString())) {
return this.variable;
}
return stringBuilder.toString();
} catch (Exception e) {
return null;
}
if (stringBuilder.length() > 0) {
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
}
if (StringUtils.isEmpty(stringBuilder.toString())) {
return this.variable;
}
return stringBuilder.toString();
}
public String getCondition() {
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 value;
if (StringUtils.equals(operator, "<") || StringUtils.equals(operator, ">")) {

View File

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