test: prepare destination appointments in dispatch review fixtures

This commit is contained in:
2026-10-23 01:08:49 +08:00
parent eb82401afa
commit 2dbf0cb248
2 changed files with 5 additions and 0 deletions
@@ -29,6 +29,7 @@ class DispatchLoadingEligibilityPersistenceTest {
@org.junit.jupiter.api.Test void preArrangementRemainsAllowedButReviewsCannotApproveUnconfirmedAppointments() throws Exception { @org.junit.jupiter.api.Test void preArrangementRemainsAllowedButReviewsCannotApproveUnconfirmedAppointments() throws Exception {
var f=new DispatchAggregatePersistenceTest.Fixture(); var f=new DispatchAggregatePersistenceTest.Fixture();
var created=f.tx.execute(t->f.service.create(f.actor,f.configured("review-appointment",List.of(f.source(1,"101",501,"ONT8",3))))); var created=f.tx.execute(t->f.service.create(f.actor,f.configured("review-appointment",List.of(f.source(1,"101",501,"ONT8",3)))));
f.prepareAppointmentNumbers(created.dispatchNo());
var provider=mock(com.baiyue.lastleg.appointmentwork.AppointmentWorkDispatchPort.class); var provider=mock(com.baiyue.lastleg.appointmentwork.AppointmentWorkDispatchPort.class);
ReflectionTestUtils.setField(f.service,"appointments",new DispatchAppointmentAllocations(provider)); ReflectionTestUtils.setField(f.service,"appointments",new DispatchAppointmentAllocations(provider));
when(provider.reviewBlockReason(anyString(),any(),any())).thenReturn("预约收货时间尚未确认"); when(provider.reviewBlockReason(anyString(),any(),any())).thenReturn("预约收货时间尚未确认");
@@ -51,6 +52,9 @@ class DispatchLoadingEligibilityPersistenceTest {
when(provider.reviewBlockReason(anyString(),any(),any())).thenReturn(null); when(provider.reviewBlockReason(anyString(),any(),any())).thenReturn(null);
f.tx.execute(t->f.service.review(f.actor,created.dispatchNo(),true,new DispatchCommands.ReviewCommand(reviewed.recordVersion(),"loading-pass",com.baiyue.lastleg.dispatch.port.DispatchTypes.Decision.APPROVED,null,null))); f.tx.execute(t->f.service.review(f.actor,created.dispatchNo(),true,new DispatchCommands.ReviewCommand(reviewed.recordVersion(),"loading-pass",com.baiyue.lastleg.dispatch.port.DispatchTypes.Decision.APPROVED,null,null)));
when(provider.reviewEvidence(anyString())).thenReturn(List.of()); when(provider.reviewEvidence(anyString())).thenReturn(List.of());
// 本车未绑定该外部预约;改动实际运输时间,验证本车审核依据失效而非依赖无关预约。
f.db.update("UPDATE ll_dispatch_order SET estimated_arrival_at=? WHERE dispatch_no=?",
f.repository.find(created.dispatchNo()).getPlannedDepartureAt().plusHours(1),created.dispatchNo());
assertThatThrownBy(()->f.tx.execute(t->{f.service.requireReviewAppointment(f.repository.find(created.dispatchNo()));return null;})).hasMessageContaining("原审核依据失效"); assertThatThrownBy(()->f.tx.execute(t->{f.service.requireReviewAppointment(f.repository.find(created.dispatchNo()));return null;})).hasMessageContaining("原审核依据失效");
when(provider.reviewBlockReason(anyString(),any(),any())).thenReturn("预约收货时间尚未确认"); when(provider.reviewBlockReason(anyString(),any(),any())).thenReturn("预约收货时间尚未确认");
var pda=new DispatchContracts.Actor("picker",ActorMode.PDA,"9"); var pda=new DispatchContracts.Actor("picker",ActorMode.PDA,"9");
@@ -20,6 +20,7 @@ class DispatchPdaReadPersistenceTest {
try { try {
var f=new DispatchAggregatePersistenceTest.Fixture(); var f=new DispatchAggregatePersistenceTest.Fixture();
var created=f.tx.execute(s->f.service.create(f.actor,f.configured("pending-read",List.of(f.source(1,"101",501,"ONT8",3))))); var created=f.tx.execute(s->f.service.create(f.actor,f.configured("pending-read",List.of(f.source(1,"101",501,"ONT8",3)))));
f.prepareAppointmentNumbers(created.dispatchNo());
f.db.execute("CREATE TABLE ll_inventory_position(id BIGINT,customer_id VARCHAR(64),balance_id BIGINT,pallet_id BIGINT,overseas_warehouse_id VARCHAR(64),available_packages BIGINT,hold_packages BIGINT,allocated_packages BIGINT,picked_packages BIGINT)"); f.db.execute("CREATE TABLE ll_inventory_position(id BIGINT,customer_id VARCHAR(64),balance_id BIGINT,pallet_id BIGINT,overseas_warehouse_id VARCHAR(64),available_packages BIGINT,hold_packages BIGINT,allocated_packages BIGINT,picked_packages BIGINT)");
var config=new MybatisConfiguration();config.setMapUnderscoreToCamelCase(true);config.addMapper(DispatchWholePdaReadMapper.class); var config=new MybatisConfiguration();config.setMapUnderscoreToCamelCase(true);config.addMapper(DispatchWholePdaReadMapper.class);
var factory=new MybatisSqlSessionFactoryBean();factory.setDataSource(f.db.getDataSource());factory.setConfiguration(config);factory.afterPropertiesSet(); var factory=new MybatisSqlSessionFactoryBean();factory.setDataSource(f.db.getDataSource());factory.setConfiguration(config);factory.afterPropertiesSet();