| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @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()); |
| | | |