refactor(接口测试): 忽略部分getxxx方法的序列化

This commit is contained in:
AgAngle 2024-12-13 14:08:50 +08:00 committed by 刘瑞斌
parent 87583d3943
commit f20fff9b9f
10 changed files with 25 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere.api.dto.request.http.body;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@ -79,10 +80,12 @@ public class Body {
bodyTypeClassMap.put(BodyType.BINARY, BinaryBody.class);
}
@JsonIgnore
public Class getBodyClassByType() {
return bodyTypeClassMap.get(BodyType.valueOf(bodyType));
}
@JsonIgnore
public Object getBodyDataByType() {
Map<BodyType, Object> boadyDataMap = new HashMap<>();
boadyDataMap.put(BodyType.NONE, noneBody);

View File

@ -1,5 +1,6 @@
package io.metersphere.api.dto.request.http.body;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.metersphere.api.dto.ApiFile;
import jakarta.validation.Valid;
import lombok.Data;
@ -27,6 +28,7 @@ public class FormDataKV extends WWWFormKV {
*/
private String contentType;
@JsonIgnore
public boolean isFile() {
return StringUtils.equalsIgnoreCase(getParamType(), BodyParamType.FILE.getValue());
}

View File

@ -1,5 +1,6 @@
package io.metersphere.project.api;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@ -19,10 +20,12 @@ public class KeyValueParam {
*/
private String value;
@JsonIgnore
public boolean isValid() {
return StringUtils.isNotBlank(key);
}
@JsonIgnore
public boolean isNotBlankValue() {
return StringUtils.isNotBlank(value);
}

View File

@ -1,5 +1,6 @@
package io.metersphere.project.api.assertion;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.metersphere.project.api.assertion.body.MsDocumentAssertion;
import io.metersphere.project.api.assertion.body.MsJSONPathAssertion;
@ -62,10 +63,12 @@ public class MsResponseBodyAssertion extends MsAssertion {
bodyAssertionClassMap.put(MsBodyAssertionType.XPATH, MsXPathAssertion.class);
}
@JsonIgnore
public Class getBodyAssertionClassByType() {
return bodyAssertionClassMap.get(MsBodyAssertionType.valueOf(assertionBodyType));
}
@JsonIgnore
public Object getBodyAssertionDataByType() {
Map<MsBodyAssertionType, Object> boadyAssertionMap = new HashMap<>();
boadyAssertionMap.put(MsBodyAssertionType.JSON_PATH, jsonPathAssertion);

View File

@ -1,5 +1,6 @@
package io.metersphere.project.api.assertion;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.metersphere.project.constants.ScriptLanguageType;
import io.metersphere.project.dto.CommonScriptInfo;
@ -36,6 +37,7 @@ public class MsScriptAssertion extends MsAssertion {
@Valid
private CommonScriptInfo commonScriptInfo;
@JsonIgnore
public boolean isValid() {
if (isEnableCommonScript()) {
return commonScriptInfo != null && StringUtils.isNotBlank(commonScriptInfo.getId());
@ -44,6 +46,7 @@ public class MsScriptAssertion extends MsAssertion {
}
}
@JsonIgnore
public boolean isEnableCommonScript() {
return BooleanUtils.isTrue(enableCommonScript);
}

View File

@ -1,5 +1,6 @@
package io.metersphere.project.api.assertion.body;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.metersphere.sdk.constants.MsAssertionCondition;
import io.metersphere.sdk.valid.EnumValue;
import jakarta.validation.constraints.NotBlank;
@ -31,6 +32,7 @@ public class MsJSONPathAssertionItem extends MsBodyAssertionItem {
*/
private String expectedValue;
@JsonIgnore
public boolean isValid() {
return StringUtils.isNotBlank(expression)
&& StringUtils.isNotBlank(condition)

View File

@ -1,5 +1,6 @@
package io.metersphere.project.api.assertion.body;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@ -15,6 +16,7 @@ public class MsRegexAssertionItem extends MsBodyAssertionItem {
*/
private String expression;
@JsonIgnore
public boolean isValid() {
return StringUtils.isNotBlank(expression) && Boolean.TRUE.equals(this.getEnable());
}

View File

@ -1,6 +1,7 @@
package io.metersphere.project.api.assertion.body;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@ -20,6 +21,7 @@ public class MsXPathAssertionItem extends MsBodyAssertionItem {
*/
private String expectedValue;
@JsonIgnore
public boolean isValid() {
return StringUtils.isNotBlank(expression) && Boolean.TRUE.equals(this.getEnable());
}

View File

@ -1,5 +1,6 @@
package io.metersphere.project.api.processor;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.metersphere.project.constants.ScriptLanguageType;
import io.metersphere.project.dto.CommonScriptInfo;
@ -44,7 +45,7 @@ public class ScriptProcessor extends MsProcessor {
@Valid
private CommonScriptInfo commonScriptInfo;
@JsonIgnore
public boolean isValid() {
if (isEnableCommonScript()) {
return commonScriptInfo != null && StringUtils.isNotBlank(commonScriptInfo.getId());
@ -53,6 +54,7 @@ public class ScriptProcessor extends MsProcessor {
}
}
@JsonIgnore
public boolean isEnableCommonScript() {
return BooleanUtils.isTrue(enableCommonScript);
}

View File

@ -1,5 +1,6 @@
package io.metersphere.project.api.processor.extract;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.metersphere.sdk.valid.EnumValue;
@ -51,6 +52,7 @@ public abstract class MsExtract {
*/
private String description;
@JsonIgnore
public boolean isValid() {
return StringUtils.isNotBlank(variableName) && StringUtils.isNotBlank(expression);
}