From d43be9bc35936201cd3b2f695e202a3d3f1b6aaa Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 17 Jun 2022 15:45:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=A1=A8=E4=B8=AD=E5=AD=98=E5=82=A8dubbo?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=95=B0=E6=8D=AE=E4=BC=9A=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1014210 --user=宋天阳 [接口测试]github #14986api_scenario_reference_id表设计有问题 https://www.tapd.cn/55049933/s/1185047 --- .../service/ApiScenarioReferenceIdService.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReferenceIdService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReferenceIdService.java index 87e8f50f17..09ae899aac 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReferenceIdService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReferenceIdService.java @@ -10,7 +10,6 @@ import io.metersphere.base.mapper.ApiScenarioReferenceIdMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioReferenceIdMapper; import io.metersphere.commons.utils.SessionUtils; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -20,7 +19,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; /** * @author song.tianyang @@ -122,9 +124,7 @@ public class ApiScenarioReferenceIdService { } else if (item.containsKey(MsHashTreeService.URL)) { url = item.getString(MsHashTreeService.URL); } - if (item.containsKey(MsHashTreeService.METHOD)) { - method = item.getString(MsHashTreeService.METHOD); - } + method = this.getMethodFromSample(item); ApiScenarioReferenceId saveItem = new ApiScenarioReferenceId(); saveItem.setId(UUID.randomUUID().toString()); saveItem.setApiScenarioId(scenario.getId()); @@ -153,6 +153,13 @@ public class ApiScenarioReferenceIdService { return returnList; } + private String getMethodFromSample(JSONObject item) { + String method = null; + if (item.containsKey(MsHashTreeService.TYPE) && item.containsKey(MsHashTreeService.METHOD) && StringUtils.equalsIgnoreCase(item.getString(MsHashTreeService.TYPE), "HTTPSamplerProxy")) + method = item.getString(MsHashTreeService.METHOD); + return method; + } + public List deepElementRelation(String scenarioId, JSONArray hashTree) { List deepRelations = new LinkedList<>(); if (CollectionUtils.isNotEmpty(hashTree)) {