| New file |
| | |
| | | package com.zy.core.plugin.store; |
| | | |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.core.model.CommandResponse; |
| | | import com.zy.core.model.StationObjModel; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import com.zy.core.thread.StationThread; |
| | | import org.junit.jupiter.api.Test; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | | |
| | | class StoreInTaskPolicyTest { |
| | | |
| | | private final StoreInTaskPolicy policy = context -> true; |
| | | |
| | | @Test |
| | | void onApplyFailed_propagatesWarningToBackStation() { |
| | | StationProtocol barcodeStation = new StationProtocol(); |
| | | barcodeStation.setStationId(102); |
| | | StationProtocol backStation = new StationProtocol(); |
| | | backStation.setStationId(101); |
| | | StationThread stationThread = new FixedStationThread(Map.of( |
| | | 102, barcodeStation, |
| | | 101, backStation |
| | | )); |
| | | |
| | | StationObjModel backStationModel = new StationObjModel(); |
| | | backStationModel.setStationId(101); |
| | | StationObjModel barcodeStationModel = new StationObjModel(); |
| | | barcodeStationModel.setStationId(102); |
| | | barcodeStationModel.setBackStation(backStationModel); |
| | | |
| | | StoreInTaskContext context = new StoreInTaskContext(new BasDevp(), stationThread, barcodeStationModel, barcodeStation); |
| | | AsyncInTaskResult result = new AsyncInTaskResult(); |
| | | result.setMessage("WMS异常"); |
| | | |
| | | policy.onApplyFailed(context, result); |
| | | |
| | | assertEquals("请求入库失败,WMS返回=WMS异常", barcodeStation.getSystemWarning()); |
| | | assertEquals("请求入库失败,WMS返回=WMS异常", backStation.getSystemWarning()); |
| | | } |
| | | |
| | | private static class FixedStationThread implements StationThread { |
| | | |
| | | private final Map<Integer, StationProtocol> statusMap; |
| | | |
| | | private FixedStationThread(Map<Integer, StationProtocol> statusMap) { |
| | | this.statusMap = statusMap; |
| | | } |
| | | |
| | | @Override |
| | | public List<StationProtocol> getStatus() { |
| | | return List.copyOf(statusMap.values()); |
| | | } |
| | | |
| | | @Override |
| | | public Map<Integer, StationProtocol> getStatusMap() { |
| | | return statusMap; |
| | | } |
| | | |
| | | @Override |
| | | public StationCommand getCommand(com.zy.core.enums.StationCommandType commandType, Integer taskNo, |
| | | Integer stationId, Integer targetStationId, Integer palletSize) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public boolean clearPath(Integer taskNo) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public CommandResponse sendCommand(StationCommand command) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public CommandResponse sendOriginCommand(String address, short[] data) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public byte[] readOriginCommand(String address, int length) { |
| | | return new byte[0]; |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | } |
| | | |
| | | @Override |
| | | public boolean connect() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | } |
| | | } |
| | | } |