fix(接口测试): 修复导入禁用的jmx断言,ms会自动打开的缺陷
--bug=1030863 --user=王孝刚 【接口测试】github#26824,JMX禁用的断言,导入到MS上会自动打开 https://www.tapd.cn/55049933/s/1419946
This commit is contained in:
parent
9cae7c0fe6
commit
1720a23270
|
@ -454,11 +454,11 @@ public class JmeterDefinitionParser extends ApiImportAbstractParser<ApiDefinitio
|
|||
assertions.setRegex(new LinkedList<>());
|
||||
assertions.setDuration(new MsAssertionDuration());
|
||||
assertions.setType("Assertions");
|
||||
if (key instanceof ResponseAssertion) {
|
||||
if (key instanceof ResponseAssertion assertion) {
|
||||
MsAssertionRegex assertionRegex = new MsAssertionRegex();
|
||||
ResponseAssertion assertion = (ResponseAssertion) key;
|
||||
assertionRegex.setDescription(assertion.getName());
|
||||
assertionRegex.setAssumeSuccess(assertion.getAssumeSuccess());
|
||||
assertionRegex.setEnable(assertion.isEnabled());
|
||||
if (assertion.getTestStrings() != null && !assertion.getTestStrings().isEmpty()) {
|
||||
assertionRegex.setExpression(assertion.getTestStrings().get(0).getStringValue());
|
||||
}
|
||||
|
@ -485,35 +485,35 @@ public class JmeterDefinitionParser extends ApiImportAbstractParser<ApiDefinitio
|
|||
}
|
||||
assertions.setName(assertion.getName());
|
||||
assertions.getRegex().add(assertionRegex);
|
||||
} else if (key instanceof JSONPathAssertion) {
|
||||
} else if (key instanceof JSONPathAssertion jsonPathAssertion) {
|
||||
MsAssertionJsonPath assertionJsonPath = new MsAssertionJsonPath();
|
||||
JSONPathAssertion jsonPathAssertion = (JSONPathAssertion) key;
|
||||
assertionJsonPath.setDescription(jsonPathAssertion.getName());
|
||||
assertionJsonPath.setExpression(jsonPathAssertion.getJsonPath());
|
||||
assertionJsonPath.setExpect(jsonPathAssertion.getExpectedValue());
|
||||
assertionJsonPath.setEnable(jsonPathAssertion.isEnabled());
|
||||
assertionJsonPath.setOption(jsonPathAssertion.getPropertyAsString(PropertyConstant.ASS_OPTION));
|
||||
assertions.setName(jsonPathAssertion.getName());
|
||||
assertions.getJsonPath().add(assertionJsonPath);
|
||||
} else if (key instanceof XPath2Assertion) {
|
||||
} else if (key instanceof XPath2Assertion xPath2Assertion) {
|
||||
MsAssertionXPath2 assertionXPath2 = new MsAssertionXPath2();
|
||||
XPath2Assertion xPath2Assertion = (XPath2Assertion) key;
|
||||
assertionXPath2.setExpression(xPath2Assertion.getXPathString());
|
||||
assertionXPath2.setEnable(xPath2Assertion.isEnabled());
|
||||
assertions.setName(xPath2Assertion.getName());
|
||||
assertions.getXpath2().add(assertionXPath2);
|
||||
} else if (key instanceof JSR223Assertion) {
|
||||
} else if (key instanceof JSR223Assertion jsr223Assertion) {
|
||||
MsAssertionJSR223 msAssertionJSR223 = new MsAssertionJSR223();
|
||||
JSR223Assertion jsr223Assertion = (JSR223Assertion) key;
|
||||
msAssertionJSR223.setName(jsr223Assertion.getName());
|
||||
msAssertionJSR223.setDesc(jsr223Assertion.getName());
|
||||
msAssertionJSR223.setEnable(jsr223Assertion.isEnabled());
|
||||
msAssertionJSR223.setScript(jsr223Assertion.getPropertyAsString(ElementConstants.SCRIPT));
|
||||
msAssertionJSR223.setScriptLanguage(jsr223Assertion.getPropertyAsString("scriptLanguage"));
|
||||
assertions.setName(jsr223Assertion.getName());
|
||||
|
||||
assertions.getJsr223().add(msAssertionJSR223);
|
||||
} else if (key instanceof DurationAssertion) {
|
||||
} else if (key instanceof DurationAssertion durationAssertion) {
|
||||
MsAssertionDuration assertionDuration = new MsAssertionDuration();
|
||||
DurationAssertion durationAssertion = (DurationAssertion) key;
|
||||
assertionDuration.setValue(durationAssertion.getProperty("DurationAssertion.duration").getIntValue());
|
||||
assertionDuration.setEnable(durationAssertion.isEnabled());
|
||||
assertions.setName(durationAssertion.getName());
|
||||
assertions.setDuration(assertionDuration);
|
||||
}
|
||||
|
|
|
@ -633,14 +633,14 @@ public class JMeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
|||
assertions.setRegex(new LinkedList<>());
|
||||
assertions.setDuration(new MsAssertionDuration());
|
||||
assertions.setType(ElementConstants.ASSERTIONS);
|
||||
if (key instanceof ResponseAssertion) {
|
||||
ResponseAssertion assertion = (ResponseAssertion) key;
|
||||
if (key instanceof ResponseAssertion assertion) {
|
||||
if (assertion.getTestStrings() != null && !assertion.getTestStrings().isEmpty()) {
|
||||
assertion.getTestStrings().forEach(item -> {
|
||||
MsAssertionRegex assertionRegex = new MsAssertionRegex();
|
||||
assertionRegex.setDescription(assertion.getName());
|
||||
assertionRegex.setAssumeSuccess(assertion.getAssumeSuccess());
|
||||
assertionRegex.setExpression(item.getStringValue());
|
||||
assertionRegex.setEnable(assertion.isEnabled());
|
||||
if (assertion.isNotType()) {
|
||||
assertionRegex.setExpression("(?s)^((?!" + item.getStringValue() + ").)*$");
|
||||
assertionRegex.setDescription(" not contains: " + item.getStringValue());
|
||||
|
@ -682,38 +682,39 @@ public class JMeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
|||
if (assertion.isTestFieldResponseHeaders()) {
|
||||
assertionRegex.setSubject("Response Headers");
|
||||
}
|
||||
assertionRegex.setEnable(assertion.isEnabled());
|
||||
assertions.setName(assertion.getName());
|
||||
assertions.getRegex().add(assertionRegex);
|
||||
}
|
||||
} else if (key instanceof JSONPathAssertion) {
|
||||
} else if (key instanceof JSONPathAssertion jsonPathAssertion) {
|
||||
MsAssertionJsonPath assertionJsonPath = new MsAssertionJsonPath();
|
||||
JSONPathAssertion jsonPathAssertion = (JSONPathAssertion) key;
|
||||
assertionJsonPath.setDescription(jsonPathAssertion.getName());
|
||||
assertionJsonPath.setExpression(jsonPathAssertion.getJsonPath());
|
||||
assertionJsonPath.setExpect(jsonPathAssertion.getExpectedValue());
|
||||
assertionJsonPath.setOption(jsonPathAssertion.getPropertyAsString(PropertyConstant.ASS_OPTION));
|
||||
assertionJsonPath.setEnable(jsonPathAssertion.isEnabled());
|
||||
assertions.setName(jsonPathAssertion.getName());
|
||||
assertions.getJsonPath().add(assertionJsonPath);
|
||||
} else if (key instanceof XPath2Assertion) {
|
||||
} else if (key instanceof XPath2Assertion xPath2Assertion) {
|
||||
MsAssertionXPath2 assertionXPath2 = new MsAssertionXPath2();
|
||||
XPath2Assertion xPath2Assertion = (XPath2Assertion) key;
|
||||
assertionXPath2.setExpression(xPath2Assertion.getXPathString());
|
||||
assertionXPath2.setEnable(xPath2Assertion.isEnabled());
|
||||
assertions.setName(xPath2Assertion.getName());
|
||||
assertions.getXpath2().add(assertionXPath2);
|
||||
} else if (key instanceof JSR223Assertion) {
|
||||
} else if (key instanceof JSR223Assertion jsr223Assertion) {
|
||||
MsAssertionJSR223 msAssertionJSR223 = new MsAssertionJSR223();
|
||||
JSR223Assertion jsr223Assertion = (JSR223Assertion) key;
|
||||
msAssertionJSR223.setName(jsr223Assertion.getName());
|
||||
msAssertionJSR223.setDesc(jsr223Assertion.getName());
|
||||
msAssertionJSR223.setEnable(jsr223Assertion.isEnabled());
|
||||
msAssertionJSR223.setScript(jsr223Assertion.getPropertyAsString(ElementConstants.SCRIPT));
|
||||
msAssertionJSR223.setScriptLanguage(jsr223Assertion.getPropertyAsString("scriptLanguage"));
|
||||
assertions.setName(jsr223Assertion.getName());
|
||||
|
||||
assertions.getJsr223().add(msAssertionJSR223);
|
||||
} else if (key instanceof DurationAssertion) {
|
||||
} else if (key instanceof DurationAssertion durationAssertion) {
|
||||
MsAssertionDuration assertionDuration = new MsAssertionDuration();
|
||||
DurationAssertion durationAssertion = (DurationAssertion) key;
|
||||
assertionDuration.setValue(durationAssertion.getProperty("DurationAssertion.duration").getIntValue());
|
||||
assertionDuration.setEnable(durationAssertion.isEnabled());
|
||||
assertions.setName(durationAssertion.getName());
|
||||
assertions.setDuration(assertionDuration);
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ export default {
|
|||
},
|
||||
props: {
|
||||
projectId: String,
|
||||
isTemplate: String,
|
||||
isTemplate: Boolean,
|
||||
apiInfo: Object,
|
||||
},
|
||||
computed: {},
|
||||
|
|
Loading…
Reference in New Issue