refactor(接口测试): 常量命名统一规范

This commit is contained in:
fit2-zhao 2023-01-04 16:28:06 +08:00 committed by fit2-zhao
parent 55822e7dc0
commit f4985cb99a
5 changed files with 6 additions and 6 deletions

View File

@ -1,7 +1,7 @@
package io.metersphere.commons.constants; package io.metersphere.commons.constants;
public class CommonConstants { public class CommonConstants {
public static final String TrashStatus = "Trash"; public static final String TRASH_STATUS = "Trash";
public static final String TEST_PLAN = "TEST_PLAN"; public static final String TEST_PLAN = "TEST_PLAN";
public static final String LOCAL_STATUS_KEY = "LOCAL_STATUS_KEY"; public static final String LOCAL_STATUS_KEY = "LOCAL_STATUS_KEY";
public static final String REPORT_STATUS = "REPORT_STATUS"; public static final String REPORT_STATUS = "REPORT_STATUS";

View File

@ -986,7 +986,7 @@ public class ApiTestCaseService {
if (CollectionUtils.isNotEmpty(apiCaseIds)) { if (CollectionUtils.isNotEmpty(apiCaseIds)) {
ApiTestCaseExample example = new ApiTestCaseExample(); ApiTestCaseExample example = new ApiTestCaseExample();
example.createCriteria().andIdIn(apiCaseIds); example.createCriteria().andIdIn(apiCaseIds);
example.or().andStatusNotEqualTo(CommonConstants.TrashStatus).andStatusIsNull(); example.or().andStatusNotEqualTo(CommonConstants.TRASH_STATUS).andStatusIsNull();
return apiTestCaseMapper.selectByExample(example); return apiTestCaseMapper.selectByExample(example);
} }
return new ArrayList<>(); return new ArrayList<>();

View File

@ -734,9 +734,9 @@ public class TestPlanApiCaseService {
List<String> caseIds = apiCases.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList()); List<String> caseIds = apiCases.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList());
List<String> definitionIds = apiTestCaseService.selectCasesBydIds(caseIds).stream().filter(apiTestCase -> apiTestCase.getStatus() == null || !CommonConstants.TrashStatus.equals(apiTestCase.getStatus())).map(ApiTestCase::getApiDefinitionId).collect(Collectors.toList()); List<String> definitionIds = apiTestCaseService.selectCasesBydIds(caseIds).stream().filter(apiTestCase -> apiTestCase.getStatus() == null || !CommonConstants.TRASH_STATUS.equals(apiTestCase.getStatus())).map(ApiTestCase::getApiDefinitionId).collect(Collectors.toList());
List<String> dataNodeIds = apiDefinitionService.selectApiDefinitionBydIds(definitionIds).stream().filter(apiDefinition -> apiDefinition.getStatus() == null || !CommonConstants.TrashStatus.equals(apiDefinition.getStatus())).map(ApiDefinition::getModuleId).collect(Collectors.toList()); List<String> dataNodeIds = apiDefinitionService.selectApiDefinitionBydIds(definitionIds).stream().filter(apiDefinition -> apiDefinition.getStatus() == null || !CommonConstants.TRASH_STATUS.equals(apiDefinition.getStatus())).map(ApiDefinition::getModuleId).collect(Collectors.toList());
List<ApiModuleDTO> nodeTrees = apiModuleService.getNodeTrees(testCaseNodes); List<ApiModuleDTO> nodeTrees = apiModuleService.getNodeTrees(testCaseNodes);

View File

@ -1149,7 +1149,7 @@ public class TestPlanScenarioCaseService {
.collect(Collectors.toList()); .collect(Collectors.toList());
List<String> dataNodeIds = apiAutomationService.selectByIds(caseIds).stream() List<String> dataNodeIds = apiAutomationService.selectByIds(caseIds).stream()
.filter(apiScenario -> apiScenario.getStatus() == null || !CommonConstants.TrashStatus.equals(apiScenario.getStatus())) .filter(apiScenario -> apiScenario.getStatus() == null || !CommonConstants.TRASH_STATUS.equals(apiScenario.getStatus()))
.map(ApiScenario::getApiScenarioModuleId) .map(ApiScenario::getApiScenarioModuleId)
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@ -2222,7 +2222,7 @@ public class ApiScenarioService {
public List<ApiScenario> getScenarioCaseByIds(List<String> ids) { public List<ApiScenario> getScenarioCaseByIds(List<String> ids) {
if (CollectionUtils.isNotEmpty(ids)) { if (CollectionUtils.isNotEmpty(ids)) {
ApiScenarioExample example = new ApiScenarioExample(); ApiScenarioExample example = new ApiScenarioExample();
example.createCriteria().andIdIn(ids).andStatusNotEqualTo(CommonConstants.TrashStatus); example.createCriteria().andIdIn(ids).andStatusNotEqualTo(CommonConstants.TRASH_STATUS);
return apiScenarioMapper.selectByExample(example); return apiScenarioMapper.selectByExample(example);
} }
return new ArrayList<>(); return new ArrayList<>();