refactor: Request改为类,增加公共属性
This commit is contained in:
parent
4f3af764d5
commit
831741c97d
|
@ -4,30 +4,22 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import io.metersphere.api.dto.scenario.KeyValue;
|
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.BeanShellPostProcessor;
|
||||||
import io.metersphere.api.dto.scenario.processor.BeanShellPreProcessor;
|
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.ConfigCenter;
|
||||||
import io.metersphere.api.dto.scenario.request.dubbo.ConsumerAndService;
|
import io.metersphere.api.dto.scenario.request.dubbo.ConsumerAndService;
|
||||||
import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter;
|
import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter;
|
||||||
import io.metersphere.api.dto.scenario.timer.ConstantTimer;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@JSONType(typeName = RequestType.DUBBO)
|
@JSONType(typeName = RequestType.DUBBO)
|
||||||
public class DubboRequest implements Request {
|
public class DubboRequest extends Request {
|
||||||
// type 必须放最前面,以便能够转换正确的类
|
// type 必须放最前面,以便能够转换正确的类
|
||||||
private String type = RequestType.DUBBO;
|
private String type = RequestType.DUBBO;
|
||||||
@JSONField(ordinal = 1)
|
|
||||||
private String id;
|
|
||||||
@JSONField(ordinal = 1)
|
|
||||||
private String name;
|
|
||||||
@JSONField(ordinal = 2)
|
@JSONField(ordinal = 2)
|
||||||
private String protocol;
|
private String protocol;
|
||||||
@JsonProperty(value = "interface")
|
@JsonProperty(value = "interface")
|
||||||
|
@ -47,22 +39,8 @@ public class DubboRequest implements Request {
|
||||||
private List<KeyValue> args;
|
private List<KeyValue> args;
|
||||||
@JSONField(ordinal = 9)
|
@JSONField(ordinal = 9)
|
||||||
private List<KeyValue> attachmentArgs;
|
private List<KeyValue> attachmentArgs;
|
||||||
@JSONField(ordinal = 10)
|
|
||||||
private Assertions assertions;
|
|
||||||
@JSONField(ordinal = 11)
|
|
||||||
private Extract extract;
|
|
||||||
@JSONField(ordinal = 12)
|
@JSONField(ordinal = 12)
|
||||||
private BeanShellPreProcessor beanShellPreProcessor;
|
private BeanShellPreProcessor beanShellPreProcessor;
|
||||||
@JSONField(ordinal = 13)
|
@JSONField(ordinal = 13)
|
||||||
private BeanShellPostProcessor beanShellPostProcessor;
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,27 +4,19 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
import io.metersphere.api.dto.scenario.Body;
|
import io.metersphere.api.dto.scenario.Body;
|
||||||
import io.metersphere.api.dto.scenario.KeyValue;
|
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.BeanShellPostProcessor;
|
||||||
import io.metersphere.api.dto.scenario.processor.BeanShellPreProcessor;
|
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.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@JSONType(typeName = RequestType.HTTP)
|
@JSONType(typeName = RequestType.HTTP)
|
||||||
public class HttpRequest implements Request {
|
public class HttpRequest extends Request {
|
||||||
// type 必须放最前面,以便能够转换正确的类
|
// type 必须放最前面,以便能够转换正确的类
|
||||||
private String type = RequestType.HTTP;
|
private String type = RequestType.HTTP;
|
||||||
@JSONField(ordinal = 1)
|
|
||||||
private String id;
|
|
||||||
@JSONField(ordinal = 1)
|
|
||||||
private String name;
|
|
||||||
@JSONField(ordinal = 2)
|
@JSONField(ordinal = 2)
|
||||||
private String url;
|
private String url;
|
||||||
@JSONField(ordinal = 3)
|
@JSONField(ordinal = 3)
|
||||||
|
@ -39,28 +31,14 @@ public class HttpRequest implements Request {
|
||||||
private List<KeyValue> headers;
|
private List<KeyValue> headers;
|
||||||
@JSONField(ordinal = 8)
|
@JSONField(ordinal = 8)
|
||||||
private Body body;
|
private Body body;
|
||||||
@JSONField(ordinal = 9)
|
|
||||||
private Assertions assertions;
|
|
||||||
@JSONField(ordinal = 10)
|
|
||||||
private Extract extract;
|
|
||||||
@JSONField(ordinal = 11)
|
@JSONField(ordinal = 11)
|
||||||
private BeanShellPreProcessor beanShellPreProcessor;
|
private BeanShellPreProcessor beanShellPreProcessor;
|
||||||
@JSONField(ordinal = 12)
|
@JSONField(ordinal = 12)
|
||||||
private BeanShellPostProcessor beanShellPostProcessor;
|
private BeanShellPostProcessor beanShellPostProcessor;
|
||||||
@JSONField(ordinal = 13)
|
|
||||||
private Boolean enable;
|
|
||||||
@JSONField(ordinal = 14)
|
@JSONField(ordinal = 14)
|
||||||
private Long connectTimeout;
|
private Long connectTimeout;
|
||||||
@JSONField(ordinal = 15)
|
@JSONField(ordinal = 15)
|
||||||
private Long responseTimeout;
|
private Long responseTimeout;
|
||||||
@JSONField(ordinal = 16)
|
@JSONField(ordinal = 16)
|
||||||
private Boolean followRedirects;
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
package io.metersphere.api.dto.scenario.request;
|
package io.metersphere.api.dto.scenario.request;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
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")
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type")
|
||||||
@JsonSubTypes({
|
@JsonSubTypes({
|
||||||
|
@ -11,5 +19,24 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
@JsonSubTypes.Type(value = SqlRequest.class, name = RequestType.SQL)
|
@JsonSubTypes.Type(value = SqlRequest.class, name = RequestType.SQL)
|
||||||
})
|
})
|
||||||
@JSONType(seeAlso = {HttpRequest.class, DubboRequest.class, SqlRequest.class}, typeKey = "type")
|
@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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,15 @@ package io.metersphere.api.dto.scenario.request;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
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.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
@JSONType(typeName = RequestType.SQL)
|
@JSONType(typeName = RequestType.SQL)
|
||||||
public class SqlRequest implements Request {
|
public class SqlRequest extends Request {
|
||||||
// type 必须放最前面,以便能够转换正确的类
|
// type 必须放最前面,以便能够转换正确的类
|
||||||
private String type = RequestType.SQL;
|
private String type = RequestType.SQL;
|
||||||
@JSONField(ordinal = 1)
|
|
||||||
private String id;
|
|
||||||
@JSONField(ordinal = 2)
|
|
||||||
private String name;
|
|
||||||
@JSONField(ordinal = 3)
|
@JSONField(ordinal = 3)
|
||||||
private String dataSource;
|
private String dataSource;
|
||||||
@JSONField(ordinal = 4)
|
@JSONField(ordinal = 4)
|
||||||
|
@ -28,23 +20,9 @@ public class SqlRequest implements Request {
|
||||||
@JSONField(ordinal = 6)
|
@JSONField(ordinal = 6)
|
||||||
private Boolean useEnvironment;
|
private Boolean useEnvironment;
|
||||||
@JSONField(ordinal = 7)
|
@JSONField(ordinal = 7)
|
||||||
private Assertions assertions;
|
|
||||||
@JSONField(ordinal = 8)
|
|
||||||
private Extract extract;
|
|
||||||
@JSONField(ordinal = 9)
|
|
||||||
private Boolean enable;
|
|
||||||
@JSONField(ordinal = 10)
|
|
||||||
private Boolean followRedirects;
|
private Boolean followRedirects;
|
||||||
@JSONField(ordinal = 11)
|
|
||||||
private JSR223PreProcessor jsr223PreProcessor;
|
|
||||||
@JSONField(ordinal = 12)
|
|
||||||
private JSR223PostProcessor jsr223PostProcessor;
|
|
||||||
@JSONField(ordinal = 13)
|
@JSONField(ordinal = 13)
|
||||||
private String resultVariable;
|
private String resultVariable;
|
||||||
@JSONField(ordinal = 14)
|
@JSONField(ordinal = 14)
|
||||||
private String variableNames;
|
private String variableNames;
|
||||||
@JSONField(ordinal = 15)
|
|
||||||
private IfController controller;
|
|
||||||
@JSONField(ordinal = 16)
|
|
||||||
private ConstantTimer timer;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue