fix(接口测试): 修复接口定义执行时string取枚举值的缺陷
--bug=1020660 --user=王孝刚 【接口测试】json-schema请求体,string类型的参数值为空时会取枚举值 https://www.tapd.cn/55049933/s/1313197
This commit is contained in:
parent
fad9e039c0
commit
dcc5e013e5
|
@ -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<Object> 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);
|
||||
|
|
Loading…
Reference in New Issue