yeg
2026-08-29 41cfe20aeb9835315c54b3d6873d4e07ff238cfa
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
package com.ruoyi.config;
 
import static org.junit.jupiter.api.Assertions.assertTrue;
 
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;
 
/** 测试双设备绑定、字段快照和接收状态的 Mapper 契约。 */
class TestDeviceBindingMapperContractTest
{
    @Test
    void persistsAndReadsCollectorMappingsAndFieldSnapshots()
    {
        String mapper = resource("mapper/system/TTestMapper.xml");
 
        assertTrue(mapper.contains("id=\"insertTestCollectorChannel\""));
        assertTrue(mapper.contains("id=\"selectTestCollectorChannels\""));
        assertTrue(mapper.contains("id=\"insertTestFieldSnapshot\""));
        assertTrue(mapper.contains("id=\"selectTestFieldSnapshots\""));
        assertTrue(mapper.contains("reception_status = 'NOT_STARTED'"));
        assertTrue(mapper.contains("channel_count channelCount"));
    }
 
    private static String resource(String path)
    {
        try (InputStream stream = TestDeviceBindingMapperContractTest.class.getClassLoader().getResourceAsStream(path))
        {
            if (stream == null) throw new AssertionError("缺少资源 " + path);
            return new String(stream.readAllBytes(), StandardCharsets.UTF_8);
        }
        catch (Exception exception)
        {
            throw new AssertionError("无法读取资源 " + path, exception);
        }
    }
}