| | |
| | | import com.tourguide.modules.order.dto.GuideOrderResponse; |
| | | import com.tourguide.modules.order.entity.TourOrder; |
| | | import com.tourguide.modules.order.mapper.TourOrderMapper; |
| | | import com.tourguide.modules.operation.entity.ScenicMeetingPoint; |
| | | import com.tourguide.modules.operation.mapper.ScenicMeetingPointMapper; |
| | | import com.tourguide.modules.operation.entity.ScenicPricing; |
| | | import com.tourguide.modules.operation.mapper.ScenicPricingMapper; |
| | | import com.tourguide.modules.user.entity.GuideReceivingSession; |
| | |
| | | import org.junit.jupiter.api.Test; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Collections; |
| | | |
| | | import static org.assertj.core.api.Assertions.assertThat; |
| | | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
| | |
| | | private GuideReceivingSessionMapper sessionMapper; |
| | | private GuideRealtimeStatusMapper realtimeStatusMapper; |
| | | private ScenicPricingMapper pricingMapper; |
| | | private ScenicMeetingPointMapper meetingPointMapper; |
| | | private GuideTourOrderService service; |
| | | |
| | | @BeforeEach |
| | |
| | | sessionMapper = mock(GuideReceivingSessionMapper.class); |
| | | realtimeStatusMapper = mock(GuideRealtimeStatusMapper.class); |
| | | pricingMapper = mock(ScenicPricingMapper.class); |
| | | service = new GuideTourOrderService(orderMapper, sessionMapper, realtimeStatusMapper, pricingMapper); |
| | | meetingPointMapper = mock(ScenicMeetingPointMapper.class); |
| | | service = new GuideTourOrderService(orderMapper, sessionMapper, realtimeStatusMapper, |
| | | pricingMapper, meetingPointMapper); |
| | | } |
| | | |
| | | @Test |
| | |
| | | } |
| | | |
| | | @Test |
| | | void shouldExposeMeetingPointCoordinatesForOrder() { |
| | | TourOrder order = order(OrderStatus.COMPLETED); |
| | | order.setScenicSpotId(11L); |
| | | order.setMeetingPointId(12L); |
| | | order.setMeetingPointName("景区正门"); |
| | | ScenicMeetingPoint point = new ScenicMeetingPoint(); |
| | | point.setId(12L); |
| | | point.setScenicSpotId(11L); |
| | | point.setPointName("景区正门"); |
| | | point.setAddress("景区东门"); |
| | | point.setLongitude(new BigDecimal("103.648278")); |
| | | point.setLatitude(new BigDecimal("31.001472")); |
| | | when(orderMapper.selectOne(any())).thenReturn(order); |
| | | when(meetingPointMapper.selectBatchIds(any())).thenReturn(Collections.singletonList(point)); |
| | | |
| | | GuideOrderResponse response = service.detail(8L, 10L); |
| | | |
| | | assertThat(response.getMeetingPointId()).isEqualTo(12L); |
| | | assertThat(response.getMeetingPointAddress()).isEqualTo("景区东门"); |
| | | assertThat(response.getMeetingPointLongitude()).isEqualByComparingTo("103.648278"); |
| | | assertThat(response.getMeetingPointLatitude()).isEqualByComparingTo("31.001472"); |
| | | } |
| | | |
| | | @Test |
| | | void shouldRejectOrderOutsidePendingMeetingState() { |
| | | TourOrder order = order(OrderStatus.COMPLETED); |
| | | when(orderMapper.selectOne(any())).thenReturn(order); |