yeg
2026-08-28 9fed155adefdb73dd349ff99a897f2d2da5ea03e
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.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 BatterySelectionMapperContractTest
{
    @Test
    void batteryGroupBatteriesFeedEnabledTestOptions()
    {
        String groupMapper = resource("mapper/system/TBatteryGroupMapper.xml");
        String testMapper = resource("mapper/system/TTestMapper.xml");
 
        assertTrue(groupMapper.contains("insert into t_battery_group_battery"));
        assertTrue(testMapper.contains("id=\"selectEnabledBatteryOptions\""));
        assertTrue(testMapper.contains("from t_battery_group_battery battery"));
        assertTrue(testMapper.contains("battery_group.status = '0'"));
        assertTrue(testMapper.contains("battery.battery_no batteryNo"));
        assertTrue(groupMapper.contains("t.test_status not in ('COMPLETED', 'TERMINATED')"));
    }
 
    private static String resource(String path)
    {
        try (InputStream stream = BatterySelectionMapperContractTest.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);
        }
    }
}