2026-08-19 16:24:02 +08:00
package com.baiyue.lastleg.inboundplan ;
import org.junit.jupiter.api.Test ;
import java.io.IOException ;
import java.nio.charset.StandardCharsets ;
import static org.junit.jupiter.api.Assertions.assertFalse ;
import static org.junit.jupiter.api.Assertions.assertTrue ;
class InboundPlanSchemaContractTest {
@Test
2026-08-20 18:02:38 +08:00
void planIsUniqueByCustomerAndSourceOrderWhileContainerCanBeShared () throws IOException {
2026-08-19 16:24:02 +08:00
try ( var stream = getClass (). getClassLoader (). getResourceAsStream ( "db/lastleg.sql" )) {
assertTrue ( stream != null , "lastleg schema must be available" );
String schema = new String ( stream . readAllBytes (), StandardCharsets . UTF_8 ). toLowerCase ();
2026-08-20 18:02:38 +08:00
assertTrue ( schema . contains ( "unique key uk_ll_inbound_plan_source_order (customer_id, source_order_id)" ));
assertTrue ( schema . contains ( "key idx_ll_inbound_plan_container (customer_id, container_no)" ));
assertFalse ( schema . contains ( "unique key uk_ll_inbound_plan_container" ));
2026-08-19 16:24:02 +08:00
assertTrue ( schema . contains ( "default 'pending_assignment'" ));
assertTrue ( schema . contains ( "required_package_count" ));
assertTrue ( schema . contains ( "planned_package_count" ));
assertTrue ( schema . contains ( "warehouse_resource_lock_id" ));
2026-09-11 00:06:57 +08:00
assertTrue ( schema . contains ( "ll_inbound_plan_pallet' and column_name='version'" ));
2026-08-19 16:24:02 +08:00
assertTrue ( schema . contains ( "create table if not exists ll_inbound_pda_task" ));
assertTrue ( schema . contains ( "create table if not exists ll_inbound_pda_operation" ));
assertTrue ( schema . contains ( "create table if not exists ll_inbound_pallet_merge" ));
assertTrue ( schema . contains ( "create table if not exists ll_inbound_fba_appointment" ));
2026-10-09 11:01:39 +08:00
assertTrue ( schema . contains ( "unique key uk_ll_fba_appointment_no (appointment_no)" ));
2026-08-20 18:22:20 +08:00
assertTrue ( schema . contains ( "expected_loading_at" ));
2026-10-09 11:01:39 +08:00
String appointment = schema . substring ( schema . indexOf ( "create table if not exists ll_inbound_fba_appointment (" ), schema . indexOf ( "create table if not exists ll_inbound_fba_appointment_item (" ));
assertFalse ( appointment . contains ( "customer_id" ));
String items = schema . substring ( schema . indexOf ( "create table if not exists ll_inbound_fba_appointment_item (" ));
assertTrue ( items . substring ( 0 , items . indexOf ( "engine=innodb" )). contains ( "customer_id varchar(128) not null" ));
2026-09-07 23:58:18 +08:00
assertTrue ( schema . contains ( "planned_arrival_date" ));
2026-09-17 17:37:29 +08:00
assertTrue ( schema . contains ( "creation_mode varchar(32)" ));
assertTrue ( schema . contains ( "modify column creation_mode varchar(32)" ));
2026-09-07 23:58:18 +08:00
assertTrue ( schema . contains ( "pallet_type" ));
assertTrue ( schema . contains ( "create table if not exists ll_order_command_record" ));
assertTrue ( schema . contains ( "create table if not exists ll_order_hold_history" ));
assertTrue ( schema . contains ( "create table if not exists ll_order_manual_node" ));
assertTrue ( schema . contains ( "create table if not exists ll_order_manual_node_history" ));
2026-08-19 16:24:02 +08:00
assertTrue ( schema . contains ( "create table if not exists ll_inbound_fba_appointment_item" ));
assertTrue ( schema . contains ( "fba_warehouse_code" ));
assertFalse ( schema . contains ( "cabinet_no" ));
}
}
}