fix(接口测试): 修复导入jmx附件断言处理缺失问题#11700

--bug=1011539 --user=赵勇 【接口测试】github#11700jmeter里设置的断言规则和数量导入到metersphere后不正确 https://www.tapd.cn/55049933/s/1123349
This commit is contained in:
fit2-zhao 2022-03-22 15:51:29 +08:00 committed by fit2-zhao
parent 2a4e14d089
commit ca6873c7bd

View File

@ -607,24 +607,44 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
assertions.setDuration(new MsAssertionDuration());
assertions.setType("Assertions");
if (key instanceof ResponseAssertion) {
MsAssertionRegex assertionRegex = new MsAssertionRegex();
ResponseAssertion assertion = (ResponseAssertion) key;
assertionRegex.setDescription(assertion.getName());
assertionRegex.setAssumeSuccess(assertion.getAssumeSuccess());
if (assertion.getTestStrings() != null && !assertion.getTestStrings().isEmpty()) {
assertionRegex.setExpression(assertion.getTestStrings().get(0).getStringValue());
assertion.getTestStrings().forEach(item -> {
MsAssertionRegex assertionRegex = new MsAssertionRegex();
assertionRegex.setDescription(assertion.getName());
assertionRegex.setAssumeSuccess(assertion.getAssumeSuccess());
assertionRegex.setExpression(item.getStringValue());
if (assertion.isTestFieldResponseData()) {
assertionRegex.setSubject("Response Data");
}
if (assertion.isTestFieldResponseCode()) {
assertionRegex.setSubject("Response Code");
}
if (assertion.isTestFieldResponseHeaders()) {
assertionRegex.setSubject("Response Headers");
}
assertions.setName(assertion.getName());
assertions.getRegex().add(assertionRegex);
});
} else {
MsAssertionRegex assertionRegex = new MsAssertionRegex();
assertionRegex.setDescription(assertion.getName());
assertionRegex.setAssumeSuccess(assertion.getAssumeSuccess());
if (assertion.getTestStrings() != null && !assertion.getTestStrings().isEmpty()) {
assertionRegex.setExpression(assertion.getTestStrings().get(0).getStringValue());
}
if (assertion.isTestFieldResponseData()) {
assertionRegex.setSubject("Response Data");
}
if (assertion.isTestFieldResponseCode()) {
assertionRegex.setSubject("Response Code");
}
if (assertion.isTestFieldResponseHeaders()) {
assertionRegex.setSubject("Response Headers");
}
assertions.setName(assertion.getName());
assertions.getRegex().add(assertionRegex);
}
if (assertion.isTestFieldResponseData()) {
assertionRegex.setSubject("Response Data");
}
if (assertion.isTestFieldResponseCode()) {
assertionRegex.setSubject("Response Code");
}
if (assertion.isTestFieldResponseHeaders()) {
assertionRegex.setSubject("Response Headers");
}
assertions.setName(assertion.getName());
assertions.getRegex().add(assertionRegex);
} else if (key instanceof JSONPathAssertion) {
MsAssertionJsonPath assertionJsonPath = new MsAssertionJsonPath();
JSONPathAssertion jsonPathAssertion = (JSONPathAssertion) key;