fix(接口测试): 场景导入设置默认版本

--user=郭雨琦
This commit is contained in:
guoyuqi 2022-07-05 11:43:24 +08:00 committed by xiaomeinvG
parent 138f2ccfe6
commit cb7051ff9a
4 changed files with 10 additions and 39 deletions

View File

@ -1307,6 +1307,8 @@ public class ApiAutomationService {
List<ApiScenarioWithBLOBs> initData = apiImport.getData();
currentScenarioOrder.remove();
String defaultVersion = extProjectVersionMapper.getDefaultVersion(request.getProjectId());
request.setDefaultVersion(defaultVersion);
UpdateScenarioModuleDTO updateScenarioModuleDTO = apiScenarioModuleService.checkScenarioModule(request, initData, StringUtils.equals("fullCoverage", request.getModeId()), request.getCoverModule());
List<ApiScenarioModule> moduleList = updateScenarioModuleDTO.getModuleList();
@ -1326,10 +1328,8 @@ public class ApiAutomationService {
num = getNextNum(data.get(0).getProjectId());
request.setOpenCustomNum(config.getScenarioCustomNum());
}
String defaultVersion = extProjectVersionMapper.getDefaultVersion(request.getProjectId());
request.setDefaultVersion(defaultVersion);
for (int i = 0; i < data.size(); i++) {
for (int i = 0; i < data.size(); i++) {
ApiScenarioWithBLOBs item = data.get(i);
List<ApiScenarioWithBLOBs> sameList = needUpdateList.stream().filter(t -> t.getId().equals(item.getId())).collect(toList());
if (StringUtils.isBlank(item.getCreateUser())) {

View File

@ -528,9 +528,9 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
//处理模块
setModule(optionData, moduleMap, pidChildrenMap, idPathMap, idModuleMap, chooseModule);
List<String> names = optionData.stream().map(ApiScenario::getName).collect(Collectors.toList());
//系统内重复的数据
List<ApiScenarioWithBLOBs> repeatApiScenarioWithBLOBs = extApiScenarioMapper.selectRepeatByBLOBs(optionData, projectId, versionSet);
List<ApiScenarioWithBLOBs> repeatApiScenarioWithBLOBs = extApiScenarioMapper.selectRepeatByBLOBs(names, projectId, versionSet);
moduleMap = getApiScenarioModuleMap(fullCoverage, fullCoverageScenario, moduleMap, toUpdateList, chooseModuleId, idPathMap, chooseModule, optionData, repeatApiScenarioWithBLOBs);

View File

@ -91,9 +91,7 @@ public interface ExtApiScenarioMapper {
List<ApiScenarioWithBLOBs> selectByStatusIsNotTrash();
List<ApiScenarioWithBLOBs> selectRepeatByBLOBs(@Param("blobs") List<ApiScenarioWithBLOBs> blobs, @Param("projectId") String projectId, @Param("versionIds") Set<String> versionIds);
List<ApiScenarioWithBLOBs> selectRepeatByBLOBsSameUrl(@Param("blobs") List<ApiScenarioWithBLOBs> blobs, @Param("projectId") String projectId, @Param("moduleId") String moduleId, @Param("versionIds") Set<String> versionIds);
List<ApiScenarioWithBLOBs> selectRepeatByBLOBs(@Param("names") List<String> names, @Param("projectId") String projectId, @Param("versionIds") Set<String> versionIds);
}

View File

@ -756,7 +756,10 @@
</select>
<select id="selectRepeatByBLOBs" resultType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
SELECT * from api_scenario
<include refid="Same_Where_Clause"/>
where name in
<foreach collection="names" item="name" separator="," open="(" close=")">
#{name}
</foreach>
and status != 'Trash'
and project_id = #{projectId}
and version_id in
@ -765,35 +768,5 @@
</foreach>
</select>
<select id="selectRepeatByBLOBsSameUrl" resultType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
SELECT * from api_scenario
<include refid="Same_Where_Clause"/>
and status != 'TRASH'
and api_scenario_module_id = #{moduleId}
and project_id = #{projectId}
and version_id in
<foreach collection="versionIds" item="versionId" separator="," open="(" close=")">
#{versionId}
</foreach>
</select>
<sql id="Same_Where_Clause">
<where>
<if test="blobs">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="blobs" item="blob" separator="or">
<trim prefix="(" prefixOverrides="and" suffix=")">
<if test="blob.name">
and api_scenario.name = #{blob.name}
</if>
</trim>
</foreach>
</trim>
</if>
</where>
</sql>
</mapper>