diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java index f19ce7def3..828912bb2f 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java @@ -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); } diff --git a/backend/services/system-setting/src/test/resources/dml/init_operation_log_test.sql b/backend/services/system-setting/src/test/resources/dml/init_operation_log_test.sql index a9f46b2df9..68f6988928 100644 --- a/backend/services/system-setting/src/test/resources/dml/init_operation_log_test.sql +++ b/backend/services/system-setting/src/test/resources/dml/init_operation_log_test.sql @@ -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); -- 初始化日志记录