yeg
2026-09-05 7259e265b9237286996b09da03038ea5a133e1e0
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
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;
 
class Ticket13MigrationContractTest
{
    @Test
    void addsRecoverableSourceCursorsAndCollectorHistoryWithoutChangingEarlierTables()
    {
        String sql;
        try (InputStream stream = getClass().getClassLoader().getResourceAsStream(
                "db/migration/V21__natural_end_interval_backfill.sql"))
        {
            if (stream == null) throw new AssertionError("缺少 Ticket13 迁移");
            sql = new String(stream.readAllBytes(), StandardCharsets.UTF_8);
        }
        catch (Exception exception) { throw new AssertionError(exception); }
        assertTrue(sql.contains("t_test_backfill_cursor"));
        assertTrue(sql.contains("t_test_collector_sample"));
        assertTrue(sql.contains("protocol_metadata JSON"));
        assertTrue(sql.contains("reception_interval_id"));
        assertFalse(sql.matches("(?s).*\\bDROP\\s+(TABLE|COLUMN)\\b.*"));
    }
}