From 825a575deb96cce822468bb9d9ac3e4eea0f91d1 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期四, 17 九月 2026 08:58:14 +0800
Subject: [PATCH] update
---
backend/src/test/java/com/tourguide/modules/user/service/GuideAutoDisableServiceTest.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/backend/src/test/java/com/tourguide/modules/user/service/GuideAutoDisableServiceTest.java b/backend/src/test/java/com/tourguide/modules/user/service/GuideAutoDisableServiceTest.java
index e95af94..30202aa 100644
--- a/backend/src/test/java/com/tourguide/modules/user/service/GuideAutoDisableServiceTest.java
+++ b/backend/src/test/java/com/tourguide/modules/user/service/GuideAutoDisableServiceTest.java
@@ -11,7 +11,9 @@
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
@@ -56,6 +58,56 @@
}
@Test
+ void shouldRestoreAutomaticallyDisabledGuideNoLongerMatchingRule() {
+ GuideAutoDisableConfig config = validConfig();
+ when(configMapper.selectById(1)).thenReturn(config);
+ when(guideUserMapper.restoreAutoDisabledGuidesNoLongerEligible(10, new BigDecimal("4.50")))
+ .thenReturn(1);
+ when(guideUserMapper.selectList(any())).thenReturn(Collections.emptyList());
+
+ service.synchronizeGuideStatuses();
+
+ verify(guideUserMapper).restoreAutoDisabledGuidesNoLongerEligible(10, new BigDecimal("4.50"));
+ verify(guideUserMapper, never()).autoDisableIfEligible(any(), any(), any());
+ verifyNoInteractions(orderMapper, realtimeStatusMapper, receivingSessionMapper);
+ }
+
+ @Test
+ void shouldNotDisableGuideWithoutAnEffectiveRating() {
+ GuideUser guide = eligibleGuide(0);
+ guide.setRating(BigDecimal.ZERO);
+ when(configMapper.selectById(1)).thenReturn(validConfig());
+ when(guideUserMapper.selectById(8L)).thenReturn(guide);
+
+ service.disableGuideIfEligible(8L);
+
+ verify(guideUserMapper, never()).autoDisableIfEligible(any(), any(), any());
+ verifyNoInteractions(orderMapper, realtimeStatusMapper, receivingSessionMapper);
+ }
+
+ @Test
+ void shouldContinueScanningAfterAFullBatchOfBlockedGuides() {
+ List<GuideUser> firstBatch = new ArrayList<>();
+ for (long id = 1; id <= 100; id++) {
+ GuideUser guide = eligibleGuide(0);
+ guide.setId(id);
+ firstBatch.add(guide);
+ }
+ GuideUser laterGuide = eligibleGuide(0);
+ laterGuide.setId(101L);
+ when(configMapper.selectById(1)).thenReturn(validConfig());
+ when(guideUserMapper.selectList(any())).thenReturn(firstBatch, Collections.singletonList(laterGuide));
+ when(orderMapper.selectCount(any())).thenReturn(1L).thenReturn(0L);
+ when(guideUserMapper.autoDisableIfEligible(101L, 10, new BigDecimal("4.50"))).thenReturn(1);
+
+ service.disableEligibleGuides();
+
+ verify(guideUserMapper).autoDisableIfEligible(101L, 10, new BigDecimal("4.50"));
+ verify(realtimeStatusMapper).disableReceiving(101L);
+ verify(receivingSessionMapper).stopReceivingByGuide(101L);
+ }
+
+ @Test
void shouldNeverDisableWhitelistedGuide() {
service.disableIfEligible(eligibleGuide(1), validConfig());
@@ -91,6 +143,7 @@
service.disableEligibleGuides();
verify(guideUserMapper, never()).selectList(any());
+ verify(guideUserMapper, never()).restoreAutoDisabledGuidesNoLongerEligible(any(), any());
verifyNoInteractions(orderMapper, realtimeStatusMapper, receivingSessionMapper);
}
--
Gitblit v1.7.1