| | |
| | | |
| | | import com.zy.asrs.entity.BasStationOpt; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.BasStation; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.BasStationService; |
| | | import com.zy.asrs.service.BasStationOptService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.service.WrkAnalysisService; |
| | |
| | | } |
| | | |
| | | @Test |
| | | void stationOutExecuteFinish_attemptsClearPathBeforeCompletingTask() { |
| | | StationOperateProcessUtils utils = new StationOperateProcessUtils(); |
| | | WrkMastService wrkMastService = mock(WrkMastService.class); |
| | | BasStationService basStationService = mock(BasStationService.class); |
| | | WrkAnalysisService wrkAnalysisService = mock(WrkAnalysisService.class); |
| | | NotifyUtils notifyUtils = mock(NotifyUtils.class); |
| | | RedisUtil redisUtil = mock(RedisUtil.class); |
| | | StationMoveCoordinator coordinator = mock(StationMoveCoordinator.class); |
| | | StationThread stationThread = mock(StationThread.class); |
| | | |
| | | ReflectionTestUtils.setField(utils, "wrkMastService", wrkMastService); |
| | | ReflectionTestUtils.setField(utils, "basStationService", basStationService); |
| | | ReflectionTestUtils.setField(utils, "wrkAnalysisService", wrkAnalysisService); |
| | | ReflectionTestUtils.setField(utils, "notifyUtils", notifyUtils); |
| | | ReflectionTestUtils.setField(utils, "redisUtil", redisUtil); |
| | | ReflectionTestUtils.setField(utils, "stationMoveCoordinator", coordinator); |
| | | |
| | | WrkMast wrkMast = buildWrkMast(10335, 145); |
| | | wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts); |
| | | when(wrkMastService.list(any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))) |
| | | .thenReturn(Collections.singletonList(wrkMast)); |
| | | when(wrkMastService.updateById(wrkMast)).thenReturn(true); |
| | | |
| | | BasStation basStation = new BasStation(); |
| | | basStation.setStationId(145); |
| | | basStation.setDeviceNo(1); |
| | | when(basStationService.getOne(any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))) |
| | | .thenReturn(basStation); |
| | | |
| | | StationProtocol stationProtocol = buildStationProtocol(145, 10335, 145); |
| | | when(stationThread.getStatusMap()).thenReturn(Map.of(145, stationProtocol)); |
| | | when(stationThread.clearPath(10335)).thenReturn(true); |
| | | |
| | | SlaveConnection.put(SlaveType.Devp, 1, stationThread); |
| | | try { |
| | | utils.stationOutExecuteFinish(); |
| | | |
| | | verify(stationThread, times(1)).clearPath(10335); |
| | | verify(coordinator, times(1)).finishSession(10335); |
| | | verify(wrkMastService, times(1)).updateById(wrkMast); |
| | | assertEquals(WrkStsType.STATION_RUN_COMPLETE.sts, wrkMast.getWrkSts()); |
| | | } finally { |
| | | SlaveConnection.remove(SlaveType.Devp, 1); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | void watchCircleStation_usesSessionArrivalStateWhenLegacyCommandMissing() { |
| | | StationOperateProcessUtils utils = new StationOperateProcessUtils(); |
| | | BasDevpService basDevpService = mock(BasDevpService.class); |