yeg
2026-09-05 890049eeece6fc94cd974368451cdc36ec89fdf4
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
package com.battery.business.runtime;
 
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
 
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;
 
/** Ticket14 迁移契约:完整性事实追加存储且不改写历史迁移。 */
class Ticket14MigrationContractTest
{
    @Test
    void addsIntervalIntegrityFactsAndCollectorIntervalOwnership()
    {
        String sql;
        try (InputStream stream = getClass().getClassLoader().getResourceAsStream(
                "db/migration/V22__interval_integrity_and_completion.sql"))
        {
            if (stream == null) throw new AssertionError("缺少 Ticket14 迁移");
            sql = new String(stream.readAllBytes(), StandardCharsets.UTF_8);
        }
        catch (Exception exception) { throw new AssertionError(exception); }
        assertTrue(sql.contains("t_test_integrity_issue"));
        assertTrue(sql.contains("reception_interval_id"));
        assertTrue(sql.contains("SEQUENCE_GAP") || sql.contains("issue_type"));
        assertTrue(sql.contains("issue_status"));
        assertFalse(sql.matches("(?s).*\\bDROP\\s+(TABLE|COLUMN)\\b.*"));
    }
}