From b83498993176c61e49ac7a7b65e9113d74580354 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 20 Jul 2023 15:21:02 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E9=A1=B9=E7=9B=AE=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SystemProjectControllerTests.java | 14 ++++++++++---- .../test/resources/dml/init_operation_log_test.sql | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) 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); -- 初始化日志记录