refactor(系统设置): 项目优化测试用例

This commit is contained in:
wxg0103 2023-07-20 15:21:02 +08:00 committed by Yuki Guo
parent ab85dc7cb9
commit b834989931
2 changed files with 12 additions and 6 deletions

View File

@ -192,8 +192,10 @@ public class SystemProjectControllerTests extends BaseTest {
* 测试添加项目失败的用例
*/
public void testAddProjectError() throws Exception {
AddProjectRequest project = this.generatorAdd("organizationId","nameError", "description", true, List.of("admin"));
this.responsePost(addProject, project);
//项目名称存在 500
AddProjectRequest project = this.generatorAdd("organizationId","name", "description", true, List.of("admin"));
project = this.generatorAdd("organizationId","nameError", "description", true, List.of("admin"));
this.requestPost(addProject, project, ERROR_REQUEST_MATCHER);
//参数组织Id为空
project = this.generatorAdd(null, null, null, true, List.of("admin"));
@ -212,9 +214,13 @@ public class SystemProjectControllerTests extends BaseTest {
@Test
@Order(3)
public void testGetProject() throws Exception {
MvcResult mvcResult = this.responseGet(getProject + projectId);
Project project = this.parseObjectFromMvcResult(mvcResult, Project.class);
Assertions.assertTrue(StringUtils.equals(project.getId(), projectId));
AddProjectRequest project = this.generatorAdd("organizationId","getName", "description", true, List.of("admin"));
MvcResult mvcResult = this.responsePost(addProject, project);
Project result = this.parseObjectFromMvcResult(mvcResult, Project.class);
projectId = result.getId();
mvcResult = this.responseGet(getProject + projectId);
Project getProjects = this.parseObjectFromMvcResult(mvcResult, Project.class);
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), projectId));
// @@校验权限
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getProject + projectId);
}

View File

@ -2,8 +2,8 @@
INSERT INTO organization (id, num, name, description, create_user, update_user, create_time, update_time) VALUES ('organization_id_001', 100010, '测试日志组织', '测试日志的组织', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
INSERT INTO organization (id, num, name, description, create_user, update_user, create_time, update_time) VALUES ('organization_id_002', 100011, '测试日志组织2', '测试日志的组织2', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES ('project_id_001', 100010, 'organization_id_001', '测试日志项目', '测试日志的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES ('project_id_002', 100011, 'organization_id_002', '测试日志项目2', '测试日志的项目2', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES ('project_id_001', null, 'organization_id_001', '测试日志项目', '测试日志的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES ('project_id_002', null, 'organization_id_002', '测试日志项目2', '测试日志的项目2', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
-- 初始化日志记录