| | |
| | | |
| | | import static org.mockito.ArgumentMatchers.any; |
| | | import static org.mockito.Mockito.mock; |
| | | import static org.mockito.Mockito.never; |
| | | import static org.mockito.Mockito.verify; |
| | | import static org.mockito.Mockito.when; |
| | | |
| | |
| | | stationOperateProcessUtils |
| | | ); |
| | | |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(1001); |
| | | wrkMast.setIoType(1); |
| | | wrkMast.setWrkSts(WrkStsType.INBOUND_STATION_RUN.sts); |
| | | wrkMast.setStaNo(12); |
| | | |
| | | BasStation basStation = new BasStation(); |
| | | basStation.setStationId(12); |
| | | basStation.setDeviceNo(3); |
| | | WrkMast wrkMast = inboundWrkMast(1001, 12); |
| | | BasStation basStation = station(12, 3); |
| | | |
| | | when(wrkMastService.list(any(QueryWrapper.class))).thenReturn(List.of(wrkMast)); |
| | | when(basStationService.getOne(any())).thenReturn(basStation); |
| | |
| | | verify(wrkAnalysisService).completeInboundStationRun(any(WrkMast.class), any(Date.class)); |
| | | } |
| | | |
| | | @Test |
| | | void scanInboundStationArrival_completesTaskWhenProtocolMatchesCurrentTask() { |
| | | WrkMastService wrkMastService = mock(WrkMastService.class); |
| | | BasStationService basStationService = mock(BasStationService.class); |
| | | WrkAnalysisService wrkAnalysisService = mock(WrkAnalysisService.class); |
| | | StationOperateProcessUtils stationOperateProcessUtils = mock(StationOperateProcessUtils.class); |
| | | |
| | | WrkAnalysisStationArrivalScanner scanner = new WrkAnalysisStationArrivalScanner( |
| | | wrkMastService, |
| | | basStationService, |
| | | wrkAnalysisService, |
| | | stationOperateProcessUtils |
| | | ); |
| | | |
| | | WrkMast wrkMast = inboundWrkMast(1002, 15); |
| | | BasStation basStation = station(15, 5); |
| | | |
| | | when(wrkMastService.list(any(QueryWrapper.class))).thenReturn(List.of(wrkMast)); |
| | | when(basStationService.getOne(any())).thenReturn(basStation); |
| | | when(wrkAnalysisService.completeInboundStationRun(any(WrkMast.class), any(Date.class))).thenReturn(true); |
| | | |
| | | ArrivalAwareStationThread stationThread = new ArrivalAwareStationThread(false); |
| | | StationProtocol stationProtocol = new StationProtocol(); |
| | | stationProtocol.setStationId(15); |
| | | stationProtocol.setTaskNo(1002); |
| | | stationProtocol.setLoading(true); |
| | | stationThread.putStatus(stationProtocol); |
| | | |
| | | SlaveConnection.put(SlaveType.Devp, 5, stationThread); |
| | | try { |
| | | scanner.scanInboundStationArrival(); |
| | | } finally { |
| | | SlaveConnection.remove(SlaveType.Devp, 5); |
| | | } |
| | | |
| | | verify(wrkAnalysisService).completeInboundStationRun(any(WrkMast.class), any(Date.class)); |
| | | } |
| | | |
| | | @Test |
| | | void scanInboundStationArrival_skipsWhenArrivalWasNotObserved() { |
| | | WrkMastService wrkMastService = mock(WrkMastService.class); |
| | | BasStationService basStationService = mock(BasStationService.class); |
| | | WrkAnalysisService wrkAnalysisService = mock(WrkAnalysisService.class); |
| | | StationOperateProcessUtils stationOperateProcessUtils = mock(StationOperateProcessUtils.class); |
| | | |
| | | WrkAnalysisStationArrivalScanner scanner = new WrkAnalysisStationArrivalScanner( |
| | | wrkMastService, |
| | | basStationService, |
| | | wrkAnalysisService, |
| | | stationOperateProcessUtils |
| | | ); |
| | | |
| | | WrkMast wrkMast = inboundWrkMast(1003, 18); |
| | | BasStation basStation = station(18, 8); |
| | | |
| | | when(wrkMastService.list(any(QueryWrapper.class))).thenReturn(List.of(wrkMast)); |
| | | when(basStationService.getOne(any())).thenReturn(basStation); |
| | | |
| | | ArrivalAwareStationThread stationThread = new ArrivalAwareStationThread(false); |
| | | StationProtocol stationProtocol = new StationProtocol(); |
| | | stationProtocol.setStationId(18); |
| | | stationProtocol.setTaskNo(9999); |
| | | stationProtocol.setLoading(true); |
| | | stationThread.putStatus(stationProtocol); |
| | | |
| | | SlaveConnection.put(SlaveType.Devp, 8, stationThread); |
| | | try { |
| | | scanner.scanInboundStationArrival(); |
| | | } finally { |
| | | SlaveConnection.remove(SlaveType.Devp, 8); |
| | | } |
| | | |
| | | verify(wrkAnalysisService, never()).completeInboundStationRun(any(WrkMast.class), any(Date.class)); |
| | | } |
| | | |
| | | @Test |
| | | void scanOutboundStationFlow_triggersStationOperateProcessSteps() { |
| | | WrkMastService wrkMastService = mock(WrkMastService.class); |
| | | BasStationService basStationService = mock(BasStationService.class); |
| | | WrkAnalysisService wrkAnalysisService = mock(WrkAnalysisService.class); |
| | | StationOperateProcessUtils stationOperateProcessUtils = mock(StationOperateProcessUtils.class); |
| | | |
| | | WrkAnalysisStationArrivalScanner scanner = new WrkAnalysisStationArrivalScanner( |
| | | wrkMastService, |
| | | basStationService, |
| | | wrkAnalysisService, |
| | | stationOperateProcessUtils |
| | | ); |
| | | |
| | | scanner.scanOutboundStationFlow(); |
| | | |
| | | verify(stationOperateProcessUtils).stationOutExecuteFinish(); |
| | | verify(stationOperateProcessUtils).checkTaskToComplete(); |
| | | } |
| | | |
| | | private WrkMast inboundWrkMast(int wrkNo, int stationId) { |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(wrkNo); |
| | | wrkMast.setIoType(1); |
| | | wrkMast.setWrkSts(WrkStsType.INBOUND_STATION_RUN.sts); |
| | | wrkMast.setStaNo(stationId); |
| | | return wrkMast; |
| | | } |
| | | |
| | | private BasStation station(int stationId, int deviceNo) { |
| | | BasStation basStation = new BasStation(); |
| | | basStation.setStationId(stationId); |
| | | basStation.setDeviceNo(deviceNo); |
| | | return basStation; |
| | | } |
| | | |
| | | private static class ArrivalAwareStationThread implements StationThread { |
| | | |
| | | private final boolean recentArrival; |