From 98d80c673233f7b5bcdbdfa01a1fcfb6cebcd981 Mon Sep 17 00:00:00 2001 From: hy001 Date: Sat, 23 May 2026 21:26:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AB=9F=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../circle/other/app/listener/user/CpApplyListener.java | 6 ++++-- .../other/app/listener/user/CpApplyListenerTest.java | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/user/CpApplyListener.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/user/CpApplyListener.java index d97acfc3..eba27308 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/user/CpApplyListener.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/user/CpApplyListener.java @@ -61,8 +61,10 @@ public class CpApplyListener implements MessageListener { } private void expire(CpApply cpApply) { - sendExpiredNotice(cpApply); - cpApplyService.changeStatusById(cpApply.getId(), CpApplyStatus.EXPIRE); + boolean changed = cpApplyService.changeStatusById(cpApply.getId(), CpApplyStatus.EXPIRE); + if (changed) { + sendExpiredNotice(cpApply); + } } private void sendExpiredNotice(CpApply cpApply) { diff --git a/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/listener/user/CpApplyListenerTest.java b/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/listener/user/CpApplyListenerTest.java index a421907b..0bda6de2 100644 --- a/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/listener/user/CpApplyListenerTest.java +++ b/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/listener/user/CpApplyListenerTest.java @@ -4,8 +4,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; @@ -27,6 +27,7 @@ import java.util.Map; import java.util.function.Consumer; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; +import org.mockito.InOrder; class CpApplyListenerTest { @@ -66,10 +67,11 @@ class CpApplyListenerTest { ArgumentCaptor captor = ArgumentCaptor.forClass( CustomC2cMsgBodyCmd.class); - verify(imMessageClient).sendCustomMessage(captor.capture()); + InOrder inOrder = inOrder(cpApplyService, imMessageClient); + inOrder.verify(cpApplyService).changeStatusById(3001L, CpApplyStatus.EXPIRE); + inOrder.verify(imMessageClient).sendCustomMessage(captor.capture()); List messages = captor.getAllValues(); assertExpiredMessage(messages.get(0), "1001", "2001"); - verify(cpApplyService).changeStatusById(3001L, CpApplyStatus.EXPIRE); } @SuppressWarnings("unchecked")