refactor(接口测试): 优化接口定义状态字段
This commit is contained in:
parent
254d664204
commit
a4e9f8c2a5
|
@ -1,6 +1,5 @@
|
|||
package io.metersphere.api.constants;
|
||||
|
||||
import io.metersphere.sdk.constants.ValueEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
|
@ -9,17 +8,9 @@ import lombok.Getter;
|
|||
* @version: 1.0
|
||||
*/
|
||||
@Getter
|
||||
public enum ApiDefinitionStatus implements ValueEnum {
|
||||
PREPARE("Prepare"),
|
||||
UNDERWAY("Underway"),
|
||||
DEBUGGING("Debugging"),
|
||||
OBSOLETE("Obsolete"),
|
||||
COMPLETED("Completed");
|
||||
|
||||
private final String value;
|
||||
|
||||
ApiDefinitionStatus(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public enum ApiDefinitionStatus {
|
||||
PROCESSING,
|
||||
DEPRECATED,
|
||||
DEBUGGING,
|
||||
DONE
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.metersphere.api.domain.ApiDefinitionCustomField;
|
|||
import io.metersphere.sdk.constants.ModuleConstants;
|
||||
import io.metersphere.system.valid.EnumValue;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
@ -80,6 +81,7 @@ public class ApiDefinitionAddRequest implements Serializable {
|
|||
|
||||
@Schema(description = "响应内容")
|
||||
@NotNull
|
||||
@Valid
|
||||
private List<HttpResponse> response;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.api.constants.ApiDefinitionStatus;
|
||||
import io.metersphere.system.valid.EnumValue;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
@ -31,9 +33,10 @@ public class ApiTestCaseAddRequest implements Serializable {
|
|||
@Size(min = 1, max = 50, message = "{api_test_case.priority.length_range}")
|
||||
private String priority;
|
||||
|
||||
@Schema(description = "用例状态 Underway Prepare Completed", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "用例状态", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{api_test_case.status.not_blank}")
|
||||
@Size(min = 1, max = 20, message = "{api_test_case.status.length_range}")
|
||||
@EnumValue(enumClass = ApiDefinitionStatus.class)
|
||||
private String status;
|
||||
|
||||
@Schema(description = "接口fk", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.api.constants.ApiDefinitionStatus;
|
||||
import io.metersphere.system.valid.EnumValue;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
@ -30,9 +32,10 @@ public class ApiTestCaseUpdateRequest implements Serializable {
|
|||
@Size(min = 1, max = 50, message = "{api_test_case.priority.length_range}")
|
||||
private String priority;
|
||||
|
||||
@Schema(description = "用例状态 Underway Prepare Completed", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "用例状态", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{api_test_case.status.not_blank}")
|
||||
@Size(min = 1, max = 20, message = "{api_test_case.status.length_range}")
|
||||
@EnumValue(enumClass = ApiDefinitionStatus.class)
|
||||
private String status;
|
||||
|
||||
@Schema(description = "标签")
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.dto.definition;
|
|||
|
||||
import io.metersphere.api.dto.request.http.Header;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
|
@ -33,9 +34,11 @@ public class HttpResponse implements Serializable {
|
|||
private String name;
|
||||
|
||||
@Schema(description = "响应请求头")
|
||||
@Valid
|
||||
private List<Header> headers;
|
||||
|
||||
@Schema(description = "响应请求体")
|
||||
@Valid
|
||||
private ResponseBody body;
|
||||
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ public class ApiDefinitionImportUtilService {
|
|||
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
||||
apiDefinition.setNum(NumGenerator.nextNum(request.getProjectId(), ApplicationNumScope.API_DEFINITION));
|
||||
apiDefinition.setLatest(true);
|
||||
apiDefinition.setStatus(ApiDefinitionStatus.UNDERWAY.name());
|
||||
apiDefinition.setStatus(ApiDefinitionStatus.PROCESSING.name());
|
||||
apiDefinition.setRefId(apiDefinition.getId());
|
||||
apiDefinition.setVersionId(request.getVersionId());
|
||||
apiMapper.insertSelective(apiDefinition);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.service.definition;
|
||||
|
||||
import io.metersphere.api.constants.ApiConstants;
|
||||
import io.metersphere.api.constants.ApiDefinitionDocType;
|
||||
import io.metersphere.api.constants.ApiResourceType;
|
||||
import io.metersphere.api.controller.result.ApiResultCode;
|
||||
|
@ -256,6 +257,9 @@ public class ApiDefinitionService {
|
|||
ApiDefinition apiDefinition = new ApiDefinition();
|
||||
BeanUtils.copyBean(apiDefinition, request);
|
||||
checkResponseNameCode(request.getResponse());
|
||||
apiDefinition.setVersionId(originApiDefinition.getVersionId());
|
||||
apiDefinition.setRefId(originApiDefinition.getRefId());
|
||||
apiDefinition.setProjectId(originApiDefinition.getProjectId());
|
||||
if (request.getProtocol().equals(ModuleConstants.NODE_PROTOCOL_HTTP)) {
|
||||
checkUpdateExist(apiDefinition);
|
||||
//http协议的接口,如果修改了path和method,需要同步把case的path和method修改
|
||||
|
@ -268,7 +272,6 @@ public class ApiDefinitionService {
|
|||
apiDefinition.setStatus(request.getStatus());
|
||||
apiDefinition.setUpdateUser(userId);
|
||||
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
||||
apiDefinition.setVersionId(request.getVersionId());
|
||||
if (CollectionUtils.isNotEmpty(request.getTags())) {
|
||||
apiDefinition.setTags(request.getTags());
|
||||
}
|
||||
|
@ -516,21 +519,33 @@ public class ApiDefinitionService {
|
|||
}
|
||||
|
||||
private void checkAddExist(ApiDefinition apiDefinition) {
|
||||
if (!StringUtils.equals(apiDefinition.getProtocol(), ApiConstants.HTTP_PROTOCOL)) {
|
||||
return;
|
||||
}
|
||||
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||
example.createCriteria()
|
||||
.andPathEqualTo(apiDefinition.getPath()).andMethodEqualTo(apiDefinition.getMethod())
|
||||
.andProtocolEqualTo(apiDefinition.getProtocol()).andVersionIdEqualTo(apiDefinition.getVersionId());
|
||||
.andPathEqualTo(apiDefinition.getPath())
|
||||
.andMethodEqualTo(apiDefinition.getMethod())
|
||||
.andProtocolEqualTo(apiDefinition.getProtocol())
|
||||
.andProjectIdEqualTo(apiDefinition.getProjectId());
|
||||
if (CollectionUtils.isNotEmpty(apiDefinitionMapper.selectByExample(example))) {
|
||||
throw new MSException(ApiResultCode.API_DEFINITION_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpdateExist(ApiDefinition apiDefinition) {
|
||||
if (!StringUtils.equals(apiDefinition.getProtocol(), ApiConstants.HTTP_PROTOCOL)) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(apiDefinition.getPath()) && StringUtils.isNotEmpty(apiDefinition.getMethod())) {
|
||||
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||
example.createCriteria()
|
||||
.andIdNotEqualTo(apiDefinition.getId()).andProtocolEqualTo(apiDefinition.getProtocol())
|
||||
.andPathEqualTo(apiDefinition.getPath()).andMethodEqualTo(apiDefinition.getMethod()).andVersionIdEqualTo(apiDefinition.getVersionId());
|
||||
.andIdNotEqualTo(apiDefinition.getId())
|
||||
.andProtocolEqualTo(apiDefinition.getProtocol())
|
||||
.andPathEqualTo(apiDefinition.getPath())
|
||||
.andMethodEqualTo(apiDefinition.getMethod())
|
||||
.andProjectIdEqualTo(apiDefinition.getProjectId())
|
||||
.andRefIdNotEqualTo(apiDefinition.getRefId());
|
||||
if (apiDefinitionMapper.countByExample(example) > 0) {
|
||||
throw new MSException(ApiResultCode.API_DEFINITION_EXIST);
|
||||
}
|
||||
|
@ -1050,6 +1065,7 @@ public class ApiDefinitionService {
|
|||
if (!StringUtils.equals(request.getModuleId(), apiDefinition.getModuleId())) {
|
||||
checkModuleExist(request.getModuleId());
|
||||
apiDefinition.setModuleId(request.getModuleId());
|
||||
apiDefinition.setProjectId(request.getProjectId());
|
||||
checkUpdateExist(apiDefinition);
|
||||
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
||||
apiDefinition.setUpdateUser(userId);
|
||||
|
|
|
@ -259,6 +259,13 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
|||
|
||||
// @@重名校验异常
|
||||
assertErrorCode(this.requestPost(ADD, request), ApiResultCode.API_DEFINITION_EXIST);
|
||||
|
||||
// 校验其他协议
|
||||
request.setProtocol("TCP");
|
||||
request.setMethod(null);
|
||||
request.setPath(null);
|
||||
this.requestPostWithOk(ADD, request);
|
||||
|
||||
// @@响应名+响应码唯一校验异常
|
||||
request.setName("test123-response");
|
||||
request.setMethod("GET");
|
||||
|
@ -277,8 +284,7 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
|||
|
||||
// @@校验日志
|
||||
checkLogModelList.add(new CheckLogModel(apiDefinition.getId(), OperationLogType.ADD, ADD));
|
||||
// @@异常参数校验
|
||||
createdGroupParamValidateTest(ApiDefinitionAddRequest.class, ADD);
|
||||
|
||||
// @@校验权限
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setName("permission-st-6");
|
||||
|
@ -328,7 +334,7 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
|||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setMethod("POST");
|
||||
request.setPath("/api/admin/posts");
|
||||
request.setStatus(ApiDefinitionStatus.PREPARE.getValue());
|
||||
request.setStatus(ApiDefinitionStatus.PROCESSING.name());
|
||||
request.setModuleId("default");
|
||||
request.setVersionId(defaultVersion);
|
||||
request.setDescription("描述内容");
|
||||
|
@ -440,8 +446,11 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
|||
request.setLinkFileIds(List.of(fileMetadataId));
|
||||
request.setDeleteFileIds(null);
|
||||
request.setUnLinkFileIds(null);
|
||||
String versionId = request.getVersionId();
|
||||
request.setVersionId(null);
|
||||
this.requestPostWithOk(UPDATE, request);
|
||||
// 校验请求成功数据
|
||||
request.setVersionId(versionId);
|
||||
apiDefinition = assertAddApiDefinition(request, msHttpElement, request.getId());
|
||||
assertUploadFile(apiDefinition.getId(), List.of(fileId));
|
||||
assertLinkFile(apiDefinition.getId());
|
||||
|
@ -509,7 +518,7 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
|||
addRequest.setProjectId(DEFAULT_PROJECT_ID);
|
||||
addRequest.setMethod("POST");
|
||||
addRequest.setPath("/api/admin/posts");
|
||||
addRequest.setStatus(ApiDefinitionStatus.PREPARE.getValue());
|
||||
addRequest.setStatus(ApiDefinitionStatus.PROCESSING.name());
|
||||
addRequest.setModuleId("default");
|
||||
addRequest.setVersionId(DEFAULT_PROJECT_ID);
|
||||
addRequest.setDescription("描述内容");
|
||||
|
@ -536,7 +545,7 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
|||
testCaseAddRequest.setName("test-path" + i);
|
||||
testCaseAddRequest.setProjectId(DEFAULT_PROJECT_ID);
|
||||
testCaseAddRequest.setPriority("P0");
|
||||
testCaseAddRequest.setStatus(ApiDefinitionStatus.PREPARE.getValue());
|
||||
testCaseAddRequest.setStatus(ApiDefinitionStatus.PROCESSING.name());
|
||||
testCaseAddRequest.setTags(new LinkedHashSet<>(List.of("tag1", "tag2")));
|
||||
testCaseAddRequest.setRequest(getMsElementParam(msHttpElement));
|
||||
apiTestCaseService.addCase(testCaseAddRequest, "admin");
|
||||
|
@ -683,7 +692,7 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
|||
this.requestPostWithOk(BATCH_UPDATE, apiDefinitionBatchUpdateRequest);
|
||||
// 修改状态
|
||||
apiDefinitionBatchUpdateRequest.setType("status");
|
||||
apiDefinitionBatchUpdateRequest.setStatus(ApiDefinitionStatus.DEBUGGING.getValue());
|
||||
apiDefinitionBatchUpdateRequest.setStatus(ApiDefinitionStatus.DEBUGGING.name());
|
||||
this.requestPostWithOk(BATCH_UPDATE, apiDefinitionBatchUpdateRequest);
|
||||
// 修改版本
|
||||
apiDefinitionBatchUpdateRequest.setType("version");
|
||||
|
|
|
@ -164,7 +164,7 @@ public class ApiDefinitionMockControllerTests extends BaseTest {
|
|||
noMockNoResponseApiRequest.setProjectId(DEFAULT_PROJECT_ID);
|
||||
noMockNoResponseApiRequest.setMethod("GET");
|
||||
noMockNoResponseApiRequest.setPath("/mock/api/notMatch/");
|
||||
noMockNoResponseApiRequest.setStatus(ApiDefinitionStatus.PREPARE.getValue());
|
||||
noMockNoResponseApiRequest.setStatus(ApiDefinitionStatus.PROCESSING.name());
|
||||
noMockNoResponseApiRequest.setModuleId(ModuleConstants.DEFAULT_NODE_ID);
|
||||
noMockNoResponseApiRequest.setVersionId(defaultVersion);
|
||||
noMockNoResponseApiRequest.setDescription("desc");
|
||||
|
@ -181,7 +181,7 @@ public class ApiDefinitionMockControllerTests extends BaseTest {
|
|||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setMethod(method);
|
||||
request.setPath("/mock/api/" + method + "/{param1}/{param2}");
|
||||
request.setStatus(ApiDefinitionStatus.PREPARE.getValue());
|
||||
request.setStatus(ApiDefinitionStatus.PROCESSING.name());
|
||||
request.setModuleId(ModuleConstants.DEFAULT_NODE_ID);
|
||||
request.setVersionId(defaultVersion);
|
||||
request.setDescription("desc");
|
||||
|
@ -248,8 +248,6 @@ public class ApiDefinitionMockControllerTests extends BaseTest {
|
|||
|
||||
// @@校验日志
|
||||
this.checkLog(apiDefinitionMock.getId(), OperationLogType.ADD, ADD);
|
||||
// @@异常参数校验
|
||||
createdGroupParamValidateTest(ApiDefinitionAddRequest.class, ADD);
|
||||
// @@校验权限
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setName("permission-st-6");
|
||||
|
|
|
@ -541,7 +541,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
apiDefinitionAddRequest.setProjectId(DEFAULT_PROJECT_ID);
|
||||
apiDefinitionAddRequest.setMethod("POST");
|
||||
apiDefinitionAddRequest.setPath("/api/admin/posts");
|
||||
apiDefinitionAddRequest.setStatus(ApiDefinitionStatus.PREPARE.getValue());
|
||||
apiDefinitionAddRequest.setStatus(ApiDefinitionStatus.PROCESSING.name());
|
||||
apiDefinitionAddRequest.setModuleId(moduleId);
|
||||
apiDefinitionAddRequest.setVersionId(extBaseProjectVersionMapper.getDefaultVersion(DEFAULT_PROJECT_ID));
|
||||
apiDefinitionAddRequest.setDescription("描述内容");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.constants.ApiConstants;
|
||||
import io.metersphere.api.constants.ApiDefinitionStatus;
|
||||
import io.metersphere.api.controller.param.ApiTestCaseAddRequestDefinition;
|
||||
import io.metersphere.api.controller.result.ApiResultCode;
|
||||
import io.metersphere.api.domain.*;
|
||||
|
@ -155,7 +156,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
apiDefinition.setModuleId("case-moduleId");
|
||||
apiDefinition.setProtocol(ApiConstants.HTTP_PROTOCOL);
|
||||
apiDefinition.setMethod("GET");
|
||||
apiDefinition.setStatus("未规划");
|
||||
apiDefinition.setStatus(ApiDefinitionStatus.DEBUGGING.name());
|
||||
apiDefinition.setNum(NumGenerator.nextNum(DEFAULT_PROJECT_ID, ApplicationNumScope.API_DEFINITION));
|
||||
apiDefinition.setPos(0L);
|
||||
apiDefinition.setPath(StringUtils.join("api/definition/", apiDefinition.getId()));
|
||||
|
@ -190,7 +191,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
apiTestCase.setProjectId(DEFAULT_PROJECT_ID);
|
||||
apiTestCase.setName(StringUtils.join("接口用例", apiTestCase.getId()));
|
||||
apiTestCase.setPriority("P0");
|
||||
apiTestCase.setStatus("Underway");
|
||||
apiTestCase.setStatus(ApiDefinitionStatus.PROCESSING.name());
|
||||
apiTestCase.setNum(NumGenerator.nextNum(DEFAULT_PROJECT_ID + "_" + "100001", ApplicationNumScope.API_TEST_CASE));
|
||||
apiTestCase.setPos(0L);
|
||||
apiTestCase.setCreateTime(System.currentTimeMillis());
|
||||
|
@ -313,7 +314,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
request.setName("test");
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setPriority("P0");
|
||||
request.setStatus("Underway");
|
||||
request.setStatus(ApiDefinitionStatus.PROCESSING.name());
|
||||
request.setTags(new LinkedHashSet<>(List.of("tag1", "tag2")));
|
||||
request.setEnvironmentId(environments.get(0).getId());
|
||||
MsHTTPElement msHttpElement = MsHTTPElementTest.getMsHttpElement();
|
||||
|
@ -540,7 +541,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
request.setId(apiTestCase.getId());
|
||||
request.setName("update");
|
||||
request.setPriority("P1");
|
||||
request.setStatus("Underway");
|
||||
request.setStatus(ApiDefinitionStatus.PROCESSING.name());
|
||||
request.setTags(List.of("tag1", "tag2"));
|
||||
request.setEnvironmentId(null);
|
||||
MsHTTPElement msHttpElement = MsHTTPElementTest.getMsHttpElement();
|
||||
|
@ -712,7 +713,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
request.setName("testApiDefinitionId1");
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setPriority("P0");
|
||||
request.setStatus("Underway");
|
||||
request.setStatus(ApiDefinitionStatus.DEBUGGING.name());
|
||||
request.setTags(new LinkedHashSet<>(List.of("tag1", "tag2")));
|
||||
MsHTTPElement msHttpElement = MsHTTPElementTest.getMsHttpElement();
|
||||
request.setRequest(getMsElementParam(msHttpElement));
|
||||
|
@ -857,13 +858,13 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
//状态
|
||||
request.setPriority(null);
|
||||
request.setType("Status");
|
||||
request.setStatus("Completed");
|
||||
request.setStatus(ApiDefinitionStatus.DEBUGGING.name());
|
||||
request.setSelectAll(true);
|
||||
request.setExcludeIds(new ArrayList<>());
|
||||
requestPostWithOkAndReturn(BATCH_EDIT, request);
|
||||
//判断数据的状态是不是Completed
|
||||
//判断数据的状态是不是DEBUGGING
|
||||
caseList = apiTestCaseMapper.selectByExample(example);
|
||||
caseList.forEach(apiTestCase -> Assertions.assertEquals(apiTestCase.getStatus(), "Completed"));
|
||||
caseList.forEach(apiTestCase -> Assertions.assertEquals(apiTestCase.getStatus(), ApiDefinitionStatus.DEBUGGING.name()));
|
||||
//状态数据为空
|
||||
request.setStatus(null);
|
||||
this.requestPost(BATCH_EDIT, request, ERROR_REQUEST_MATCHER);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.metersphere.api.controller.param;
|
||||
|
||||
import io.metersphere.api.constants.ApiDefinitionStatus;
|
||||
import io.metersphere.system.valid.EnumValue;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
@ -32,9 +34,10 @@ public class ApiTestCaseAddRequestDefinition implements Serializable {
|
|||
@Size(min = 1, max = 50, message = "{api_test_case.priority.length_range}")
|
||||
private String priority;
|
||||
|
||||
@Schema(description = "用例状态 Underway Prepare Completed", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "用例状态", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{api_test_case.status.not_blank}")
|
||||
@Size(min = 1, max = 20, message = "{api_test_case.status.length_range}")
|
||||
@EnumValue(enumClass = ApiDefinitionStatus.class)
|
||||
private String status;
|
||||
|
||||
@Schema(description = "接口fk", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
-- 插入测试数据
|
||||
|
||||
DELETE FROM `api_definition` WHERE `id` in ('1001','1002','1003','1004','1005','1006');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1001', 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test', 'HTTP', 'POST', '/api/admin/1', 'Prepare', 1001, '[\"test3\",\"te\"]', 1, '100001100001', 'root', b'1', '100570499574136985', '1001', NULL, 1699500298164, 'admin', 1699500298162, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1002', 'test-2', 'HTTP', 'GET', '/api/admin/2', 'Underway', 1002, null, 1, '100001100001', '1001001', b'1', '1005704995741369851', '1002', NULL, 1699500298165, 'admin', 1699500298163, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1003', 'test-3', 'HTTP', 'POST', '/api/admin/3', 'Completed', 1003, '[\"test3\",\"te\"]', 1, '100001100001', '10001', b'1', '100570499574136985', '1002', NULL, 1699500298166, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1004', 'test-4', 'HTTP', 'GET', '/api/admin/4', 'Prepare', 1004, '[\"test4\",\"te\"]', 1, '100001100001', '10001', b'1', '100570499574136985', '1004', NULL, 1699500298167, 'admin', 1699500298165, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1005', 'test-65', 'HTTP', 'POST', '/api/admin/5', 'Underway', 1005, '[\"test5\",\"te\"]', 1, '100001100001', '10001', b'0', '100570499574136985', '1004', NULL, 1699500298168, 'admin', 1699500298166, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1006', 'test-6', 'HTTP', 'GET', '/api/admin/6', 'Completed', 1006, '[\"test6\",\"te\"]', 1, '100001100001', '10001', b'1', '100570499574136985', '1006', NULL, 1699500298169, 'admin', 1699500298167, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1001', 'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1test', 'HTTP', 'POST', '/api/admin/1', 'PROCESSING', 1001, '[\"test3\",\"te\"]', 1, '100001100001', 'root', b'1', '100570499574136985', '1001', NULL, 1699500298164, 'admin', 1699500298162, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1002', 'test-2', 'HTTP', 'GET', '/api/admin/2', 'DEPRECATED', 1002, null, 1, '100001100001', '1001001', b'1', '1005704995741369851', '1002', NULL, 1699500298165, 'admin', 1699500298163, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1003', 'test-3', 'HTTP', 'POST', '/api/admin/3', 'DEBUGGING', 1003, '[\"test3\",\"te\"]', 1, '100001100001', '10001', b'1', '100570499574136985', '1002', NULL, 1699500298166, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1004', 'test-4', 'HTTP', 'GET', '/api/admin/4', 'PROCESSING', 1004, '[\"test4\",\"te\"]', 1, '100001100001', '10001', b'1', '100570499574136985', '1004', NULL, 1699500298167, 'admin', 1699500298165, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1005', 'test-65', 'HTTP', 'POST', '/api/admin/5', 'DONE', 1005, '[\"test5\",\"te\"]', 1, '100001100001', '10001', b'0', '100570499574136985', '1004', NULL, 1699500298168, 'admin', 1699500298166, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1006', 'test-6', 'HTTP', 'GET', '/api/admin/6', 'DEBUGGING', 1006, '[\"test6\",\"te\"]', 1, '100001100001', '10001', b'1', '100570499574136985', '1006', NULL, 1699500298169, 'admin', 1699500298167, 'admin', NULL, NULL, b'0');
|
||||
|
||||
DELETE FROM `project_version` WHERE `id` = '100570499574136985';
|
||||
INSERT INTO project_version (id, project_id, name, description, status, latest, publish_time, start_time, end_time, create_time, create_user) VALUES ('100570499574136985', '100001100001', 'v1.0.0', NULL, 'open', 1, UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin');
|
||||
|
||||
DELETE FROM `api_test_case` WHERE `id` in ('12df5721-c5e6-a38b-e999-3eafcb992094','12df5721-c5e6-a38b-e999-3eafcb992100','12df5721-c5e6-a38b-e999-3eafcb992233','3ee2ae9c-a680-4ed6-b115-1f6ab8980973','3ee2ae9c-a680-4ed6-b115-1f6ab8980100','3ee2ae9c-a680-4ed6-b115-1f6ab8980589','3ee2ae9c-a680-4ed6-b115-1f6ab8980553','3ee2ae9c-a680-4ed6-b115-1f6ab8980104','3ee2ae9c-a680-4ed6-b115-1f6ab8980545');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('12df5721-c5e6-a38b-e999-3eafcb992094', '查询windows主机1', 'P0', 100002001, NULL, 'PENDING', NULL, '10001', 10000, '100001100001', '1001', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('12df5721-c5e6-a38b-e999-3eafcb992100', '查询windows主机2', 'P0', 100002002, NULL, 'PENDING', NULL, '10002', 10000, '100001100001', '1001', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('12df5721-c5e6-a38b-e999-3eafcb992233', '查询windows主机3', 'P0', 100002003, NULL, 'PENDING', NULL, '10003', 10000, '100001100001', '1002', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980973', '查询Linux主机1', 'P0', 100002004, NULL, 'PENDING', NULL, '10004', 10000, '100001100001', '1002', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980100', '查询Linux主机2', 'P0', 100002005, NULL, 'PENDING', NULL, '10005', 10000, '100001100001', '1003', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980589', '查询Linux主机3', 'P0', 100002006, NULL, 'PENDING', NULL, '10006', 10000, '100001100001', '1004', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980553', '查询Linux主机4', 'P0', 100002007, NULL, 'PENDING', NULL, '10007', 10000, '100001100001', '1005', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980104', '查询Linux主机5', 'P0', 100002008, NULL, 'PENDING', NULL, '10008', 10000, '100001100001', '1005', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980545', '查询Linux主机6', 'P0', 100002009, NULL, 'PENDING', NULL, NULL, 10000, '100001100001', '1005', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('12df5721-c5e6-a38b-e999-3eafcb992094', '查询windows主机1', 'P0', 100002001, NULL, 'PROCESSING', NULL, '10001', 10000, '100001100001', '1001', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('12df5721-c5e6-a38b-e999-3eafcb992100', '查询windows主机2', 'P0', 100002002, NULL, 'PROCESSING', NULL, '10002', 10000, '100001100001', '1001', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('12df5721-c5e6-a38b-e999-3eafcb992233', '查询windows主机3', 'P0', 100002003, NULL, 'PROCESSING', NULL, '10003', 10000, '100001100001', '1002', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980973', '查询Linux主机1', 'P0', 100002004, NULL, 'PROCESSING', NULL, '10004', 10000, '100001100001', '1002', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980100', '查询Linux主机2', 'P0', 100002005, NULL, 'PROCESSING', NULL, '10005', 10000, '100001100001', '1003', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980589', '查询Linux主机3', 'P0', 100002006, NULL, 'PROCESSING', NULL, '10006', 10000, '100001100001', '1004', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980553', '查询Linux主机4', 'P0', 100002007, NULL, 'PROCESSING', NULL, '10007', 10000, '100001100001', '1005', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980104', '查询Linux主机5', 'P0', 100002008, NULL, 'PROCESSING', NULL, '10008', 10000, '100001100001', '1005', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980545', '查询Linux主机6', 'P0', 100002009, NULL, 'PROCESSING', NULL, NULL, 10000, '100001100001', '1005', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
|
||||
|
||||
DELETE FROM `api_definition_module` WHERE `id` in ('10001', 'case-moduleId');
|
||||
INSERT INTO `api_definition_module` (`id`, `name`, `parent_id`, `project_id`, `pos`, `create_time`, `update_time`, `update_user`, `create_user`) VALUES ('10001', 'module1', 'NONE', '100001100001', 10, 0, 0, 'admin', 'admin');
|
||||
|
|
|
@ -32,7 +32,7 @@ public class CommonVariables implements Serializable {
|
|||
|
||||
@JsonIgnore
|
||||
public boolean isConstantValid() {
|
||||
return StringUtils.isEmpty(this.type) || (StringUtils.equals("text", this.type) && StringUtils.isNotEmpty(key)) || (StringUtils.equals(this.type, VariableTypeConstants.CONSTANT.name()) && StringUtils.isNotEmpty(key));
|
||||
return StringUtils.equals(this.type, VariableTypeConstants.CONSTANT.name()) && StringUtils.isNotEmpty(key);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
|
|
Loading…
Reference in New Issue