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);