diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/utils/HttpRequestParamDiffUtils.java b/backend/services/api-test/src/main/java/io/metersphere/api/utils/HttpRequestParamDiffUtils.java index 505c2a6be7..281b6681ed 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/utils/HttpRequestParamDiffUtils.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/utils/HttpRequestParamDiffUtils.java @@ -303,7 +303,7 @@ public class HttpRequestParamDiffUtils { * @return */ public static Body syncBodyDiff(boolean isDeleteRedundantParam, Body sourceBody, Body targetBody) { - if (sourceBody == null || targetBody == null || sourceBody.getBodyType() != targetBody.getBodyType()) { + if (sourceBody == null || targetBody == null || !StringUtils.equals(sourceBody.getBodyType(), targetBody.getBodyType())) { return sourceBody; } Body.BodyType bodyType = EnumValidator.validateEnum(Body.BodyType.class, sourceBody.getBodyType()); diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/utils/HttpRequestParamDiffUtilsTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/utils/HttpRequestParamDiffUtilsTests.java index 138840d57d..0974239532 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/utils/HttpRequestParamDiffUtilsTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/utils/HttpRequestParamDiffUtilsTests.java @@ -766,6 +766,12 @@ public class HttpRequestParamDiffUtilsTests { sourceBody.getFormDataBody().getFormValues().add(formDataKV); result = HttpRequestParamDiffUtils.syncBodyDiff(true, sourceBody, targetBody); Assertions.assertEquals(result.getFormDataBody(), sourceBody.getFormDataBody()); + FormDataKV formDataKV2 = new FormDataKV(); + formDataKV2.setKey("key2"); + formDataKV2.setValue("value2"); + targetBody.getFormDataBody().getFormValues().add(formDataKV); + result = HttpRequestParamDiffUtils.syncBodyDiff(true, sourceBody, targetBody); + Assertions.assertNotEquals(result.getFormDataBody(), sourceBody.getFormDataBody()); sourceBody.setBodyType(Body.BodyType.WWW_FORM.name()); targetBody.setBodyType(Body.BodyType.WWW_FORM.name());