From 4aae31102495c0049304ae904782be538708e39c Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 22 Jun 2021 18:35:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=B1=E8=B4=A5=E7=BB=A7=E7=BB=AD?= =?UTF-8?q?=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/MsScenario.java | 2 +- .../api/dto/definition/request/MsThreadGroup.java | 4 ++-- .../api/dto/definition/request/ParameterConfig.java | 4 ++-- .../io/metersphere/api/service/ApiAutomationService.java | 8 ++++---- .../io/metersphere/track/service/TestPlanService.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 72432a510e..bb23ba172b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -62,7 +62,7 @@ public class MsScenario extends MsTestElement { private Map environmentMap; @JSONField(ordinal = 24) - private boolean onSampleError; + private Boolean onSampleError; private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java index 8960399233..3e194c35dd 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java @@ -21,7 +21,7 @@ import java.util.List; public class MsThreadGroup extends MsTestElement { private String type = "ThreadGroup"; private boolean enableCookieShare; - private boolean onSampleError; + private Boolean onSampleError; @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { @@ -66,7 +66,7 @@ public class MsThreadGroup extends MsTestElement { threadGroup.setDuration(0); threadGroup.setProperty(ThreadGroup.ON_SAMPLE_ERROR, ThreadGroup.ON_SAMPLE_ERROR_CONTINUE); threadGroup.setScheduler(false); - if (!onSampleError) { + if (onSampleError != null && !onSampleError) { threadGroup.setProperty("ThreadGroup.on_sample_error", "stoptest"); } threadGroup.setSamplerController(loopController); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java index 7a1f1e7075..8db64e8a79 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java @@ -33,7 +33,7 @@ public class ParameterConfig { /** * 是否停止继续 */ - private boolean onSampleError; + private Boolean onSampleError; /** * 是否是导入/导出操作 @@ -62,4 +62,4 @@ public class ParameterConfig { return arguments; } -} \ No newline at end of file +} diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 43993b718a..1bbc22b836 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -785,7 +785,7 @@ public class ApiAutomationService { group.setLabel(item.getName()); group.setName(reportId); MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class); - group.setOnSampleError(scenario.isOnSampleError()); + group.setOnSampleError(scenario.getOnSampleError()); this.preduceMsScenario(scenario); if (planEnvMap.size() > 0) { scenario.setEnvironmentMap(planEnvMap); @@ -829,7 +829,7 @@ public class ApiAutomationService { group.setLabel(apiScenario.getName()); group.setName(apiScenario.getName()); group.setEnableCookieShare(scenario.isEnableCookieShare()); - group.setOnSampleError(scenario.isOnSampleError()); + group.setOnSampleError(scenario.getOnSampleError()); group.setHashTree(new LinkedList() {{ this.add(scenario); }}); @@ -1062,7 +1062,7 @@ public class ApiAutomationService { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JSONObject element = JSON.parseObject(item.getScenarioDefinition()); MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class); - group.setOnSampleError(scenario.isOnSampleError()); + group.setOnSampleError(scenario.getOnSampleError()); this.preduceMsScenario(scenario); // 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取 if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) { @@ -1078,7 +1078,7 @@ public class ApiAutomationService { scenario.setVariables(variables); } group.setEnableCookieShare(scenario.isEnableCookieShare()); - group.setOnSampleError(scenario.isOnSampleError()); + group.setOnSampleError(scenario.getOnSampleError()); LinkedList scenarios = new LinkedList<>(); scenarios.add(scenario); // 创建场景报告 diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index c6e818470f..bf199859fa 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -969,7 +969,7 @@ public class TestPlanService { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JSONObject element = JSON.parseObject(item.getScenarioDefinition()); MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class); - group.setOnSampleError(scenario.isOnSampleError()); + group.setOnSampleError(scenario.getOnSampleError()); // 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取 if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) { LinkedList elements = mapper.readValue(element.getString("hashTree"),