feat(接口测试): 不同版本的相同接口应该不能创建多条
--user=郭雨琦 --story=1008821 https://www.tapd.cn/55049933/prong/stories/view/1155049933001008821
This commit is contained in:
parent
84149d5ea1
commit
50eaaf976b
|
@ -718,16 +718,32 @@ public class ApiAutomationService {
|
||||||
.andProjectIdEqualTo(request.getProjectId())
|
.andProjectIdEqualTo(request.getProjectId())
|
||||||
.andStatusNotEqualTo("Trash")
|
.andStatusNotEqualTo("Trash")
|
||||||
.andIdNotEqualTo(request.getId())
|
.andIdNotEqualTo(request.getId())
|
||||||
.andVersionIdEqualTo(request.getVersionId())
|
|
||||||
.andApiScenarioModuleIdEqualTo(request.getApiScenarioModuleId());
|
.andApiScenarioModuleIdEqualTo(request.getApiScenarioModuleId());
|
||||||
if (moduleIdNotExist) {
|
if (moduleIdNotExist) {
|
||||||
criteria.andModulePathEqualTo(request.getModulePath());
|
criteria.andModulePathEqualTo(request.getModulePath());
|
||||||
} else {
|
} else {
|
||||||
criteria.andApiScenarioModuleIdEqualTo(request.getApiScenarioModuleId());
|
criteria.andApiScenarioModuleIdEqualTo(request.getApiScenarioModuleId());
|
||||||
}
|
}
|
||||||
|
if (apiScenarioMapper.countByExample(example) > 0 && StringUtils.isBlank(request.getId())) {
|
||||||
|
MSException.throwException(Translator.get("automation_versions_create"));
|
||||||
|
}
|
||||||
|
criteria.andVersionIdEqualTo(request.getVersionId());
|
||||||
if (apiScenarioMapper.countByExample(example) > 0) {
|
if (apiScenarioMapper.countByExample(example) > 0) {
|
||||||
MSException.throwException(Translator.get("automation_name_already_exists") + " :" + Translator.get("api_definition_module") + request.getModulePath() + " ," + Translator.get("automation_name") + " :" + request.getName());
|
MSException.throwException(Translator.get("automation_name_already_exists") + " :" + Translator.get("api_definition_module") + request.getModulePath() + " ," + Translator.get("automation_name") + " :" + request.getName());
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isNotBlank(request.getId())) {
|
||||||
|
ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(request.getId());
|
||||||
|
if (scenario != null) {
|
||||||
|
example = new ApiScenarioExample();
|
||||||
|
example.createCriteria().andRefIdEqualTo(scenario.getRefId()).andStatusNotEqualTo("Trash");
|
||||||
|
List<ApiScenario> apiScenarios = apiScenarioMapper.selectByExample(example);
|
||||||
|
if (apiScenarios != null && apiScenarios.size() > 1) {
|
||||||
|
if (!StringUtils.equals(scenario.getName(), request.getName())) {
|
||||||
|
MSException.throwException(Translator.get("automation_versions_update"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiScenarioDTO getNewApiScenario(String id) {
|
public ApiScenarioDTO getNewApiScenario(String id) {
|
||||||
|
|
|
@ -623,8 +623,7 @@ public class ApiDefinitionService {
|
||||||
if (StringUtils.isNotEmpty(request.getProtocol()) && request.getProtocol().equals(RequestType.HTTP)) {
|
if (StringUtils.isNotEmpty(request.getProtocol()) && request.getProtocol().equals(RequestType.HTTP)) {
|
||||||
criteria.andMethodEqualTo(request.getMethod()).andStatusNotEqualTo("Trash")
|
criteria.andMethodEqualTo(request.getMethod()).andStatusNotEqualTo("Trash")
|
||||||
.andProtocolEqualTo(request.getProtocol()).andPathEqualTo(request.getPath())
|
.andProtocolEqualTo(request.getProtocol()).andPathEqualTo(request.getPath())
|
||||||
.andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId())
|
.andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId());
|
||||||
.andVersionIdEqualTo(request.getVersionId());
|
|
||||||
Project project = projectMapper.selectByPrimaryKey(request.getProjectId());
|
Project project = projectMapper.selectByPrimaryKey(request.getProjectId());
|
||||||
ProjectConfig config = projectApplicationService.getSpecificTypeValue(project.getId(), ProjectApplicationType.URL_REPEATABLE.name());
|
ProjectConfig config = projectApplicationService.getSpecificTypeValue(project.getId(), ProjectApplicationType.URL_REPEATABLE.name());
|
||||||
boolean urlRepeat = config.getUrlRepeatable();
|
boolean urlRepeat = config.getUrlRepeatable();
|
||||||
|
@ -635,10 +634,18 @@ public class ApiDefinitionService {
|
||||||
criteria.andModuleIdEqualTo(request.getModuleId());
|
criteria.andModuleIdEqualTo(request.getModuleId());
|
||||||
}
|
}
|
||||||
criteria.andNameEqualTo(request.getName());
|
criteria.andNameEqualTo(request.getName());
|
||||||
|
if (apiDefinitionMapper.countByExample(example) > 0 && StringUtils.isBlank(request.getId())) {
|
||||||
|
MSException.throwException(Translator.get("api_versions_create"));
|
||||||
|
}
|
||||||
|
criteria.andVersionIdEqualTo(request.getVersionId());
|
||||||
if (apiDefinitionMapper.countByExample(example) > 0) {
|
if (apiDefinitionMapper.countByExample(example) > 0) {
|
||||||
MSException.throwException(Translator.get("api_definition_name_not_repeating") + " :" + Translator.get("api_definition_module") + ":" + request.getModulePath() + " ," + Translator.get("api_definition_name") + " :" + request.getName() + "-" + request.getPath());
|
MSException.throwException(Translator.get("api_definition_name_not_repeating") + " :" + Translator.get("api_definition_module") + ":" + request.getModulePath() + " ," + Translator.get("api_definition_name") + " :" + request.getName() + "-" + request.getPath());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (apiDefinitionMapper.countByExample(example) > 0 && StringUtils.isBlank(request.getId())) {
|
||||||
|
MSException.throwException(Translator.get("api_versions_create"));
|
||||||
|
}
|
||||||
|
criteria.andVersionIdEqualTo(request.getVersionId());
|
||||||
if (apiDefinitionMapper.countByExample(example) > 0) {
|
if (apiDefinitionMapper.countByExample(example) > 0) {
|
||||||
MSException.throwException(Translator.get("api_definition_url_not_repeating") + " :" + Translator.get("api_definition_module") + ":" + request.getModulePath() + " ," + Translator.get("api_definition_name") + " :" + request.getName());
|
MSException.throwException(Translator.get("api_definition_url_not_repeating") + " :" + Translator.get("api_definition_module") + ":" + request.getModulePath() + " ," + Translator.get("api_definition_name") + " :" + request.getName());
|
||||||
}
|
}
|
||||||
|
@ -646,16 +653,38 @@ public class ApiDefinitionService {
|
||||||
} else {
|
} else {
|
||||||
criteria.andProtocolEqualTo(request.getProtocol()).andStatusNotEqualTo("Trash")
|
criteria.andProtocolEqualTo(request.getProtocol()).andStatusNotEqualTo("Trash")
|
||||||
.andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId())
|
.andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId())
|
||||||
.andIdNotEqualTo(request.getId()).andVersionIdEqualTo(request.getVersionId());
|
.andIdNotEqualTo(request.getId());
|
||||||
if (moduleIdNotExist) {
|
if (moduleIdNotExist) {
|
||||||
criteria.andModulePathEqualTo(request.getModulePath());
|
criteria.andModulePathEqualTo(request.getModulePath());
|
||||||
} else {
|
} else {
|
||||||
criteria.andModuleIdEqualTo(request.getModuleId());
|
criteria.andModuleIdEqualTo(request.getModuleId());
|
||||||
}
|
}
|
||||||
|
if (apiDefinitionMapper.countByExample(example) > 0 && StringUtils.isBlank(request.getId())) {
|
||||||
|
MSException.throwException(Translator.get("api_versions_create"));
|
||||||
|
}
|
||||||
|
criteria.andVersionIdEqualTo(request.getVersionId());
|
||||||
if (apiDefinitionMapper.countByExample(example) > 0) {
|
if (apiDefinitionMapper.countByExample(example) > 0) {
|
||||||
MSException.throwException(Translator.get("api_definition_name_already_exists") + " :" + Translator.get("api_definition_module") + ":" + request.getModulePath() + " ," + Translator.get("api_definition_name") + " :" + request.getName());
|
MSException.throwException(Translator.get("api_definition_name_already_exists") + " :" + Translator.get("api_definition_module") + ":" + request.getModulePath() + " ," + Translator.get("api_definition_name") + " :" + request.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isNotBlank(request.getId())) {
|
||||||
|
ApiDefinitionWithBLOBs result = apiDefinitionMapper.selectByPrimaryKey(request.getId());
|
||||||
|
if (result != null) {
|
||||||
|
example = new ApiDefinitionExample();
|
||||||
|
example.createCriteria().andRefIdEqualTo(result.getRefId()).andStatusNotEqualTo("Trash");
|
||||||
|
List<ApiDefinition> apiDefinitions = apiDefinitionMapper.selectByExample(example);
|
||||||
|
if (apiDefinitions != null && apiDefinitions.size() > 1) {
|
||||||
|
if (request.getProtocol().equals(RequestType.HTTP) && (!StringUtils.equals(result.getMethod(), request.getMethod()) || !StringUtils.equals(result.getPath(), request.getPath()))) {
|
||||||
|
MSException.throwException(Translator.get("api_versions_update_http"));
|
||||||
|
} else {
|
||||||
|
if (!StringUtils.equals(result.getName(), request.getName())) {
|
||||||
|
MSException.throwException(Translator.get("api_versions_update"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiDefinitionWithBLOBs updateTest(SaveApiDefinitionRequest request) {
|
private ApiDefinitionWithBLOBs updateTest(SaveApiDefinitionRequest request) {
|
||||||
|
|
|
@ -90,6 +90,9 @@ illegal_xml_format=illegal XML format
|
||||||
api_report_is_null="Report is null, can't update"
|
api_report_is_null="Report is null, can't update"
|
||||||
api_test_environment_already_exists="Api test environment already exists"
|
api_test_environment_already_exists="Api test environment already exists"
|
||||||
api_test=API Test
|
api_test=API Test
|
||||||
|
api_versions_update_http=There are multiple versions of this interface. It is not allowed to modify the request type or path. Please create a new interface
|
||||||
|
api_versions_update=There are multiple versions of this interface, name modification is not allowed, please create a new interface
|
||||||
|
api_versions_create=The interface already exists, please create a new version at version
|
||||||
#test case
|
#test case
|
||||||
test_case_node_level=level
|
test_case_node_level=level
|
||||||
test_case_node_level_tip=The node tree maximum depth is
|
test_case_node_level_tip=The node tree maximum depth is
|
||||||
|
@ -247,6 +250,8 @@ not_execute=Not execute
|
||||||
execute_not_pass=Not pass
|
execute_not_pass=Not pass
|
||||||
execute_pass=Pass
|
execute_pass=Pass
|
||||||
import_fail_custom_num_exists=import fail, custom num is exists
|
import_fail_custom_num_exists=import fail, custom num is exists
|
||||||
|
automation_versions_update=There are multiple versions of this scene, name modification is not allowed, please create a new scene
|
||||||
|
automation_versions_create=The scene already exists, please create a new version at version
|
||||||
#authsource
|
#authsource
|
||||||
authsource_name_already_exists=Authentication source name already exists
|
authsource_name_already_exists=Authentication source name already exists
|
||||||
authsource_name_is_null=Authentication source name cannot be empty
|
authsource_name_is_null=Authentication source name cannot be empty
|
||||||
|
|
|
@ -90,6 +90,9 @@ illegal_xml_format=不合法的 XML 格式
|
||||||
api_report_is_null="测试报告是未生成,无法更新"
|
api_report_is_null="测试报告是未生成,无法更新"
|
||||||
api_test_environment_already_exists="已存在该名称的环境配置"
|
api_test_environment_already_exists="已存在该名称的环境配置"
|
||||||
api_test=接口测试
|
api_test=接口测试
|
||||||
|
api_versions_update_http=该接口存在多版本,不允许修改请求类型或路径,请新建接口
|
||||||
|
api_versions_update=该接口存在多版本,不允许修改名称,请新建接口
|
||||||
|
api_versions_create=该接口已存在,请在版本处创建新版本
|
||||||
#test case
|
#test case
|
||||||
test_case_node_level=层
|
test_case_node_level=层
|
||||||
test_case_node_level_tip=模块树最大深度为
|
test_case_node_level_tip=模块树最大深度为
|
||||||
|
@ -247,6 +250,8 @@ not_execute=未执行
|
||||||
execute_not_pass=未通过
|
execute_not_pass=未通过
|
||||||
execute_pass=通过
|
execute_pass=通过
|
||||||
import_fail_custom_num_exists=导入失败,自定义ID已存在
|
import_fail_custom_num_exists=导入失败,自定义ID已存在
|
||||||
|
automation_versions_update=该场景存在多版本,不允许修改名称,请新建接口
|
||||||
|
automation_versions_create=该场景已存在,请在版本处创建新版本
|
||||||
#authsource
|
#authsource
|
||||||
authsource_name_already_exists=认证源名称已经存在
|
authsource_name_already_exists=认证源名称已经存在
|
||||||
authsource_name_is_null=认证源名称不能为空
|
authsource_name_is_null=认证源名称不能为空
|
||||||
|
|
|
@ -90,6 +90,9 @@ illegal_xml_format=不合法的 XML 格式
|
||||||
api_report_is_null="測試報告是未生成,無法更新"
|
api_report_is_null="測試報告是未生成,無法更新"
|
||||||
api_test_environment_already_exists="已存在該名稱的環境配置"
|
api_test_environment_already_exists="已存在該名稱的環境配置"
|
||||||
api_test=接口測試
|
api_test=接口測試
|
||||||
|
api_versions_update_http=該接口存在多版本,不允許修改請求類型或路徑,請新建接口
|
||||||
|
api_versions_update=該接口存在多版本,不允許修改名稱,請新建接口
|
||||||
|
api_versions_create=該接口已存在,請在版本處創建新版本
|
||||||
#test case
|
#test case
|
||||||
test_case_node_level=層
|
test_case_node_level=層
|
||||||
test_case_node_level_tip=模塊樹最大深度為
|
test_case_node_level_tip=模塊樹最大深度為
|
||||||
|
@ -246,6 +249,8 @@ not_execute=未執行
|
||||||
execute_not_pass=未通過
|
execute_not_pass=未通過
|
||||||
execute_pass=通過
|
execute_pass=通過
|
||||||
import_fail_custom_num_exists=導入失敗,自定義ID已存在
|
import_fail_custom_num_exists=導入失敗,自定義ID已存在
|
||||||
|
automation_versions_update=該場景存在多版本,不允許修改名稱,請新建場景
|
||||||
|
automation_versions_create=該場景已存在,請在版本處創建新版本
|
||||||
#authsource
|
#authsource
|
||||||
authsource_name_already_exists=認證源名稱已經存在
|
authsource_name_already_exists=認證源名稱已經存在
|
||||||
authsource_name_is_null=認證源名稱不能為空
|
authsource_name_is_null=認證源名稱不能為空
|
||||||
|
|
Loading…
Reference in New Issue