fix(测试跟踪): 测试计划允许重复关联用例配置对接口用例无效

--bug=1019333 --user=陈建星 【测试跟踪】测试计划开启允许关联重复用例后,关联重复接口用例时用例数没增加 https://www.tapd.cn/55049933/s/1293220
This commit is contained in:
chenjianxing 2022-11-09 13:53:35 +08:00 committed by jianxing
parent 53d5ccf49f
commit 2a661ac7b3
5 changed files with 99 additions and 2 deletions

View File

@ -0,0 +1,27 @@
package io.metersphere.controller.remote;
import io.metersphere.dto.ApiCaseRelevanceRequest;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.service.remote.api.RelevanceApiCaseService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RequestMapping("/api/testcase")
@RestController
public class TrackApiCaseController {
@Resource
RelevanceApiCaseService relevanceApiCaseService;
@Resource
TestPlanService testPlanService;
@PostMapping("/relevance")
public void relevance(@RequestBody ApiCaseRelevanceRequest request) {
request.setAllowedRepeatCase(testPlanService.isAllowedRepeatCase(request.getPlanId()));
relevanceApiCaseService.relevance(request);
}
}

View File

@ -1,6 +1,8 @@
package io.metersphere.controller.remote; package io.metersphere.controller.remote;
import io.metersphere.dto.ApiCaseRelevanceRequest;
import io.metersphere.plan.request.api.ApiDefinitionRequest; import io.metersphere.plan.request.api.ApiDefinitionRequest;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.plan.service.remote.api.PlanApiDefinitionService; import io.metersphere.plan.service.remote.api.PlanApiDefinitionService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -12,10 +14,18 @@ public class TrackApiDefinitionController {
@Resource @Resource
PlanApiDefinitionService planApiDefinitionService; PlanApiDefinitionService planApiDefinitionService;
@Resource
TestPlanService testPlanService;
@PostMapping("/list/relevance/{goPage}/{pageSize}") @PostMapping("/list/relevance/{goPage}/{pageSize}")
public Object listRelevance(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) { public Object listRelevance(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {
return planApiDefinitionService.listRelevance(request, goPage, pageSize); return planApiDefinitionService.listRelevance(request, goPage, pageSize);
} }
@PostMapping("/relevance")
public void relevance(@RequestBody ApiCaseRelevanceRequest request) {
request.setAllowedRepeatCase(testPlanService.isAllowedRepeatCase(request.getPlanId()));
planApiDefinitionService.relevance(request);
}
} }

View File

@ -0,0 +1,49 @@
package io.metersphere.dto;
import io.metersphere.plan.request.api.ApiScenarioRequest;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Getter
@Setter
public class ApiCaseRelevanceRequest {
/**
* 测试计划ID
*/
private String planId;
private String environmentId;
/**
* 具体要关联的用例
*/
private List<String> selectIds = new ArrayList<>();
/**
* 项目环境对应关系
*/
private Map<String, String> envMap;
/**
* 用例的环境的对应关系
*/
private Map<String, List<String>> mapping;
/**
*测试评审ID
*/
private String reviewId;
private String environmentType;
private String envGroupId;
private List<String> ids;
private ApiScenarioRequest condition;
private Boolean allowedRepeatCase = false;
}

View File

@ -1,5 +1,6 @@
package io.metersphere.plan.service.remote.api; package io.metersphere.plan.service.remote.api;
import io.metersphere.dto.ApiCaseRelevanceRequest;
import io.metersphere.plan.request.api.ApiDefinitionRequest; import io.metersphere.plan.request.api.ApiDefinitionRequest;
import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.service.TestPlanService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -11,7 +12,7 @@ import javax.annotation.Resource;
@Service @Service
public class PlanApiDefinitionService extends ApiTestService { public class PlanApiDefinitionService extends ApiTestService {
private static final String BASE_UEL = "/api/definition"; private static final String BASE_URL = "/api/definition";
@Resource @Resource
@Lazy @Lazy
@ -21,6 +22,11 @@ public class PlanApiDefinitionService extends ApiTestService {
if (StringUtils.isNotBlank(request.getPlanId()) && testPlanService.isAllowedRepeatCase(request.getPlanId())) { if (StringUtils.isNotBlank(request.getPlanId()) && testPlanService.isAllowedRepeatCase(request.getPlanId())) {
request.setRepeatCase(true); request.setRepeatCase(true);
} }
return microService.postForData(serviceName, BASE_UEL + String.format("/list/relevance/%s/%s", pageNum, pageSize), request); return microService.postForData(serviceName, BASE_URL + String.format("/list/relevance/%s/%s", pageNum, pageSize), request);
} }
public void relevance(ApiCaseRelevanceRequest request) {
microService.postForData(serviceName, BASE_URL + "/relevance", request);
}
} }

View File

@ -2,6 +2,7 @@ package io.metersphere.service.remote.api;
import io.metersphere.base.domain.ApiScenario; import io.metersphere.base.domain.ApiScenario;
import io.metersphere.base.domain.ApiTestCase; import io.metersphere.base.domain.ApiTestCase;
import io.metersphere.dto.ApiCaseRelevanceRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -15,6 +16,10 @@ public class RelevanceApiCaseService extends TrackApiTestService{
return microService.postForDataArray(serviceName, BASE_URL + "/getApiCaseByIds", ids, ApiTestCase.class); return microService.postForDataArray(serviceName, BASE_URL + "/getApiCaseByIds", ids, ApiTestCase.class);
} }
public void relevance(ApiCaseRelevanceRequest param) {
microService.postForData(serviceName, BASE_URL + "/relevance", param);
}
public List<ApiScenario> getScenarioCaseByIds(List<String> ids) { public List<ApiScenario> getScenarioCaseByIds(List<String> ids) {
return microService.postForDataArray(serviceName, BASE_URL + "/getScenarioCaseByIds", ids, ApiScenario.class); return microService.postForDataArray(serviceName, BASE_URL + "/getScenarioCaseByIds", ids, ApiScenario.class);
} }