From a3e1ab465347f8328f9ffdf67536ce730e81a027 Mon Sep 17 00:00:00 2001 From: q4speed Date: Fri, 9 Oct 2020 13:47:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8DDubbo=E9=87=8D=E5=A4=8D=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/pom.xml b/backend/pom.xml index a1772fb09f..6876f40434 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -243,7 +243,7 @@ io.metersphere jmeter-plugins-dubbo - 2.7.10 + 2.7.11 From 831741c97d3d4ae1236955451db423094ae635a2 Mon Sep 17 00:00:00 2001 From: q4speed Date: Fri, 9 Oct 2020 13:50:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20Request=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E7=B1=BB=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=85=AC=E5=85=B1=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/scenario/request/DubboRequest.java | 28 ++---------------- .../api/dto/scenario/request/HttpRequest.java | 28 ++---------------- .../api/dto/scenario/request/Request.java | 29 ++++++++++++++++++- .../api/dto/scenario/request/SqlRequest.java | 28 ++---------------- 4 files changed, 37 insertions(+), 76 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/request/DubboRequest.java b/backend/src/main/java/io/metersphere/api/dto/scenario/request/DubboRequest.java index db5cce8a74..9f88f3d706 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/request/DubboRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/request/DubboRequest.java @@ -4,30 +4,22 @@ import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONType; import com.fasterxml.jackson.annotation.JsonProperty; import io.metersphere.api.dto.scenario.KeyValue; -import io.metersphere.api.dto.scenario.assertions.Assertions; -import io.metersphere.api.dto.scenario.controller.IfController; -import io.metersphere.api.dto.scenario.extract.Extract; import io.metersphere.api.dto.scenario.processor.BeanShellPostProcessor; import io.metersphere.api.dto.scenario.processor.BeanShellPreProcessor; -import io.metersphere.api.dto.scenario.processor.JSR223PostProcessor; -import io.metersphere.api.dto.scenario.processor.JSR223PreProcessor; import io.metersphere.api.dto.scenario.request.dubbo.ConfigCenter; import io.metersphere.api.dto.scenario.request.dubbo.ConsumerAndService; import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter; -import io.metersphere.api.dto.scenario.timer.ConstantTimer; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.List; @Data +@EqualsAndHashCode(callSuper = true) @JSONType(typeName = RequestType.DUBBO) -public class DubboRequest implements Request { +public class DubboRequest extends Request { // type 必须放最前面,以便能够转换正确的类 private String type = RequestType.DUBBO; - @JSONField(ordinal = 1) - private String id; - @JSONField(ordinal = 1) - private String name; @JSONField(ordinal = 2) private String protocol; @JsonProperty(value = "interface") @@ -47,22 +39,8 @@ public class DubboRequest implements Request { private List args; @JSONField(ordinal = 9) private List attachmentArgs; - @JSONField(ordinal = 10) - private Assertions assertions; - @JSONField(ordinal = 11) - private Extract extract; @JSONField(ordinal = 12) private BeanShellPreProcessor beanShellPreProcessor; @JSONField(ordinal = 13) private BeanShellPostProcessor beanShellPostProcessor; - @JSONField(ordinal = 14) - private Boolean enable; - @JSONField(ordinal = 15) - private JSR223PreProcessor jsr223PreProcessor; - @JSONField(ordinal = 16) - private JSR223PostProcessor jsr223PostProcessor; - @JSONField(ordinal = 17) - private IfController controller; - @JSONField(ordinal = 18) - private ConstantTimer timer; } diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java b/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java index 95477f8c6d..b9744d0cb8 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java @@ -4,27 +4,19 @@ import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONType; import io.metersphere.api.dto.scenario.Body; import io.metersphere.api.dto.scenario.KeyValue; -import io.metersphere.api.dto.scenario.assertions.Assertions; -import io.metersphere.api.dto.scenario.controller.IfController; -import io.metersphere.api.dto.scenario.extract.Extract; import io.metersphere.api.dto.scenario.processor.BeanShellPostProcessor; import io.metersphere.api.dto.scenario.processor.BeanShellPreProcessor; -import io.metersphere.api.dto.scenario.processor.JSR223PostProcessor; -import io.metersphere.api.dto.scenario.processor.JSR223PreProcessor; -import io.metersphere.api.dto.scenario.timer.ConstantTimer; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.List; @Data +@EqualsAndHashCode(callSuper = true) @JSONType(typeName = RequestType.HTTP) -public class HttpRequest implements Request { +public class HttpRequest extends Request { // type 必须放最前面,以便能够转换正确的类 private String type = RequestType.HTTP; - @JSONField(ordinal = 1) - private String id; - @JSONField(ordinal = 1) - private String name; @JSONField(ordinal = 2) private String url; @JSONField(ordinal = 3) @@ -39,28 +31,14 @@ public class HttpRequest implements Request { private List headers; @JSONField(ordinal = 8) private Body body; - @JSONField(ordinal = 9) - private Assertions assertions; - @JSONField(ordinal = 10) - private Extract extract; @JSONField(ordinal = 11) private BeanShellPreProcessor beanShellPreProcessor; @JSONField(ordinal = 12) private BeanShellPostProcessor beanShellPostProcessor; - @JSONField(ordinal = 13) - private Boolean enable; @JSONField(ordinal = 14) private Long connectTimeout; @JSONField(ordinal = 15) private Long responseTimeout; @JSONField(ordinal = 16) private Boolean followRedirects; - @JSONField(ordinal = 17) - private JSR223PreProcessor jsr223PreProcessor; - @JSONField(ordinal = 18) - private JSR223PostProcessor jsr223PostProcessor; - @JSONField(ordinal = 19) - private IfController controller; - @JSONField(ordinal = 20) - private ConstantTimer timer; } diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/request/Request.java b/backend/src/main/java/io/metersphere/api/dto/scenario/request/Request.java index 94be3e48d1..540132a56d 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/request/Request.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/request/Request.java @@ -1,8 +1,16 @@ package io.metersphere.api.dto.scenario.request; +import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONType; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; +import io.metersphere.api.dto.scenario.assertions.Assertions; +import io.metersphere.api.dto.scenario.controller.IfController; +import io.metersphere.api.dto.scenario.extract.Extract; +import io.metersphere.api.dto.scenario.processor.JSR223PostProcessor; +import io.metersphere.api.dto.scenario.processor.JSR223PreProcessor; +import io.metersphere.api.dto.scenario.timer.ConstantTimer; +import lombok.Data; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type") @JsonSubTypes({ @@ -11,5 +19,24 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; @JsonSubTypes.Type(value = SqlRequest.class, name = RequestType.SQL) }) @JSONType(seeAlso = {HttpRequest.class, DubboRequest.class, SqlRequest.class}, typeKey = "type") -public interface Request { +@Data +public abstract class Request { + @JSONField(ordinal = 1) + private String id; + @JSONField(ordinal = 2) + private String name; + @JSONField(ordinal = 3) + private Boolean enable; + @JSONField(ordinal = 4) + private Assertions assertions; + @JSONField(ordinal = 5) + private Extract extract; + @JSONField(ordinal = 6) + private JSR223PreProcessor jsr223PreProcessor; + @JSONField(ordinal = 7) + private JSR223PostProcessor jsr223PostProcessor; + @JSONField(ordinal = 8) + private IfController controller; + @JSONField(ordinal = 9) + private ConstantTimer timer; } diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/request/SqlRequest.java b/backend/src/main/java/io/metersphere/api/dto/scenario/request/SqlRequest.java index b46dfb6ac0..d48c75ac3a 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/request/SqlRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/request/SqlRequest.java @@ -2,23 +2,15 @@ package io.metersphere.api.dto.scenario.request; import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONType; -import io.metersphere.api.dto.scenario.assertions.Assertions; -import io.metersphere.api.dto.scenario.controller.IfController; -import io.metersphere.api.dto.scenario.extract.Extract; -import io.metersphere.api.dto.scenario.processor.JSR223PostProcessor; -import io.metersphere.api.dto.scenario.processor.JSR223PreProcessor; -import io.metersphere.api.dto.scenario.timer.ConstantTimer; import lombok.Data; +import lombok.EqualsAndHashCode; +@EqualsAndHashCode(callSuper = true) @Data @JSONType(typeName = RequestType.SQL) -public class SqlRequest implements Request { +public class SqlRequest extends Request { // type 必须放最前面,以便能够转换正确的类 private String type = RequestType.SQL; - @JSONField(ordinal = 1) - private String id; - @JSONField(ordinal = 2) - private String name; @JSONField(ordinal = 3) private String dataSource; @JSONField(ordinal = 4) @@ -28,23 +20,9 @@ public class SqlRequest implements Request { @JSONField(ordinal = 6) private Boolean useEnvironment; @JSONField(ordinal = 7) - private Assertions assertions; - @JSONField(ordinal = 8) - private Extract extract; - @JSONField(ordinal = 9) - private Boolean enable; - @JSONField(ordinal = 10) private Boolean followRedirects; - @JSONField(ordinal = 11) - private JSR223PreProcessor jsr223PreProcessor; - @JSONField(ordinal = 12) - private JSR223PostProcessor jsr223PostProcessor; @JSONField(ordinal = 13) private String resultVariable; @JSONField(ordinal = 14) private String variableNames; - @JSONField(ordinal = 15) - private IfController controller; - @JSONField(ordinal = 16) - private ConstantTimer timer; }