From dcc5e013e57c5e499e2f3fc0905921d7986e4a91 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Mon, 5 Dec 2022 18:32:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=97=B6string=E5=8F=96=E6=9E=9A=E4=B8=BE=E5=80=BC?= =?UTF-8?q?=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020660 --user=王孝刚 【接口测试】json-schema请求体,string类型的参数值为空时会取枚举值 https://www.tapd.cn/55049933/s/1313197 --- .../api/exec/generator/JSONSchemaRunTest.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaRunTest.java b/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaRunTest.java index f69bd76b0e..519759f689 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaRunTest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaRunTest.java @@ -3,10 +3,8 @@ package io.metersphere.api.exec.generator; import com.google.gson.*; import io.metersphere.commons.constants.PropertyConstant; -import io.metersphere.commons.utils.EnumPropertyUtil; import io.metersphere.commons.utils.JSONUtil; import io.metersphere.jmeter.utils.ScriptEngineUtils; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; @@ -14,7 +12,6 @@ import org.json.JSONObject; import org.springframework.util.NumberUtils; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -252,12 +249,6 @@ public class JSONSchemaRunTest { if (isMock(object)) { String value = ScriptEngineUtils.buildFunctionCallString(object.get(PropertyConstant.MOCK).getAsJsonObject().get(PropertyConstant.MOCK).getAsString()); return value; - } else if (object.has(PropertyConstant.ENUM)) { - List list = EnumPropertyUtil.analyzeEnumProperty(object); - if (CollectionUtils.isNotEmpty(list)) { - int index = (int) (Math.random() * list.size()); - return list.get(index); - } } } catch (Exception e) { return object.get(PropertyConstant.MOCK).getAsJsonObject().get(PropertyConstant.MOCK);