From 1b8b75bd40d16edbc6903f94490e124decdddc09 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 15 Sep 2023 18:27:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B6=88=E6=81=AF=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E8=A1=A5=E5=85=85=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NoticeMessageTaskControllerTests.java | 4 ++-- .../controller/NoticeTemplateControllerTests.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeMessageTaskControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeMessageTaskControllerTests.java index b54678f86e..c9839a3d30 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeMessageTaskControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeMessageTaskControllerTests.java @@ -312,7 +312,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest { userIds.add("project-message-user-del"); messageTaskRequest.setReceiverIds(userIds); messageTaskRequest.setRobotId("test_message_robot2"); - messageTaskRequest.setEnable(true); + messageTaskRequest.setEnable(false); messageTaskRequest.setTemplate("发送消息测试"); MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save") .header(SessionConstants.HEADER_TOKEN, sessionId) @@ -338,7 +338,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest { userIds.add("FOLLOW_PEOPLE"); messageTaskRequest.setReceiverIds(userIds); messageTaskRequest.setRobotId("test_message_robot2"); - messageTaskRequest.setEnable(null); + messageTaskRequest.setEnable(false); messageTaskRequest.setTemplate("发送消息测试"); MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save") .header(SessionConstants.HEADER_TOKEN, sessionId) diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeTemplateControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeTemplateControllerTests.java index 428882b6eb..135495f97b 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeTemplateControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeTemplateControllerTests.java @@ -51,4 +51,17 @@ public class NoticeTemplateControllerTests extends BaseTest { Assertions.assertTrue(CollectionUtils.isNotEmpty(projectList)); } } + @Test + @Order(2) + public void getTemplateFieldsEmptySuccess() throws Exception { + MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/template/get/fields/default" ) + .header(SessionConstants.HEADER_TOKEN, sessionId) + .header(SessionConstants.CSRF_TOKEN, csrfToken)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn(); + String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); + ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); + List projectList = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), OptionDTO.class); + Assertions.assertTrue(CollectionUtils.isEmpty(projectList)); + } }