| | |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.test.util.ReflectionTestUtils; |
| | | |
| | | import java.util.List; |
| | | import java.util.function.Function; |
| | | |
| | | import static org.junit.jupiter.api.Assertions.assertFalse; |
| | | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | | import static org.mockito.ArgumentMatchers.any; |
| | | import static org.mockito.Mockito.mock; |
| | | import static org.mockito.Mockito.never; |
| | |
| | | class StationSegmentExecutorTest { |
| | | |
| | | @Test |
| | | void resolveCurrentPathIndex_prefersForwardOccurrenceForLoopRevisitStations() { |
| | | StationSegmentExecutor executor = new StationSegmentExecutor(new DeviceConfig(), mock(RedisUtil.class), command -> null); |
| | | |
| | | Integer second121Index = ReflectionTestUtils.invokeMethod( |
| | | executor, |
| | | "resolveCurrentPathIndex", |
| | | List.of(121, 124, 186, 189, 121, 124, 125, 127), |
| | | 121, |
| | | 3 |
| | | ); |
| | | Integer second124Index = ReflectionTestUtils.invokeMethod( |
| | | executor, |
| | | "resolveCurrentPathIndex", |
| | | List.of(121, 124, 186, 189, 121, 124, 125, 127), |
| | | 124, |
| | | 4 |
| | | ); |
| | | Integer same124Index = ReflectionTestUtils.invokeMethod( |
| | | executor, |
| | | "resolveCurrentPathIndex", |
| | | List.of(121, 124, 186, 189, 121, 124, 125, 127), |
| | | 124, |
| | | 5 |
| | | ); |
| | | |
| | | assertEquals(Integer.valueOf(4), second121Index); |
| | | assertEquals(Integer.valueOf(5), second124Index); |
| | | assertEquals(Integer.valueOf(5), same124Index); |
| | | } |
| | | |
| | | @Test |
| | | void sendSegmentWithRetry_skipsWhenRouteIsCancelPending() { |
| | | ApplicationContext applicationContext = mock(ApplicationContext.class); |
| | | StationMoveCoordinator coordinator = new StationMoveCoordinator(); |