refactor(消息管理): 补充测试用例

This commit is contained in:
guoyuqi 2023-09-15 18:27:54 +08:00 committed by 刘瑞斌
parent 22446027e0
commit 1b8b75bd40
2 changed files with 15 additions and 2 deletions

View File

@ -312,7 +312,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
userIds.add("project-message-user-del"); userIds.add("project-message-user-del");
messageTaskRequest.setReceiverIds(userIds); messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot2"); messageTaskRequest.setRobotId("test_message_robot2");
messageTaskRequest.setEnable(true); messageTaskRequest.setEnable(false);
messageTaskRequest.setTemplate("发送消息测试"); messageTaskRequest.setTemplate("发送消息测试");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save") MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.HEADER_TOKEN, sessionId)
@ -338,7 +338,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
userIds.add("FOLLOW_PEOPLE"); userIds.add("FOLLOW_PEOPLE");
messageTaskRequest.setReceiverIds(userIds); messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot2"); messageTaskRequest.setRobotId("test_message_robot2");
messageTaskRequest.setEnable(null); messageTaskRequest.setEnable(false);
messageTaskRequest.setTemplate("发送消息测试"); messageTaskRequest.setTemplate("发送消息测试");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save") MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.HEADER_TOKEN, sessionId)

View File

@ -51,4 +51,17 @@ public class NoticeTemplateControllerTests extends BaseTest {
Assertions.assertTrue(CollectionUtils.isNotEmpty(projectList)); 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<OptionDTO> projectList = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), OptionDTO.class);
Assertions.assertTrue(CollectionUtils.isEmpty(projectList));
}
} }