From d9fd9b11aa3777f11b1259a7e2499c5cb9319010 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 17 Oct 2023 10:07:16 +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=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NoticeTemplateControllerTests.java | 27 +++++++++---------- .../controller/MessageTemplateUtilsTests.java | 3 ++- 2 files changed, 15 insertions(+), 15 deletions(-) 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 7425151ebc..cd6f57cd13 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 @@ -35,15 +35,7 @@ public class NoticeTemplateControllerTests extends BaseTest { @Sql(scripts = {"/dml/init_project_template.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED)) public void getTemplateFieldsSuccess() throws Exception { List typeList = new ArrayList<>(); - typeList.add(NoticeConstants.TaskType.API_DEFINITION_TASK); - typeList.add(NoticeConstants.TaskType.API_SCENARIO_TASK); - typeList.add(NoticeConstants.TaskType.TEST_PLAN_TASK); - typeList.add(NoticeConstants.TaskType.CASE_REVIEW_TASK); - typeList.add(NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK); - typeList.add(NoticeConstants.TaskType.BUG_TASK); - typeList.add(NoticeConstants.TaskType.UI_SCENARIO_TASK); - typeList.add(NoticeConstants.TaskType.LOAD_TEST_TASK); - + getTypeList(typeList); for (String s : typeList) { MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/template/get/fields/project-template-test-1") .header(SessionConstants.HEADER_TOKEN, sessionId) @@ -55,17 +47,15 @@ public class NoticeTemplateControllerTests extends BaseTest { ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); MessageTemplateResultDTO messageTemplateResultDTO = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), MessageTemplateResultDTO.class); List projectList = messageTemplateResultDTO.getFieldList(); - if (s.equals(NoticeConstants.TaskType.SCHEDULE_TASK)) { + if (s.equals(NoticeConstants.TaskType.LOAD_REPORT_TASK)) { Assertions.assertTrue(CollectionUtils.isEmpty(projectList)); } else { Assertions.assertTrue(CollectionUtils.isNotEmpty(projectList)); } } } - @Test - @Order(2) - public void getTemplateFieldsEmptySuccess() throws Exception { - List typeList = new ArrayList<>(); + + private static void getTypeList(List typeList) { typeList.add(NoticeConstants.TaskType.API_DEFINITION_TASK); typeList.add(NoticeConstants.TaskType.API_SCENARIO_TASK); typeList.add(NoticeConstants.TaskType.TEST_PLAN_TASK); @@ -74,6 +64,15 @@ public class NoticeTemplateControllerTests extends BaseTest { typeList.add(NoticeConstants.TaskType.BUG_TASK); typeList.add(NoticeConstants.TaskType.UI_SCENARIO_TASK); typeList.add(NoticeConstants.TaskType.LOAD_TEST_TASK); + typeList.add(NoticeConstants.TaskType.JENKINS_TASK); + typeList.add(NoticeConstants.TaskType.SCHEDULE_TASK); + } + + @Test + @Order(2) + public void getTemplateFieldsEmptySuccess() throws Exception { + List typeList = new ArrayList<>(); + getTypeList(typeList); for (String s : typeList) { MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/template/get/fields/project-template-test-2" ) .header(SessionConstants.HEADER_TOKEN, sessionId) diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/MessageTemplateUtilsTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/MessageTemplateUtilsTests.java index ff5e0b74e4..f0d5a0e6ff 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/MessageTemplateUtilsTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/MessageTemplateUtilsTests.java @@ -32,7 +32,8 @@ public class MessageTemplateUtilsTests { Assertions.assertTrue(CollectionUtils.isNotEmpty(defaultRelatedUser)); Map defaultRelatedUserMap = MessageTemplateUtils.getDefaultRelatedUserMap(); Assertions.assertTrue(MapUtils.isNotEmpty(defaultRelatedUserMap)); - + Map fieldSourceMap = MessageTemplateUtils.getFieldSourceMap(); + Assertions.assertTrue(MapUtils.isNotEmpty(fieldSourceMap)); for (String type : typeList) { Field[] domainTemplateFields = MessageTemplateUtils.getDomainTemplateFields(type); Assertions.assertNotNull(domainTemplateFields);