From 1720a23270d38227765610d52d7fe9d57b955c9e Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 22 Sep 2023 13:41:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=85=A5=E7=A6=81=E7=94=A8=E7=9A=84?= =?UTF-8?q?jmx=E6=96=AD=E8=A8=80=EF=BC=8Cms=E4=BC=9A=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=89=93=E5=BC=80=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1030863 --user=王孝刚 【接口测试】github#26824,JMX禁用的断言,导入到MS上会自动打开 https://www.tapd.cn/55049933/s/1419946 --- .../api/parse/api/JmeterDefinitionParser.java | 20 +++++++++--------- .../api/parse/scenario/JMeterParser.java | 21 ++++++++++--------- .../document/components/ApiInformation.vue | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/JmeterDefinitionParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/JmeterDefinitionParser.java index 3b3ed2873f..7ab4743117 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/JmeterDefinitionParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/JmeterDefinitionParser.java @@ -454,11 +454,11 @@ public class JmeterDefinitionParser extends ApiImportAbstractParser()); 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 { 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 { 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); } diff --git a/api-test/frontend/src/business/definition/components/document/components/ApiInformation.vue b/api-test/frontend/src/business/definition/components/document/components/ApiInformation.vue index e7a8d91f2c..c79c4a4433 100644 --- a/api-test/frontend/src/business/definition/components/document/components/ApiInformation.vue +++ b/api-test/frontend/src/business/definition/components/document/components/ApiInformation.vue @@ -173,7 +173,7 @@ export default { }, props: { projectId: String, - isTemplate: String, + isTemplate: Boolean, apiInfo: Object, }, computed: {},