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.*")); } }