feat(appointment): integrate work calendar and stable cargo batches
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
package com.baiyue.lastleg.contract;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.nio.file.*;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class AppointmentWorkSchemaContractTest {
|
||||
@Test void completeWorkAndPhysicalAllocationSchemaMatchesBothInitializationEntries() throws Exception {
|
||||
String source=Files.readString(Path.of("src/main/resources/db/appointment-work.sql"));
|
||||
for(String path:List.of("src/main/resources/db/lastleg.sql","../deploy/sql/海外区域统一增量-MySQL8.sql")) {
|
||||
String target=Files.readString(Path.of(path));
|
||||
for(String table:List.of("ll_dispatch_appointment_allocation","ll_appointment_work_commitment","ll_appointment_work_guard","ll_appointment_work","ll_appointment_work_history"))
|
||||
assertEquals(definition(source,table),definition(target,table),path+" differs for "+table);
|
||||
assertTrue(target.contains("INSERT INTO ll_appointment_work_guard(id,initialized) SELECT 1,FALSE"));
|
||||
}
|
||||
assertTrue(source.contains("scan_cursor VARCHAR(128)"));
|
||||
assertTrue(source.contains("PRIMARY KEY(dispatch_item_id,batch_key,source_key,destination_key)"));
|
||||
}
|
||||
@Test void overseasInitializationReportsSuccessOnlyAfterEveryTableAndSeed() throws Exception {
|
||||
String sql=Files.readString(Path.of("../deploy/sql/海外区域统一增量-MySQL8.sql"));
|
||||
long count=Pattern.compile("(?m)^CREATE TABLE\\s+").matcher(sql).results().count();
|
||||
String pass="SELECT 'PASS' AS initialization_status, 'OVERSEAS' AS region, "+count+" AS initialized_tables;";
|
||||
assertTrue(sql.stripTrailing().endsWith(pass));
|
||||
assertEquals(1,Pattern.compile("SELECT 'PASS' AS initialization_status").matcher(sql).results().count());
|
||||
String reset=Files.readString(Path.of("../deploy/sql/reset-test-fba-appointments.sql"));
|
||||
assertTrue(reset.indexOf("CALL assert_test_appointment_reset_preconditions()")<reset.indexOf("DROP TABLE ll_inbound_fba_appointment_item"));
|
||||
assertTrue(reset.contains("'ll_fba_appointment_command','ll_appointment_cargo_verification'"));
|
||||
}
|
||||
private String definition(String sql,String table) {
|
||||
var match=Pattern.compile("CREATE TABLE(?: IF NOT EXISTS)? "+Pattern.quote(table)+" \\([\\s\\S]*?\\) ENGINE=InnoDB[^\\r\\n]*;").matcher(sql);
|
||||
assertTrue(match.find(),"Missing "+table);
|
||||
String result=match.group().replace("CREATE TABLE IF NOT EXISTS","CREATE TABLE").replace("\r\n","\n");
|
||||
assertFalse(match.find(),"Duplicate "+table);return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user