From cb5ba5992b4f7e595103666efc0bdb268a30fb28 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Thu, 14 Mar 2024 09:32:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=94=A8=E4=BE=8B=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E4=BE=8B=E7=AE=A1=E7=90=86=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E8=BF=94=E5=9B=9E=E7=9A=84=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=AD=E6=9C=89=E9=87=8D=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1037064 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001037064 --- .../service/FunctionalCaseCommentService.java | 2 +- .../FunctionalCaseCommentControllerTests.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) 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);