fix(接口自动化): 修复IF条件为空时无法保存问题
This commit is contained in:
parent
9dee308d8e
commit
986d24724a
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,25 +77,29 @@ public class MsIfController extends MsTestElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getContentValue() {
|
public String getContentValue() {
|
||||||
String content = this.variable;
|
try {
|
||||||
Pattern regex = Pattern.compile("\\$\\{([^}]*)\\}");
|
String content = this.variable;
|
||||||
Matcher matcher = regex.matcher(content);
|
Pattern regex = Pattern.compile("\\$\\{([^}]*)\\}");
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
Matcher matcher = regex.matcher(content);
|
||||||
while (matcher.find()) {
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
stringBuilder.append(matcher.group(1) + ",");
|
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() {
|
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, ">")) {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue