| | |
| | | } |
| | | |
| | | @Test |
| | | void idleRecover_skipsWhenCurrentStationIsStillInsideRecentlyIssuedActiveRoute() { |
| | | StationOperateProcessUtils utils = new StationOperateProcessUtils(); |
| | | StationMoveCoordinator coordinator = mock(StationMoveCoordinator.class); |
| | | RedisUtil redisUtil = mock(RedisUtil.class); |
| | | ReflectionTestUtils.setField(utils, "stationMoveCoordinator", coordinator); |
| | | ReflectionTestUtils.setField(utils, "redisUtil", redisUtil); |
| | | |
| | | StationMoveSession session = new StationMoveSession(); |
| | | session.setStatus(StationMoveSession.STATUS_RUNNING); |
| | | session.setDispatchStationId(196); |
| | | session.setCurrentStationId(189); |
| | | session.setFullPathStationIds(List.of(196, 195, 189, 121, 124)); |
| | | session.setLastIssuedAt(System.currentTimeMillis()); |
| | | when(coordinator.loadSession(10510)).thenReturn(session); |
| | | |
| | | StationCommand command = new StationCommand(); |
| | | command.setTaskNo(10510); |
| | | command.setStationId(121); |
| | | command.setTargetStaNo(124); |
| | | |
| | | StationOperateProcessUtils.RerouteContext context = StationOperateProcessUtils.RerouteContext.create( |
| | | StationOperateProcessUtils.RerouteSceneType.IDLE_RECOVER, |
| | | buildBasDevp(1), |
| | | mock(StationThread.class), |
| | | buildStationProtocol(121, 10510, 121), |
| | | buildWrkMast(10510, 124), |
| | | Collections.emptyList(), |
| | | 0.0d, |
| | | "checkStationIdleRecover" |
| | | ).withRecentDispatchGuard(); |
| | | |
| | | StationOperateProcessUtils.RerouteExecutionResult result = utils.executeReroutePlan( |
| | | context, |
| | | StationOperateProcessUtils.RerouteCommandPlan.dispatch( |
| | | command, |
| | | StationOperateProcessUtils.RerouteDecision.proceed(124), |
| | | "checkStationIdleRecover" |
| | | ) |
| | | ); |
| | | |
| | | assertTrue(result.skipped()); |
| | | assertEquals("recent-dispatch", result.skipReason()); |
| | | verify(coordinator, never()).cancelSession(10510); |
| | | } |
| | | |
| | | @Test |
| | | void checkStationOutOrder_skipsWhenActiveSessionAlreadyOwnsCurrentStation() { |
| | | StationOperateProcessUtils utils = new StationOperateProcessUtils(); |
| | | BasDevpService basDevpService = mock(BasDevpService.class); |