#
Junjie
1 天以前 aa710969e00e9d7e56a276066a239f74d5c49310
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.zy.core.network.real;
 
import com.zy.core.model.StationObjModel;
import org.junit.jupiter.api.Test;
 
import java.util.Arrays;
import java.util.List;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
 
class ZyStationV4RealConnectTest {
 
    @Test
    void buildConveyorCommonAlarmMessageShouldMapDefinedBits() {
        String alarmMsg = ZyStationV4RealConnect.buildConveyorCommonAlarmMessage(
                new boolean[]{true, false, false, false, false, false, false, false},
                new boolean[]{false, false, true, false, false, false, false, false},
                new boolean[]{false, false, true, false, false, false, false, false},
                new boolean[]{true, true, false, false, false, false, false, false}
        );
 
        assertEquals("急停;扫码检验异常;高位变频器故障;路径查询异常;", alarmMsg);
    }
 
    @Test
    void mergeAlarmMessagesShouldAppendToExistingBarcodeAlarm() {
        String merged = ZyStationV4RealConnect.mergeAlarmMessages("扫码异常;", "急停;路径查询异常;");
 
        assertEquals("扫码异常;急停;路径查询异常;", merged);
    }
 
    @Test
    void sortStationObjModelsByStationIdShouldSortAscending() {
        List<StationObjModel> sorted = ZyStationV4RealConnect.sortStationObjModelsByStationId(Arrays.asList(
                station(107),
                station(101),
                station(104)
        ));
 
        assertEquals(101, sorted.get(0).getStationId());
        assertEquals(104, sorted.get(1).getStationId());
        assertEquals(107, sorted.get(2).getStationId());
    }
 
    private static StationObjModel station(Integer stationId) {
        StationObjModel model = new StationObjModel();
        model.setStationId(stationId);
        return model;
    }
}