自动化立体仓库 - WMS系统
cl
2 天以前 18c51d40be82435289ba3be6bd5f8e15fdf786f7
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
package com.zy.integration.iot;
 
import com.zy.iot.config.IotProperties;
import com.zy.iot.util.IotInstructionIdGenerator;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
 
public class IotSupportTest {
 
    @Test
    public void shouldResolveServerUriAndClientId() {
        IotProperties properties = new IotProperties();
        properties.setEndpoint("example-ats.iot.cn-north-1.amazonaws.com.cn");
        properties.setPort(8883);
        properties.setThingName("thing-a");
 
        Assertions.assertEquals("mqtts://example-ats.iot.cn-north-1.amazonaws.com.cn:8883", properties.getServerUri());
        String thingId = properties.getResolvedClientId();
        Assertions.assertNotNull(thingId);
        Assertions.assertTrue(thingId.startsWith("thing-a-"));
        Assertions.assertEquals(thingId, properties.getResolvedClientId());
 
        IotProperties withClient = new IotProperties();
        withClient.setClientId("client-b");
        String cid = withClient.getResolvedClientId();
        Assertions.assertNotNull(cid);
        Assertions.assertTrue(cid.startsWith("client-b-"));
        Assertions.assertEquals(cid, withClient.getResolvedClientId());
    }
 
    @Test
    public void shouldGenerateStableLengthInstructionId() {
        String instructionId = IotInstructionIdGenerator.generate("wrk-1001");
 
        Assertions.assertEquals(20, instructionId.length());
        Assertions.assertEquals(instructionId, instructionId.toUpperCase());
    }
}