fix(接口测试): 修复接口请求体会缩减数字精度的缺陷

--bug=1025842 --user=王孝刚 【接口测试】接口请求体会缩减数字精度
https://www.tapd.cn/55049933/s/1369188
This commit is contained in:
wxg0103 2023-05-05 20:22:51 +08:00 committed by fit2-zhao
parent 1f09f13d00
commit 2626394659
1 changed files with 5 additions and 4 deletions

View File

@ -10,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -122,11 +123,11 @@ public class JSONSchemaParser {
}
if (FormatterUtil.isMockValue(object)) {
if (FormatterUtil.isNumber(FormatterUtil.getStrValue(object))) {
Number value = FormatterUtil.getElementValue(object).getAsNumber();
if (value.toString().indexOf(".") == -1) {
concept.put(propertyName, value.longValue());
String value = FormatterUtil.getElementValue(object).getAsString();
if (value.indexOf(".") == -1) {
concept.put(propertyName, Integer.valueOf(value));
} else {
concept.put(propertyName, value.floatValue());
concept.put(propertyName, new BigDecimal(value));
}
} else {
JSONSchemaBuilder.processValue(concept, processMap, propertyName, FormatterUtil.getStrValue(object));