| | |
| | | import com.tourguide.modules.user.mapper.GuideRealtimeStatusMapper; |
| | | import com.tourguide.modules.user.mapper.GuideReceivingSessionMapper; |
| | | import com.tourguide.modules.user.mapper.GuideUserMapper; |
| | | import org.mockito.ArgumentCaptor; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.Test; |
| | | |
| | |
| | | verify(notificationService).notifyOrderAssigned(secondOrder); |
| | | } |
| | | |
| | | @Test |
| | | void shouldApplyScenicLeadTimeToPrivateOrderSession() { |
| | | TourOrder order = privateOrder(3L); |
| | | GuideReceivingSession session = receivingSession("RECEIVING", 0); |
| | | session.setReceivingMode("PRIVATE"); |
| | | ScenicPricing pricing = privatePricing(); |
| | | OperationScenicSpot scenic = scenicSpot(); |
| | | GuideUser guide = guide(); |
| | | |
| | | when(orderMapper.selectForUpdate(3L)).thenReturn(order); |
| | | when(sessionMapper.selectMatchCandidates(11L, 12L, "PRIVATE", "PRIVATE_QUICK")) |
| | | .thenReturn(Collections.singletonList(session)); |
| | | when(pricingMapper.selectById(30L)).thenReturn(pricing); |
| | | when(scenicMapper.selectById(11L)).thenReturn(scenic); |
| | | when(guideUserMapper.selectById(7L)).thenReturn(guide); |
| | | when(sessionMapper.assignPrivate(eq(41L), eq(1), any(LocalDateTime.class), any(LocalDateTime.class))) |
| | | .thenReturn(1); |
| | | |
| | | assertThat(service.match(3L)).isTrue(); |
| | | |
| | | ArgumentCaptor<LocalDateTime> now = ArgumentCaptor.forClass(LocalDateTime.class); |
| | | ArgumentCaptor<LocalDateTime> serviceStartAt = ArgumentCaptor.forClass(LocalDateTime.class); |
| | | verify(sessionMapper).assignPrivate(eq(41L), eq(1), now.capture(), serviceStartAt.capture()); |
| | | assertThat(serviceStartAt.getValue()).isEqualTo(now.getValue().plusMinutes(10)); |
| | | assertThat(order.getStatus()).isEqualTo(OrderStatus.PENDING_MEETING.getCode()); |
| | | } |
| | | |
| | | private TourOrder groupOrder(Long id) { |
| | | TourOrder order = new TourOrder(); |
| | | order.setId(id); |
| | |
| | | order.setOrderType("GROUP_PREMIUM"); |
| | | order.setPeopleCount(1); |
| | | order.setStatus(OrderStatus.PENDING_ACCEPT.getCode()); |
| | | return order; |
| | | } |
| | | |
| | | private TourOrder privateOrder(Long id) { |
| | | TourOrder order = groupOrder(id); |
| | | order.setOrderType("PRIVATE_QUICK"); |
| | | return order; |
| | | } |
| | | |
| | |
| | | return pricing; |
| | | } |
| | | |
| | | private ScenicPricing privatePricing() { |
| | | ScenicPricing pricing = new ScenicPricing(); |
| | | pricing.setId(30L); |
| | | pricing.setScenicSpotId(11L); |
| | | pricing.setServiceType("PRIVATE_QUICK"); |
| | | pricing.setDiscountPrice(new BigDecimal("536.00")); |
| | | return pricing; |
| | | } |
| | | |
| | | private OperationScenicSpot scenicSpot() { |
| | | OperationScenicSpot scenic = new OperationScenicSpot(); |
| | | scenic.setId(11L); |