| | |
| | | import com.tourguide.modules.user.entity.MiniUser; |
| | | import com.tourguide.modules.user.mapper.GuideUserMapper; |
| | | import com.tourguide.modules.user.service.MiniUserService; |
| | | import com.tourguide.modules.system.service.GuideNotificationService; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.mockito.ArgumentCaptor; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | import static org.assertj.core.api.Assertions.assertThat; |
| | | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
| | |
| | | private ScenicPricingMapper pricingMapper; |
| | | private GuideUserMapper guideUserMapper; |
| | | private PlatformSettingsService platformSettingsService; |
| | | private GuideOrderMatchingService matchingService; |
| | | private GuideNotificationService notificationService; |
| | | private MiniTourOrderCommandService commandService; |
| | | |
| | | @BeforeEach |
| | |
| | | pricingMapper = mock(ScenicPricingMapper.class); |
| | | guideUserMapper = mock(GuideUserMapper.class); |
| | | platformSettingsService = mock(PlatformSettingsService.class); |
| | | matchingService = mock(GuideOrderMatchingService.class); |
| | | notificationService = mock(GuideNotificationService.class); |
| | | commandService = new MiniTourOrderCommandService( |
| | | orderMapper, miniUserService, scenicSpotMapper, meetingPointMapper, pricingMapper, |
| | | guideUserMapper, platformSettingsService); |
| | | guideUserMapper, platformSettingsService, matchingService, notificationService); |
| | | } |
| | | |
| | | @Test |
| | |
| | | order.setAmount(new BigDecimal("144.00")); |
| | | order.setStatus(OrderStatus.PENDING_PAYMENT.getCode()); |
| | | when(orderMapper.selectOne(any())).thenReturn(order); |
| | | when(orderMapper.selectById(99L)).thenReturn(order); |
| | | |
| | | TourOrderResponse response = commandService.confirmPayment(7L, 99L); |
| | | |
| | |
| | | |
| | | verify(orderMapper, never()).insert(any(TourOrder.class)); |
| | | } |
| | | |
| | | @Test |
| | | void cancelPendingMeetingOrderShouldNotifyAssignedGuide() { |
| | | MiniUser visitor = new MiniUser(); |
| | | visitor.setId(7L); |
| | | when(miniUserService.findEnabledById(7L)).thenReturn(visitor); |
| | | |
| | | TourOrder order = new TourOrder(); |
| | | order.setId(99L); |
| | | order.setOrderNo("MJ202607300001"); |
| | | order.setVisitorId(7L); |
| | | order.setGuideId(8L); |
| | | order.setStatus(OrderStatus.PENDING_MEETING.getCode()); |
| | | order.setPaymentTime(LocalDateTime.now()); |
| | | order.setPaymentAmount(new BigDecimal("36.00")); |
| | | when(orderMapper.selectOne(any())).thenReturn(order); |
| | | |
| | | commandService.cancel(7L, 99L); |
| | | |
| | | assertThat(order.getStatus()).isEqualTo(OrderStatus.CANCELLED.getCode()); |
| | | verify(orderMapper).updateById(order); |
| | | verify(notificationService).notifyOrderCancelled(order); |
| | | } |
| | | } |