fix(fleet): hash pooled dispatch source keys without object cast
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
package com.baiyue.lastleg.fleet.trip;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import java.util.List;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class FleetBookingRequestHashTest {
|
||||
final FleetBookingService service = new FleetBookingService(null, null, null, null, null, null,
|
||||
new ObjectMapper().findAndRegisterModules(), null, null, null);
|
||||
|
||||
private String hash(Object value) { return ReflectionTestUtils.invokeMethod(service, "hash", value); }
|
||||
|
||||
@Test void incomingDispatchSourceKeyAcceptsArrayAndPreservesBookingAndCommandIdentity() {
|
||||
var source = List.of("FB202610210004", "pool-arrange-command");
|
||||
var digest = assertDoesNotThrow(() -> hash(source));
|
||||
assertEquals(64, digest.length());
|
||||
assertEquals(digest, hash(source));
|
||||
assertNotEquals(digest, hash(List.of("FB202610210005", "pool-arrange-command")));
|
||||
assertNotEquals(digest, hash(List.of("FB202610210004", "another-command")));
|
||||
assertNotEquals(digest, hash(List.of("pool-arrange-command", "FB202610210004")));
|
||||
}
|
||||
|
||||
@Test void bookingCommandsStillIgnoreReplayKeyAndTripVersionButRetainBookingVersion() {
|
||||
var digest = hash(new FleetBookingModels.Command(8L, 4L, "command-original", "TEST"));
|
||||
assertEquals(digest, hash(new FleetBookingModels.Command(9L, 4L, "command-replay", "TEST")));
|
||||
assertNotEquals(digest, hash(new FleetBookingModels.Command(8L, 5L, "command-original", "TEST")));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user