fix(测试跟踪): 测试计划-接口测试用例-关联接口用例,场景用例后显示乱序

--bug=1013849 --user=宋昌昌 【测试跟踪】测试计划-关联接口用例和场景用例后的显示顺序是乱序,不是按照选中的id顺序关联的 https://www.tapd.cn/55049933/s/1181619
This commit is contained in:
song-cc-rock 2022-06-14 17:45:25 +08:00 committed by jianxing
parent 4389424598
commit 11bf5fb42a
4 changed files with 11 additions and 26 deletions

View File

@ -977,13 +977,15 @@ public class ApiAutomationService {
Map<String, List<String>> mapping = request.getMapping();
Map<String, String> envMap = request.getEnvMap();
Set<String> set = mapping.keySet();
List<String> ids = new ArrayList<>(set);
Collections.reverse(ids);
String envType = request.getEnvironmentType();
String envGroupId = request.getEnvGroupId();
if (set.isEmpty()) {
return;
}
Long nextOrder = ServiceUtils.getNextOrder(request.getPlanId(), extTestPlanScenarioCaseMapper::getLastOrder);
for (String id : set) {
for (String id : ids) {
Map<String, String> newEnvMap = new HashMap<>(16);
List<String> list = mapping.get(id);
list.forEach(l -> newEnvMap.put(l, envMap == null ? "" : envMap.getOrDefault(l, "")));

View File

@ -539,13 +539,8 @@ public class ApiTestCaseService {
if (CollectionUtils.isEmpty(request.getSelectIds())) {
return;
}
// 尽量保持与用例顺序一致
Collections.reverse(request.getSelectIds());
ApiTestCaseExample example = new ApiTestCaseExample();
example.createCriteria().andApiDefinitionIdIn(request.getSelectIds());
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
relevance(apiTestCases, request);
relevance(request.getSelectIds(), request);
}
public void relevanceByApiByReview(ApiCaseRelevanceRequest request) {
@ -567,24 +562,22 @@ public class ApiTestCaseService {
if (CollectionUtils.isEmpty(ids)) {
return;
}
ApiTestCaseExample example = new ApiTestCaseExample();
example.createCriteria().andIdIn(ids);
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
relevance(apiTestCases, request);
Collections.reverse(ids);
relevance(ids, request);
}
private void relevance(List<ApiTestCase> apiTestCases, ApiCaseRelevanceRequest request) {
private void relevance(List<String> relevanceIds, ApiCaseRelevanceRequest request) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ExtTestPlanApiCaseMapper batchMapper = sqlSession.getMapper(ExtTestPlanApiCaseMapper.class);
TestPlanApiCaseMapper batchBaseMapper = sqlSession.getMapper(TestPlanApiCaseMapper.class);
Long nextOrder = ServiceUtils.getNextOrder(request.getPlanId(), extTestPlanApiCaseMapper::getLastOrder);
for (ApiTestCase apiTestCase : apiTestCases) {
for (String id : relevanceIds) {
TestPlanApiCase testPlanApiCase = new TestPlanApiCase();
testPlanApiCase.setId(UUID.randomUUID().toString());
testPlanApiCase.setCreateUser(SessionUtils.getUserId());
testPlanApiCase.setApiCaseId(apiTestCase.getId());
testPlanApiCase.setApiCaseId(id);
testPlanApiCase.setTestPlanId(request.getPlanId());
testPlanApiCase.setEnvironmentId(request.getEnvironmentId());
testPlanApiCase.setCreateTime(System.currentTimeMillis());

View File

@ -79,13 +79,8 @@ public class TestPlanApiCaseService {
}
public List<TestPlanApiCaseDTO> list(ApiTestCaseRequest request) {
List<OrderRequest> orderRequests = new ArrayList<>();
OrderRequest orderRequest = new OrderRequest();
orderRequest.setName("num");
orderRequest.setType("desc");
orderRequests.add(orderRequest);
request.setProjectId(null);
request.setOrders(orderRequests);
request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders()));
List<TestPlanApiCaseDTO> apiTestCases = extTestPlanApiCaseMapper.list(request);
ServiceUtils.buildVersionInfo(apiTestCases);
if (CollectionUtils.isEmpty(apiTestCases)) {

View File

@ -78,12 +78,7 @@ public class TestPlanScenarioCaseService {
public List<ApiScenarioDTO> list(TestPlanScenarioRequest request) {
request.setProjectId(null);
List<OrderRequest> orderRequests = new ArrayList<>();
OrderRequest orderRequest = new OrderRequest();
orderRequest.setName("num");
orderRequest.setType("desc");
orderRequests.add(orderRequest);
request.setOrders(orderRequests);
request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders()));
List<ApiScenarioDTO> apiTestCases = extTestPlanScenarioCaseMapper.list(request);
if (CollectionUtils.isEmpty(apiTestCases)) {
return apiTestCases;