fix: preserve overseas pallet identity

This commit is contained in:
2026-08-25 08:12:58 +08:00
parent 73d206e3f3
commit 85a288e4f2
4 changed files with 72 additions and 10 deletions
@@ -0,0 +1,61 @@
package com.baiyue.lastleg.inboundplan.pda.gateway;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestClient;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
class HttpWarehouseResourceGatewayTest {
private HttpWarehouseResourceGateway gateway;
private MockRestServiceServer server;
@BeforeEach
void setUp() {
RestClient.Builder builder = RestClient.builder();
server = MockRestServiceServer.bindTo(builder).build();
gateway = new HttpWarehouseResourceGateway();
ReflectionTestUtils.setField(gateway, "restClientBuilder", builder);
ReflectionTestUtils.setField(gateway, "baseUrl", "http://warehouse");
ReflectionTestUtils.setField(gateway, "internalToken", "test-token");
gateway.initializeClient();
}
@Test
void resolveMapsCanonicalPalletIdInsteadOfSilentlyUsingZero() {
server.expect(requestTo("http://warehouse/internal/v1/warehouse-pallets/resolve/PAL-1"))
.andRespond(withSuccess("""
{"code":"200","data":{"palletId":2092040891261427713,"palletCode":"PAL-1",
"warehouseId":2092040869757231105,"locationId":2092040891076878337,
"status":"IDLE","fbaWarehouseCode":"ABE3","version":3}}
""", MediaType.APPLICATION_JSON));
WarehouseResourceGateway.WarehousePalletReference result = gateway.resolvePallet("PAL-1");
assertThat(result.palletId()).isEqualTo(2092040891261427713L);
assertThat(result.warehouseId()).isEqualTo(2092040869757231105L);
assertThat(result.locationId()).isEqualTo(2092040891076878337L);
server.verify();
}
@Test
void ensureDropshipStillMapsWarehouseEntityId() {
server.expect(requestTo("http://warehouse/internal/v1/warehouse-pallets/ensure-dropship"))
.andRespond(withSuccess("""
{"code":"200","data":{"id":2092040891261427713,"palletCode":"PAL-DROP",
"warehouseId":2092040869757231105,"locationId":2092040891076878337,
"status":"IDLE","fbaWarehouseCode":null,"version":1}}
""", MediaType.APPLICATION_JSON));
WarehouseResourceGateway.WarehousePalletReference result =
gateway.ensureDropshipPallet("2092040041967063041", 2092040869757231105L, "DROP-1");
assertThat(result.palletId()).isEqualTo(2092040891261427713L);
server.verify();
}
}