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); } } }