优化
This commit is contained in:
+4
-1
@@ -642,7 +642,10 @@ public class DispatchAggregatePersistenceTest {
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(service,"evidence",dispatchEvidence);
|
||||
var profilePhotos=mock(com.baiyue.lastleg.fleet.photo.FleetResourcePhotoService.class);
|
||||
when(profilePhotos.current(any(),anyLong())).thenReturn(new com.baiyue.lastleg.fleet.photo.FleetResourcePhotoModels.Detail(0,null));
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(service,"masterPhotos",new DispatchMasterPhotoService(profilePhotos,dispatchEvidence));
|
||||
var masterPhotos=org.mockito.Mockito.spy(new DispatchMasterPhotoService(profilePhotos,dispatchEvidence));
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(masterPhotos,"loadingPhotos",mock(com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.class));
|
||||
org.mockito.Mockito.doNothing().when(masterPhotos).populateLoading(anyLong(),anyString(),any());
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(service,"masterPhotos",masterPhotos);
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(service,"ownedBusinessOwnership",ownedBusinessOwnership);
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(gateway,"workflow",service);
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(service,"appointments",new DispatchAppointmentAllocations(mock(com.baiyue.lastleg.appointmentwork.AppointmentWorkDispatchPort.class)));
|
||||
|
||||
+70
-4
@@ -30,6 +30,68 @@ import static org.mockito.ArgumentMatchers.*;
|
||||
|
||||
/** 装车后五框门禁、保存发车共同事务及跨端竞争使用真实单据和版本。 */
|
||||
class DispatchLoadingDeparturePersistenceTest {
|
||||
/** 零扫码退回后换资源,旧凭证失效与资源保存原子提交;重审自动带入新资料供两端共用。 */
|
||||
@Test void changedResourcesInvalidateOldDocumentsAndReapprovalImportsNewEvidence() throws Exception {
|
||||
authorize();var f=new Fixture(false);long id=f.f.repository.find(f.number).getId();
|
||||
for(int i=0;i<5;i++)f.bind(i,f.f.actor);
|
||||
var old=f.photos.read(id);assertThat(DispatchLoadingDocumentService.complete(old.photos())).isTrue();
|
||||
var master=(DispatchMasterPhotoService)org.springframework.test.util.ReflectionTestUtils.getField(f.f.service,"masterPhotos");
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(master,"loadingPhotos",f.photos);
|
||||
doCallRealMethod().when(master).populateLoading(anyLong(),anyString(),any());
|
||||
var evidence=(com.baiyue.lastleg.dispatch.gateway.DispatchEvidenceGateway)org.springframework.test.util.ReflectionTestUtils.getField(f.f.service,"evidence");
|
||||
when(evidence.download(anyLong(),any(),anyLong())).thenReturn(new byte[]{1,2,3});
|
||||
var nextId=new java.util.concurrent.atomic.AtomicLong(3000);
|
||||
when(f.files.upload(eq(id),any(),eq(f.f.actor.operatorId()),any())).thenAnswer(call->new OwnedBusinessFileGateway.Evidence(nextId.incrementAndGet(),"new.png","image/png",3,"2026-10-26T00:00:00Z"));
|
||||
var returned=f.f.tx.execute(s->f.f.service.returnToReview(f.f.actor,f.number,new DispatchCommands.ReturnToReview(f.version,"return-change-resources","更换车辆司机")));
|
||||
var input=f.f.configured("new-resources",List.of());var evidenceInput=input.driver().evidence();
|
||||
var vehicle=new DispatchCommands.Vehicle(ResourceMode.EXTERNAL,null,"NEW-TRUCK","新承运商",input.vehicle().capacity(),List.of(111L));
|
||||
var driver=new DispatchCommands.Driver(ResourceMode.EXTERNAL,null,"新司机","987654321",new DriverEvidence("NEW-LICENSE",evidenceInput.licenseExpiresOn(),List.of(222L),evidenceInput.expectedTaskEndAt(),List.of(333L)));
|
||||
var request=new DispatchCommands.Update(returned.recordVersion(),"change-resources",vehicle,driver,input.plannedDepartureAt(),null,null,null);
|
||||
var previousResources=f.f.repository.find(f.number).getResourcesJson();
|
||||
assertThatThrownBy(()->f.f.tx.execute(s->{f.f.service.update(f.f.actor,f.number,request);throw new IllegalStateException("模拟后续保存失败");})).hasMessage("模拟后续保存失败");
|
||||
assertThat(f.photos.read(id)).isEqualTo(old);
|
||||
assertThat(f.f.repository.find(f.number).getResourcesJson()).isEqualTo(previousResources);
|
||||
var updated=f.f.tx.execute(s->f.f.service.update(f.f.actor,f.number,request));
|
||||
var invalidated=f.photos.read(id);assertThat(invalidated.recordVersion()).isEqualTo("6");
|
||||
assertThat(invalidated.photos()).containsExactlyElementsOf(old.photos().subList(2,5));
|
||||
assertThat(DispatchLoadingDocumentService.complete(invalidated.photos())).isFalse();
|
||||
assertThat(f.f.tx.execute(s->f.f.service.update(f.f.actor,f.number,request)).replayed()).isTrue();
|
||||
assertThat(f.photos.read(id)).isEqualTo(invalidated);
|
||||
assertThat(f.f.db.queryForObject("SELECT snapshot_json FROM ll_fleet_owned_business_history WHERE dispatch_id=? AND record_version=5",String.class,id)).contains("1000","1001");
|
||||
f.f.prepareAppointmentNumbers(f.number);
|
||||
var submitted=f.f.tx.execute(s->f.f.service.submitReview(f.f.actor,f.number,new DispatchCommands.SubmitReview(updated.recordVersion(),"resubmit-changed",null)));
|
||||
var reviewed=f.f.tx.execute(s->f.f.service.review(f.f.actor,f.number,false,new DispatchCommands.ReviewCommand(submitted.recordVersion(),"dispatch-changed",Decision.APPROVED,null,null)));
|
||||
f.f.tx.execute(s->f.f.service.review(f.f.actor,f.number,true,new DispatchCommands.ReviewCommand(reviewed.recordVersion(),"loading-changed",Decision.APPROVED,null,null)));
|
||||
var admin=f.documents.get(f.f.actor,f.number);var pda=f.documents.get(new Actor("picker",ActorMode.PDA,"9"),f.number);
|
||||
assertThat(admin.photos()).isEqualTo(pda.photos()).hasSize(5);assertThat(admin.complete()).isTrue();
|
||||
assertThat(admin.photos().stream().map(p->p.fileId())).containsExactlyInAnyOrder("3001","3002","1002","1003","1004");
|
||||
verify(evidence).download(id,com.baiyue.lastleg.dispatch.gateway.DispatchEvidenceGateway.Kind.DRIVER,222L);
|
||||
verify(evidence).download(id,com.baiyue.lastleg.dispatch.gateway.DispatchEvidenceGateway.Kind.VEHICLE,111L);
|
||||
assertThatThrownBy(()->f.f.tx.execute(s->f.documents.bind(f.f.actor,f.number,Slot.LOADING_SCENE,new BindPhoto("5","stale-before-change","1000")))).hasMessageContaining("其他操作更新");
|
||||
f.f.tx.execute(s->f.f.service.review(f.f.actor,f.number,true,new DispatchCommands.ReviewCommand(reviewed.recordVersion(),"loading-changed",Decision.APPROVED,null,null)));
|
||||
verify(f.files,times(2)).upload(anyLong(),any(),anyString(),any());
|
||||
}
|
||||
@Test void importedFilesAreSharedAcrossActorsAndCountTowardDepartureWithoutDuplicateCopies() throws Exception {
|
||||
authorize();var f=new Fixture();long id=f.f.repository.find(f.number).getId();
|
||||
var image=new org.springframework.mock.web.MockMultipartFile("file","plate.png","image/png",new byte[]{1,2,3});
|
||||
when(f.files.upload(eq(id),any(),eq("operator"),any())).thenAnswer(call->new OwnedBusinessFileGateway.Evidence(
|
||||
call.getArgument(1)==com.baiyue.lastleg.fleet.ownedbusiness.model.OwnedBusinessModels.PhotoSlot.LOADING_SCENE?2000:2001,"copied.png","image/png",3,"2026-10-26T00:00:00Z"));
|
||||
f.f.tx.executeWithoutResult(s->{
|
||||
f.photos.importIfEmpty(id,"operator",Slot.LOADING_SCENE,List.of(image));
|
||||
f.photos.importIfEmpty(id,"operator",Slot.LOADING_LIST,List.of(image));
|
||||
});
|
||||
var admin=f.documents.get(f.f.actor,f.number);
|
||||
var pda=f.documents.get(new Actor("picker",ActorMode.PDA,"9"),f.number);
|
||||
assertThat(pda.photos()).isEqualTo(admin.photos()).hasSize(2);
|
||||
assertThat(admin.complete()).isFalse();assertThat(admin.recordVersion()).isEqualTo("2");
|
||||
f.f.tx.executeWithoutResult(s->f.photos.importIfEmpty(id,"operator",Slot.LOADING_SCENE,List.of(image)));
|
||||
verify(f.files,times(2)).upload(anyLong(),any(),anyString(),any());
|
||||
assertThat(f.photos.read(id).recordVersion()).isEqualTo("2");
|
||||
f.f.tx.execute(s->f.service.complete(f.f.actor,f.number,f.request("complete-imported")));
|
||||
f.bind(2,f.f.actor);f.bind(3,f.f.actor);
|
||||
assertThat(f.bind(4,new Actor("picker",ActorMode.PDA,"9")).stage()).isEqualTo("DELIVERING");
|
||||
verify(f.delivery,times(1)).prepareForDeparture(any(),any(),anyString());
|
||||
}
|
||||
/** 每例恢复隔离身份,不影响其他服务权限测试。 */
|
||||
@AfterEach void clearSecurity(){SecurityContextHolder.clearContext();}
|
||||
|
||||
@@ -221,11 +283,15 @@ class DispatchLoadingDeparturePersistenceTest {
|
||||
final DispatchPdaWorkflowService sourceWorkflow=mock(DispatchPdaWorkflowService.class);
|
||||
final DispatchLoadingDepartureService service;final DispatchLoadingDocumentService documents;final String number;final long version;final String manifest;
|
||||
final List<LoadingMeasurement> measurements;
|
||||
final OwnedBusinessFileGateway files=mock(OwnedBusinessFileGateway.class);
|
||||
final DispatchLoadingPhotoAdapter photos;
|
||||
/** 创建两客户货物并走真实两级审核、真实拣货归属,不伪造已装车状态。 */
|
||||
Fixture() throws Exception {
|
||||
Fixture() throws Exception { this(true); }
|
||||
/** 零扫码夹具用于退回重审;其余用例继续真实拣货。 */
|
||||
Fixture(boolean picked) throws Exception {
|
||||
var created=f.tx.execute(s->f.service.create(f.actor,f.configured("create",List.of(f.source(1,"101",501,"ONT8",3),f.source(2,"202",502,"LAX9",5)))));
|
||||
number=created.dispatchNo();version=f.approve(created).recordVersion();
|
||||
f.picked(1,"101",501,3);f.picked(2,"202",502,5);f.db.update("UPDATE ll_dispatch_order SET picked_package_count=8");
|
||||
if(picked) {f.picked(1,"101",501,3);f.picked(2,"202",502,5);f.db.update("UPDATE ll_dispatch_order SET picked_package_count=8");}
|
||||
f.db.execute("ALTER TABLE ll_order ADD detained INT DEFAULT 0");
|
||||
var preview=f.tx.execute(s->f.service.loading(f.actor,number));manifest=preview.manifestHash();
|
||||
measurements=preview.pallets().stream().map(p->new LoadingMeasurement(p.warehousePalletId(),1,BigDecimal.ONE,BigDecimal.ONE,p.deliveryIndex())).toList();
|
||||
@@ -259,9 +325,9 @@ class DispatchLoadingDeparturePersistenceTest {
|
||||
f.db.execute(matcher.group().replace(" JSON"," LONGTEXT").replace(" COLLATE utf8mb4_bin","").replaceFirst("(?s) ENGINE=InnoDB.*?;$",";"));
|
||||
}
|
||||
var records=new OwnedBusinessRepository(f.session.getMapper(OwnedBusinessMapper.class),mock(OwnedBusinessQueryMapper.class));
|
||||
var codec=new OwnedBusinessSupport(f.json);var files=mock(OwnedBusinessFileGateway.class);
|
||||
var codec=new OwnedBusinessSupport(f.json);
|
||||
when(files.metadata(anyLong(),any(),anyLong())).thenAnswer(call->new OwnedBusinessFileGateway.Evidence(call.getArgument(2),"loading.png","image/png",12,"2026-10-21T00:00:00Z"));
|
||||
var photos=new DispatchLoadingPhotoAdapter(records,new OwnedBusinessCommandService(records,codec),new OwnedBusinessProjection(codec),codec,files);
|
||||
photos=new DispatchLoadingPhotoAdapter(records,new OwnedBusinessCommandService(records,codec),new OwnedBusinessProjection(codec),codec,files);
|
||||
service=new DispatchLoadingDepartureService(f.service,delivery,departure,ledger,hashes,photos);
|
||||
documents=new DispatchLoadingDocumentService(f.service,service,photos);
|
||||
}
|
||||
|
||||
+50
@@ -14,6 +14,56 @@ import static org.mockito.Mockito.*;
|
||||
|
||||
/** 自动带入不复用跨排车文件ID,也不覆盖已有当趟照片。 */
|
||||
class DispatchMasterPhotoServiceTest {
|
||||
/** 只失效来源变化的类别;相同来源重审、无关资料修改和文件重排保留现场替换。 */
|
||||
@Test void resourceChangesInvalidateOnlyAffectedCategories() {
|
||||
var loading=mock(com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.class);
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(service,"loadingPhotos",loading);
|
||||
var vehicle=new VehicleSnapshot(ResourceMode.MASTER,1L,"TEST",null,"IN_SERVICE",null,List.of(101L,102L));
|
||||
var driver=new DriverSnapshot(ResourceMode.MASTER,2L,"司机","电话",new DriverEvidence("LICENSE",null,List.of(8L),null,List.of(90L),8L));
|
||||
var original=new Resources(vehicle,driver,null);
|
||||
service.invalidateLoading(9,"op",original,new Resources(new VehicleSnapshot(ResourceMode.MASTER,1L,"TEST","新承运商","IN_SERVICE",new Capacity(10,null,null),List.of(102L,101L)),
|
||||
new DriverSnapshot(ResourceMode.MASTER,2L,"司机","新电话",new DriverEvidence("LICENSE",null,List.of(8L),java.time.Instant.now(),List.of(91L),8L)),null));
|
||||
verifyNoInteractions(loading);
|
||||
var changedVehicle=new VehicleSnapshot(ResourceMode.MASTER,3L,"OTHER",null,"IN_SERVICE",null,List.of(103L));
|
||||
service.invalidateLoading(9,"op",original,new Resources(changedVehicle,driver,null));
|
||||
verify(loading).invalidateResourcePhotos(9,"op",java.util.Set.of(com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.Slot.LOADING_LIST));
|
||||
clearInvocations(loading);
|
||||
var renewedDriver=new DriverSnapshot(ResourceMode.MASTER,2L,"司机","电话",new DriverEvidence("LICENSE",null,List.of(9L),null,List.of(90L),9L));
|
||||
service.invalidateLoading(9,"op",original,new Resources(vehicle,renewedDriver,null));
|
||||
verify(loading).invalidateResourcePhotos(9,"op",java.util.Set.of(com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.Slot.LOADING_SCENE));
|
||||
clearInvocations(loading);
|
||||
service.invalidateLoading(9,"op",original,new Resources(null,null,null));
|
||||
verify(loading).invalidateResourcePhotos(9,"op",java.util.Set.of(com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.Slot.LOADING_SCENE,
|
||||
com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.Slot.LOADING_LIST));
|
||||
}
|
||||
@Test void importsFrozenLicenseAndVehicleIntoSharedLoadingCategoriesWithoutDriverPortrait() throws Exception {
|
||||
var loading=mock(com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.class);
|
||||
var fleet=mock(com.baiyue.lastleg.fleet.trip.FleetTripExecutionService.class);
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(service,"loadingPhotos",loading);
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(service,"fleet",fleet);
|
||||
when(loading.read(9)).thenReturn(new com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.State("0",List.of()));
|
||||
var license=new com.baiyue.lastleg.fleet.driver.DriverModels.File("8","license.pdf","application/pdf",8);
|
||||
when(fleet.dispatchDriverLicense(2,8)).thenReturn(new com.baiyue.lastleg.fleet.driver.DriverModels.Download(license,"%PDF-1.4".getBytes()));
|
||||
when(evidence.metadata(9,DispatchEvidenceGateway.Kind.VEHICLE,101)).thenReturn(new DispatchEvidenceGateway.File(101L,"plate.png","image/png",3));
|
||||
when(evidence.download(9,DispatchEvidenceGateway.Kind.VEHICLE,101)).thenReturn(new byte[]{1,2,3});
|
||||
var resources=new Resources(new VehicleSnapshot(ResourceMode.MASTER,1L,"TEST",null,"IN_SERVICE",null,List.of(101L)),
|
||||
new DriverSnapshot(ResourceMode.MASTER,2L,"司机","电话",new DriverEvidence(null,null,List.of(8L),null,List.of(102L),8L)),null);
|
||||
service.populateLoading(9,"op",resources);
|
||||
@SuppressWarnings("unchecked") var files=(ArgumentCaptor<List<MultipartFile>>)(ArgumentCaptor<?>)ArgumentCaptor.forClass(List.class);
|
||||
verify(loading).importIfEmpty(eq(9L),eq("op"),eq(com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.Slot.LOADING_SCENE),files.capture());
|
||||
assertThat(files.getValue()).hasSize(1);assertThat(files.getValue().get(0).getBytes()).isEqualTo("%PDF-1.4".getBytes());
|
||||
verify(loading).importIfEmpty(eq(9L),eq("op"),eq(com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.Slot.LOADING_LIST),files.capture());
|
||||
assertThat(files.getValue().get(0).getOriginalFilename()).isEqualTo("plate.png");
|
||||
verify(evidence,never()).download(anyLong(),eq(DispatchEvidenceGateway.Kind.DRIVER_PHOTO),anyLong());
|
||||
verifyNoInteractions(photos);
|
||||
var slots=com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.Slot.values();
|
||||
var saved=java.util.Arrays.stream(slots).map(slot->new com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.Photo(slot,"LOADING","900"+slot.ordinal(),"saved.png","image/png","3",null,null)).toList();
|
||||
when(loading.read(9)).thenReturn(new com.baiyue.lastleg.fleet.ownedbusiness.port.DispatchLoadingPhotoPort.State("5",saved));
|
||||
clearInvocations(loading,fleet,evidence);
|
||||
service.populateLoading(9,"op",resources);
|
||||
verify(loading,never()).importIfEmpty(anyLong(),anyString(),any(),anyList());
|
||||
verifyNoInteractions(fleet,evidence);
|
||||
}
|
||||
final FleetResourcePhotoService photos=mock(FleetResourcePhotoService.class);
|
||||
final DispatchEvidenceGateway evidence=mock(DispatchEvidenceGateway.class);
|
||||
final DispatchMasterPhotoService service=new DispatchMasterPhotoService(photos,evidence);
|
||||
|
||||
+17
@@ -11,6 +11,23 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
/** 审核两端共用真实持久主单,驳回回客服且不能复用上一轮批准。 */
|
||||
class DispatchReviewWorkflowPersistenceTest {
|
||||
@Test void approvedLoadingReviewImportsOnceAndCopyFailureRollsBackApproval() throws Exception {
|
||||
var f=new DispatchAggregatePersistenceTest.Fixture();
|
||||
var created=f.tx.execute(s->f.service.create(f.actor,f.configured("copy-create",List.of(f.source(1,"101",501,"ONT8",3)))));
|
||||
var submitted=submit(f,created,"copy-submit");
|
||||
var approved=review(f,f.actor,submitted,false,"copy-dispatch",Decision.APPROVED,null);
|
||||
var master=org.mockito.Mockito.mock(DispatchMasterPhotoService.class);
|
||||
org.springframework.test.util.ReflectionTestUtils.setField(f.service,"masterPhotos",master);
|
||||
org.mockito.Mockito.doThrow(new IllegalStateException("文件服务不可用")).doNothing().when(master).populateLoading(org.mockito.ArgumentMatchers.anyLong(),org.mockito.ArgumentMatchers.anyString(),org.mockito.ArgumentMatchers.any());
|
||||
assertThatThrownBy(()->review(f,f.actor,approved,true,"copy-loading",Decision.APPROVED,null)).hasMessageContaining("文件服务不可用");
|
||||
assertThat(f.repository.find(created.dispatchNo()).getStage()).isEqualTo("BEFORE_LOADING");
|
||||
assertThat(f.repository.find(created.dispatchNo()).getReviewState()).isEqualTo("LOADING_PENDING");
|
||||
var loaded=review(f,f.actor,approved,true,"copy-loading",Decision.APPROVED,null);
|
||||
assertThat(loaded.stage()).isEqualTo(Stage.LOADING);
|
||||
org.mockito.Mockito.clearInvocations(master);
|
||||
assertThat(review(f,f.actor,approved,true,"copy-loading",Decision.APPROVED,null).recordVersion()).isEqualTo(loaded.recordVersion());
|
||||
org.mockito.Mockito.verifyNoInteractions(master);
|
||||
}
|
||||
/** 取货复用同轮两级审核与驳回重提,不创建仓内拣货任务。 */
|
||||
@Test void pickupUsesBothReviewsAndRejectsSkippingOrStaleApproval() throws Exception {
|
||||
var f=new DispatchAggregatePersistenceTest.Fixture();
|
||||
|
||||
+12
-3
@@ -11,9 +11,18 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
class OwnedBusinessFileGatewayTest {
|
||||
/** 图片文本伪装、PDF及空内容均须在File调用前拒绝。 */
|
||||
@Test void invalidImageSignaturesAndMimeAreRejected() {
|
||||
assertThrows(BizException.class,()->HttpOwnedBusinessFileGateway.validate(new OwnedBusinessFileGateway.Upload("x.png","image/png","not-image".getBytes())));
|
||||
assertThrows(BizException.class,()->HttpOwnedBusinessFileGateway.validate(new OwnedBusinessFileGateway.Upload("x.pdf","application/pdf","%PDF".getBytes())));
|
||||
assertThrows(BizException.class,()->HttpOwnedBusinessFileGateway.validate(new OwnedBusinessFileGateway.Upload("x.jpg","image/jpeg",new byte[0])));
|
||||
assertThrows(BizException.class,()->HttpOwnedBusinessFileGateway.validate(PhotoSlot.LOADING_SCENE,new OwnedBusinessFileGateway.Upload("x.png","image/png","not-image".getBytes())));
|
||||
assertThrows(BizException.class,()->HttpOwnedBusinessFileGateway.validate(PhotoSlot.LOADING_SCENE,new OwnedBusinessFileGateway.Upload("x.pdf","application/pdf","%PDF".getBytes())));
|
||||
assertThrows(BizException.class,()->HttpOwnedBusinessFileGateway.validate(PhotoSlot.LOADING_SCENE,new OwnedBusinessFileGateway.Upload("x.jpg","image/jpeg",new byte[0])));
|
||||
}
|
||||
@Test void onlyDriverLicenseAcceptsPdfAndChecksMetadataScope() {
|
||||
var pdf=new OwnedBusinessFileGateway.Upload("license.pdf","application/pdf","%PDF-1.4".getBytes());
|
||||
assertDoesNotThrow(()->HttpOwnedBusinessFileGateway.validate(PhotoSlot.LOADING_SCENE,pdf));
|
||||
for(var slot:PhotoSlot.values())if(slot!=PhotoSlot.LOADING_SCENE)
|
||||
assertThrows(BizException.class,()->HttpOwnedBusinessFileGateway.validate(slot,pdf));
|
||||
var meta=new HttpOwnedBusinessFileGateway.Metadata(9L,0L,"OVERSEAS_DISPATCH_LOADING_PHOTO","1","license.pdf","application/pdf",8L,LocalDateTime.now());
|
||||
assertEquals(9,HttpOwnedBusinessFileGateway.verified(new HttpOwnedBusinessFileGateway.Envelope("200",meta),1,PhotoSlot.LOADING_SCENE,9L).fileId());
|
||||
assertThrows(BizException.class,()->HttpOwnedBusinessFileGateway.verified(new HttpOwnedBusinessFileGateway.Envelope("200",meta),1,PhotoSlot.LOADING_LIST,9L));
|
||||
}
|
||||
/** 同一原dispatch内部ID、平台0与分类都匹配才接受元数据。 */
|
||||
@Test void metadataCannotCrossCustomerDispatchOrCategory() {
|
||||
|
||||
Reference in New Issue
Block a user