feat(fleet): match cargo stops when binding dispatches

This commit is contained in:
2026-10-09 15:04:51 +08:00
parent 2ec5414b39
commit c4a7c2a22d
3 changed files with 51 additions and 1 deletions
@@ -0,0 +1,25 @@
package com.baiyue.lastleg.fleet.trip;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.*;
class FleetTripMatchedStopsTest {
private FleetExecutionModels.Cargo cargo(String key, String label) {
return new FleetExecutionModels.Cargo("DP-1", "A", "1", "2", "PLT-1", 1, key, label);
}
@Test void replacesOnlyInitialPlaceholderAndDeduplicatesByIdentity() {
var origin = new FleetTripModels.Stop("起运仓", null, null);
var result = FleetTripService.matchedStops(List.of(origin, new FleetTripModels.Stop("待确定卸货点1", null, null)),
List.of(cargo("FBA:ACY2", "ACY2"), cargo("FBA:ACY2", "ACY2")));
assertThat(result).containsExactly(origin, new FleetTripModels.Stop("ACY2", null, "FBA:ACY2"));
}
@Test void preservesExistingStopIndexesAndAppendsDifferentIdentityEvenWhenNamesMatch() {
var existing = List.of(new FleetTripModels.Stop("起点", null, null), new FleetTripModels.Stop("ACY2", null, "FBA:ACY2"));
var result = FleetTripService.matchedStops(existing, List.of(cargo("PRIVATE:OTHER", "ACY2")));
assertThat(result.subList(0,2)).isEqualTo(existing);
assertThat(result.get(2).destinationKey()).isEqualTo("PRIVATE:OTHER");
}
@Test void rejectsMissingIdentityWithoutUsingDisplayNameAsKey() {
assertThatThrownBy(() -> FleetTripService.matchedStops(List.of(new FleetTripModels.Stop("起点", null, null)), List.of(cargo(null,"ACY2"))))
.hasMessageContaining("目的地未确认");
}
}