refactor(接口测试): 修复接口引用信息表中存储dubbo格式数据会报错的问题

--bug=1014210 --user=宋天阳 [接口测试]github
#14986api_scenario_reference_id表设计有问题
https://www.tapd.cn/55049933/s/1185047
This commit is contained in:
song-tianyang 2022-06-17 15:45:12 +08:00 committed by f2c-ci-robot[bot]
parent dcf0c9382b
commit d43be9bc35
1 changed files with 12 additions and 5 deletions

View File

@ -10,7 +10,6 @@ import io.metersphere.base.mapper.ApiScenarioReferenceIdMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioReferenceIdMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioReferenceIdMapper;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
@ -20,7 +19,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; 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 * @author song.tianyang
@ -122,9 +124,7 @@ public class ApiScenarioReferenceIdService {
} else if (item.containsKey(MsHashTreeService.URL)) { } else if (item.containsKey(MsHashTreeService.URL)) {
url = item.getString(MsHashTreeService.URL); url = item.getString(MsHashTreeService.URL);
} }
if (item.containsKey(MsHashTreeService.METHOD)) { method = this.getMethodFromSample(item);
method = item.getString(MsHashTreeService.METHOD);
}
ApiScenarioReferenceId saveItem = new ApiScenarioReferenceId(); ApiScenarioReferenceId saveItem = new ApiScenarioReferenceId();
saveItem.setId(UUID.randomUUID().toString()); saveItem.setId(UUID.randomUUID().toString());
saveItem.setApiScenarioId(scenario.getId()); saveItem.setApiScenarioId(scenario.getId());
@ -153,6 +153,13 @@ public class ApiScenarioReferenceIdService {
return returnList; 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<ApiScenarioReferenceId> deepElementRelation(String scenarioId, JSONArray hashTree) { public List<ApiScenarioReferenceId> deepElementRelation(String scenarioId, JSONArray hashTree) {
List<ApiScenarioReferenceId> deepRelations = new LinkedList<>(); List<ApiScenarioReferenceId> deepRelations = new LinkedList<>();
if (CollectionUtils.isNotEmpty(hashTree)) { if (CollectionUtils.isNotEmpty(hashTree)) {