diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCommentService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCommentService.java index bbea5bf6df..11a3cb3e7f 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCommentService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCommentService.java @@ -268,7 +268,7 @@ public class FunctionalCaseCommentService { List notifiers = Arrays.asList(functionalCaseComment.getNotifier().split(";")); notifiers.forEach(t-> commentUserInfos.add(userMap.get(t))); } - functionalCaseCommentDTO.setCommentUserInfos(commentUserInfos); + functionalCaseCommentDTO.setCommentUserInfos(commentUserInfos.stream().distinct().toList()); list.add(functionalCaseCommentDTO); } diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java index d5d1549340..35fe9324f1 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java @@ -373,14 +373,14 @@ public class FunctionalCaseCommentControllerTests { FunctionalCaseComment functionalCaseComment1 = getFunctionalCaseComment(); FunctionalCaseCommentRequest functionalCaseCommentRequest = new FunctionalCaseCommentRequest(); functionalCaseCommentRequest.setCaseId("xiaomeinvGTest"); - functionalCaseCommentRequest.setNotifier("default-project-member-user-guo;default-project-member-user-guo-4;"); + functionalCaseCommentRequest.setNotifier("default-project-member-user-guo;default-project-member-user-guo;default-project-member-user-guo-4;"); functionalCaseCommentRequest.setContent("评论你好哇"); functionalCaseCommentRequest.setEvent(NoticeConstants.Event.AT); functionalCaseCommentRequest.setReplyUser("default-project-member-user-guo"); functionalCaseCommentRequest.setParentId(functionalCaseComment1.getId()); FunctionalCaseComment functionalCaseComment = getFunctionalCaseComment(functionalCaseCommentRequest,SAVE_URL); Assertions.assertTrue(StringUtils.equals(functionalCaseComment.getCaseId(), "xiaomeinvGTest")); - Assertions.assertTrue(StringUtils.equals(functionalCaseComment.getNotifier(), "default-project-member-user-guo;default-project-member-user-guo-4;")); + Assertions.assertTrue(StringUtils.equals(functionalCaseComment.getNotifier(), "default-project-member-user-guo;default-project-member-user-guo;default-project-member-user-guo-4;")); Assertions.assertTrue(StringUtils.equals(functionalCaseComment.getContent(), "评论你好哇")); Assertions.assertTrue(StringUtils.isBlank(functionalCaseComment.getReplyUser())); @@ -399,6 +399,12 @@ public class FunctionalCaseCommentControllerTests { ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); List list = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), FunctionalCaseCommentDTO.class); Assertions.assertTrue(CollectionUtils.isNotEmpty(list)); + for (FunctionalCaseCommentDTO functionalCaseCommentDTO : list) { + if (StringUtils.equals("default-project-member-user-guo;default-project-member-user-guo;default-project-member-user-guo-4;", functionalCaseCommentDTO.getNotifier())) { + Assertions.assertEquals(2, functionalCaseCommentDTO.getCommentUserInfos().size()); + break; + } + } mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(GET_URL + "xiaomeinvGTestTwo").header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.CSRF_TOKEN, csrfToken) .header(SessionConstants.CURRENT_PROJECT, projectId) @@ -427,9 +433,8 @@ public class FunctionalCaseCommentControllerTests { @Order(19) public void deleteCommentSuccess() throws Exception { FunctionalCaseCommentExample functionalCaseCommentExample = new FunctionalCaseCommentExample(); - functionalCaseCommentExample.createCriteria().andCaseIdEqualTo("xiaomeinvGTest").andNotifierEqualTo("default-project-member-user-guo;default-project-member-user-guo-4;"); + functionalCaseCommentExample.createCriteria().andCaseIdEqualTo("xiaomeinvGTest").andNotifierEqualTo("default-project-member-user-guo;default-project-member-user-guo;default-project-member-user-guo-4;"); List functionalCaseComments = functionalCaseCommentMapper.selectByExample(functionalCaseCommentExample); - System.out.println(JSON.toJSONString(functionalCaseComments)); String id = functionalCaseComments.get(0).getId(); Assertions.assertFalse(functionalCaseComments.isEmpty()); delFunctionalCaseComment(id);