Commit 92a993b2833aeb4e40b7666acba51e96cd75de8c
1 parent
bca66fee
test:优化 IM 单测注释风格
- 统一 IM 单测类注释为 {@link Xxx} 的单元测试
- 保留方法分组注释,收敛不符合规范的分组文案
- 删除少量冗余字段说明注释
Showing
18 changed files
with
36 additions
and
36 deletions
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/dal/mysql/friend/ImFriendRequestMapperTest.java
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/dal/mysql/message/ImPrivateMessageMapperTest.java
| ... | ... | @@ -12,7 +12,7 @@ import java.util.List; |
| 12 | 12 | import static org.junit.jupiter.api.Assertions.*; |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * IM 私聊消息 Mapper 单元测试 | |
| 15 | + * {@link ImPrivateMessageMapper} 的单元测试 | |
| 16 | 16 | * |
| 17 | 17 | * @author 芋道源码 |
| 18 | 18 | */ |
| ... | ... | @@ -21,9 +21,6 @@ public class ImPrivateMessageMapperTest extends BaseDbUnitTest { |
| 21 | 21 | @Resource |
| 22 | 22 | private ImPrivateMessageMapper mapper; |
| 23 | 23 | |
| 24 | - /** | |
| 25 | - * 一个足够早的时间作为 minSendTime,避免把测试数据过滤掉 | |
| 26 | - */ | |
| 27 | 24 | private static final LocalDateTime FAR_PAST = LocalDateTime.of(2000, 1, 1, 0, 0, 0); |
| 28 | 25 | |
| 29 | 26 | // ========== selectListByMinId ========== | ... | ... |
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/dal/mysql/statistics/ImStatisticsManagerMapperTest.java
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/face/ImFacePackItemServiceImplTest.java
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/face/ImFacePackServiceImplTest.java
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/face/ImFaceUserItemServiceImplTest.java
| ... | ... | @@ -26,7 +26,7 @@ import static org.mockito.Mockito.verify; |
| 26 | 26 | import static org.mockito.Mockito.when; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * IM 用户私有表情 Service 单元测试 | |
| 29 | + * {@link ImFaceUserItemServiceImpl} 的单元测试 | |
| 30 | 30 | * |
| 31 | 31 | * @author 芋道源码 |
| 32 | 32 | */ |
| ... | ... | @@ -141,7 +141,7 @@ public class ImFaceUserItemServiceImplTest extends BaseMockitoUnitTest { |
| 141 | 141 | verify(faceUserItemMapper, never()).deleteById(anyLong()); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - // ========== deleteFaceUserItem(管理后台 by id) ========== | |
| 144 | + // ========== deleteFaceUserItem(管理后台) ========== | |
| 145 | 145 | |
| 146 | 146 | @Test |
| 147 | 147 | public void testDeleteFaceUserItemAdmin_success() { | ... | ... |
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImplTest.java
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/friend/ImFriendServiceImplTest.java
| ... | ... | @@ -29,7 +29,7 @@ import static org.mockito.Mockito.verify; |
| 29 | 29 | import static org.mockito.Mockito.when; |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * IM 好友关系 Service 单元测试 | |
| 32 | + * {@link ImFriendServiceImpl} 的单元测试 | |
| 33 | 33 | * |
| 34 | 34 | * @author 芋道源码 |
| 35 | 35 | */ |
| ... | ... | @@ -141,7 +141,7 @@ public class ImFriendServiceImplTest extends BaseMockitoUnitTest { |
| 141 | 141 | verify(imWebSocketService, never()).sendNotificationAsync(any(Long.class), anyInt(), anyInt(), any()); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - // ========== addFriend0(内部方法,被 becomeFriends / silentReAddFriend 调用) ========== | |
| 144 | + // ========== 建立好友 ========== | |
| 145 | 145 | |
| 146 | 146 | @Test |
| 147 | 147 | public void testAddFriend0_existingEnabledSkip() { | ... | ... |
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/group/ImGroupMemberServiceImplTest.java
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/group/ImGroupRequestServiceImplTest.java
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/group/ImGroupServiceImplTest.java
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/message/ImGroupMessageServiceImplTest.java
| ... | ... | @@ -40,7 +40,7 @@ import static org.mockito.ArgumentMatchers.*; |
| 40 | 40 | import static org.mockito.Mockito.*; |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * IM 群聊消息 Service 单元测试 | |
| 43 | + * {@link ImGroupMessageServiceImpl} 的单元测试 | |
| 44 | 44 | * |
| 45 | 45 | * @author 芋道源码 |
| 46 | 46 | */ |
| ... | ... | @@ -62,7 +62,6 @@ public class ImGroupMessageServiceImplTest extends BaseMockitoUnitTest { |
| 62 | 62 | @Mock |
| 63 | 63 | private ImWebSocketService imWebSocketService; |
| 64 | 64 | |
| 65 | - /** 用真实实例避免 NPE;默认值与生产保持一致(recallTimeoutMinutes=5、private/group read enabled=true、maxPullSize=1000);个别用例可改字段测分支 */ | |
| 66 | 65 | @Spy |
| 67 | 66 | private ImProperties imProperties = new ImProperties(); |
| 68 | 67 | |
| ... | ... | @@ -546,7 +545,7 @@ public class ImGroupMessageServiceImplTest extends BaseMockitoUnitTest { |
| 546 | 545 | assertEquals(GROUP_MEMBER_NOT_IN_GROUP.getCode(), exception.getCode()); |
| 547 | 546 | } |
| 548 | 547 | |
| 549 | - // ========== 发送:补充边界 ========== | |
| 548 | + // ========== 发送边界 ========== | |
| 550 | 549 | |
| 551 | 550 | @Test |
| 552 | 551 | public void testSendMessage_receiptPending() { |
| ... | ... | @@ -600,7 +599,7 @@ public class ImGroupMessageServiceImplTest extends BaseMockitoUnitTest { |
| 600 | 599 | verify(imWebSocketService, never()).sendNotificationAsync(anyCollection(), anyInt(), anyInt(), any()); |
| 601 | 600 | } |
| 602 | 601 | |
| 603 | - // ========== 撤回:补充边界 ========== | |
| 602 | + // ========== 撤回边界 ========== | |
| 604 | 603 | |
| 605 | 604 | @Test |
| 606 | 605 | public void testRecallMessage_notExists() { |
| ... | ... | @@ -630,7 +629,7 @@ public class ImGroupMessageServiceImplTest extends BaseMockitoUnitTest { |
| 630 | 629 | verify(groupMessageMapper, never()).insert(any(ImGroupMessageDO.class)); |
| 631 | 630 | } |
| 632 | 631 | |
| 633 | - // ========== 已读:happy path + 跳过 ========== | |
| 632 | + // ========== 已读事件 ========== | |
| 634 | 633 | |
| 635 | 634 | @Test |
| 636 | 635 | public void testReadGroupMessages_success() { |
| ... | ... | @@ -769,7 +768,7 @@ public class ImGroupMessageServiceImplTest extends BaseMockitoUnitTest { |
| 769 | 768 | } |
| 770 | 769 | } |
| 771 | 770 | |
| 772 | - // ========== 回执:DONE 状态迁移 ========== | |
| 771 | + // ========== 回执状态迁移 ========== | |
| 773 | 772 | |
| 774 | 773 | @Test |
| 775 | 774 | public void testReadGroupMessageEvent_receiptDoneTransition() { |
| ... | ... | @@ -850,7 +849,7 @@ public class ImGroupMessageServiceImplTest extends BaseMockitoUnitTest { |
| 850 | 849 | verify(imWebSocketService).sendNotificationAsync(eq(5L), anyInt(), anyInt(), any()); |
| 851 | 850 | } |
| 852 | 851 | |
| 853 | - // ========== sendGroupMessage(senderId, dto):receiverUserIds 定向过滤 ========== | |
| 852 | + // ========== 定向群消息 ========== | |
| 854 | 853 | |
| 855 | 854 | @Test |
| 856 | 855 | public void testSendGroupMessage_noReceiverUserIds_broadcastsToAllMembers() { |
| ... | ... | @@ -907,7 +906,7 @@ public class ImGroupMessageServiceImplTest extends BaseMockitoUnitTest { |
| 907 | 906 | anyInt(), anyInt(), any()); |
| 908 | 907 | } |
| 909 | 908 | |
| 910 | - // ========== sendGroupMessage(senderId, dto):helper 行为 ========== | |
| 909 | + // ========== DTO 群消息 ========== | |
| 911 | 910 | |
| 912 | 911 | @Test |
| 913 | 912 | public void testSendGroupMessage_dto_persistsAndSerializesPojoContent() { | ... | ... |
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/message/ImPrivateMessageServiceImplTest.java
| ... | ... | @@ -36,7 +36,7 @@ import static org.mockito.ArgumentMatchers.*; |
| 36 | 36 | import static org.mockito.Mockito.*; |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * IM 私聊消息 Service 单元测试 | |
| 39 | + * {@link ImPrivateMessageServiceImpl} 的单元测试 | |
| 40 | 40 | * |
| 41 | 41 | * @author 芋道源码 |
| 42 | 42 | */ |
| ... | ... | @@ -56,7 +56,6 @@ public class ImPrivateMessageServiceImplTest extends BaseMockitoUnitTest { |
| 56 | 56 | @Mock |
| 57 | 57 | private ImWebSocketService imWebSocketService; |
| 58 | 58 | |
| 59 | - /** 用真实实例避免 NPE;默认值与生产保持一致(recallTimeoutMinutes=5、private/group read enabled=true);个别用例可改字段测分支 */ | |
| 60 | 59 | @Spy |
| 61 | 60 | private ImProperties imProperties = new ImProperties(); |
| 62 | 61 | |
| ... | ... | @@ -380,7 +379,7 @@ public class ImPrivateMessageServiceImplTest extends BaseMockitoUnitTest { |
| 380 | 379 | assertEquals(MESSAGE_PRIVATE_READ_DISABLED.getCode(), exception.getCode()); |
| 381 | 380 | } |
| 382 | 381 | |
| 383 | - // ========== sendPrivateMessage(senderId, dto):helper 行为 ========== | |
| 382 | + // ========== DTO 私聊消息 ========== | |
| 384 | 383 | |
| 385 | 384 | @Test |
| 386 | 385 | public void testSendPrivateMessage_dto_persistsAndSerializesPojoContent() { | ... | ... |
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/rtc/ImRtcCallServiceImplTest.java
| ... | ... | @@ -43,6 +43,11 @@ import static org.junit.jupiter.api.Assertions.*; |
| 43 | 43 | import static org.mockito.ArgumentMatchers.*; |
| 44 | 44 | import static org.mockito.Mockito.*; |
| 45 | 45 | |
| 46 | +/** | |
| 47 | + * {@link ImRtcCallServiceImpl} 的单元测试 | |
| 48 | + * | |
| 49 | + * @author 芋道源码 | |
| 50 | + */ | |
| 46 | 51 | public class ImRtcCallServiceImplTest extends BaseMockitoUnitTest { |
| 47 | 52 | |
| 48 | 53 | @InjectMocks |
| ... | ... | @@ -63,7 +68,7 @@ public class ImRtcCallServiceImplTest extends BaseMockitoUnitTest { |
| 63 | 68 | @Mock |
| 64 | 69 | private ImGroupMemberService groupMemberService; |
| 65 | 70 | |
| 66 | - // ========== timeoutInvitingParticipants(Job 入口)========== | |
| 71 | + // ========== timeoutInvitingParticipants ========== | |
| 67 | 72 | |
| 68 | 73 | @Test |
| 69 | 74 | public void testTimeoutInvitingParticipants_emptyCandidates_returnsZeroAndNoDownstream() { |
| ... | ... | @@ -166,7 +171,7 @@ public class ImRtcCallServiceImplTest extends BaseMockitoUnitTest { |
| 166 | 171 | verifyNoInteractions(webSocketService); |
| 167 | 172 | } |
| 168 | 173 | |
| 169 | - // ========== noAnswerCallCheck(前端 timer 入口)========== | |
| 174 | + // ========== noAnswerCallCheck ========== | |
| 170 | 175 | |
| 171 | 176 | @Test |
| 172 | 177 | public void testNoAnswerCallCheck_authFails_silentNoOp() { | ... | ... |
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/sensitiveword/ImSensitiveWordServiceImplTest.java
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/statistics/ImStatisticsManagerServiceImplTest.java
| ... | ... | @@ -19,7 +19,7 @@ import static org.mockito.ArgumentMatchers.eq; |
| 19 | 19 | import static org.mockito.Mockito.when; |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | - * IM 数据看板 Service 单元测试 | |
| 22 | + * {@link ImStatisticsManagerServiceImpl} 的单元测试 | |
| 23 | 23 | * |
| 24 | 24 | * @author 芋道源码 |
| 25 | 25 | */ |
| ... | ... | @@ -72,7 +72,7 @@ public class ImStatisticsManagerServiceImplTest extends BaseMockitoUnitTest { |
| 72 | 72 | assertEquals(456L, service.getGroupMessageCount(BEGIN, END)); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - // ========== 每日序列 toDailyCountMap ========== | |
| 75 | + // ========== 每日序列 ========== | |
| 76 | 76 | |
| 77 | 77 | @Test |
| 78 | 78 | public void testGetNewUserDailyCountMap_dateConvert() { | ... | ... |
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/websocket/ImWebSocketServiceImplTest.java
| ... | ... | @@ -28,7 +28,7 @@ import static org.mockito.ArgumentMatchers.argThat; |
| 28 | 28 | import static org.mockito.Mockito.*; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * IM WebSocket 推送 Service 单元测试 | |
| 31 | + * {@link ImWebSocketServiceImpl} 的单元测试 | |
| 32 | 32 | * |
| 33 | 33 | * @author 芋道源码 |
| 34 | 34 | */ |
| ... | ... | @@ -48,7 +48,7 @@ public class ImWebSocketServiceImplTest extends BaseMockitoUnitTest { |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - // ========== sendNotificationAsync ========== | |
| 51 | + // ========== 私聊推送 ========== | |
| 52 | 52 | |
| 53 | 53 | @Test |
| 54 | 54 | public void testSendNotificationAsync_private_noTransactionSendsImmediately() { |
| ... | ... | @@ -108,7 +108,7 @@ public class ImWebSocketServiceImplTest extends BaseMockitoUnitTest { |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - // ========== sendNotificationAsync ========== | |
| 111 | + // ========== 群聊推送 ========== | |
| 112 | 112 | |
| 113 | 113 | @Test |
| 114 | 114 | public void testSendNotificationAsync_group_fanOutToAllUsers() { | ... | ... |
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/util/ImMessageUtilsTest.java