fix(integration): read master data source pagination fields
This commit is contained in:
+2
-2
@@ -137,7 +137,7 @@ public final class LingxingWmsClient {
|
||||
if (request == null) throw badRequest();
|
||||
validatePagination(request.current(), request.size(), 1000);
|
||||
return execute("/openapi/v2/customer/list", pagination(request.current(), request.size()), context, Operation.CUSTOMERS,
|
||||
(data, metadata) -> mappedPage(data, request.current(), request.size(), "current", "size", false, metadata,
|
||||
(data, metadata) -> mappedPage(data, request.current(), request.size(), "page", "pageSize", false, metadata,
|
||||
row -> new Customer(requiredText(row,"customerCode",64), optionalText(row,"customerName"), optionalText(row,"status"))));
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public final class LingxingWmsClient {
|
||||
if (request == null) throw badRequest();
|
||||
validatePagination(request.current(), request.size(), 100);
|
||||
return execute("/openapi/v2/product/page", pagination(request.current(), request.size()), context, Operation.PRODUCTS,
|
||||
(data, metadata) -> mappedPage(data, request.current(), request.size(), "current", "size", false, metadata,
|
||||
(data, metadata) -> mappedPage(data, request.current(), request.size(), "page", "pageSize", false, metadata,
|
||||
row -> new Product(requiredText(row,"customerCode",64), requiredText(row,"sku",128), optionalText(row,"productName"),
|
||||
quantity(row.get("length")),quantity(row.get("width")),quantity(row.get("height")),optionalText(row,"sizeUnit"),
|
||||
quantity(row.get("wmsLength")),quantity(row.get("wmsWidth")),quantity(row.get("wmsHeight")),optionalText(row,"wmsSizeUnit"))));
|
||||
|
||||
+16
-2
@@ -23,14 +23,14 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
/** Synthetic loopback transport only; no supplier or application services. */
|
||||
class LingxingWmsClientTest {
|
||||
@Test void customerDirectoryKeepsNamesAndUsesAccountGate() {
|
||||
response.set(page("current","size",1,1000,1,1,"{\"customerCode\":\"C\",\"customerName\":\"示例货主\",\"status\":\"0\",\"telephoneNo\":\"not-forwarded\"}"));
|
||||
response.set(page("page","pageSize",1,1000,1,1,"{\"customerCode\":\"C\",\"customerName\":\"示例货主\",\"status\":\"0\",\"telephoneNo\":\"not-forwarded\"}"));
|
||||
var result=client().queryCustomers(new WarehouseQueryRequest(1,1000),context());
|
||||
assertThat(path.get()).isEqualTo("/openapi/v2/customer/list");
|
||||
assertThat(result.records()).containsExactly(new Customer("C","示例货主","0"));
|
||||
assertThat(completion.get().operation()).isEqualTo(Operation.CUSTOMERS);
|
||||
}
|
||||
@Test void productDirectoryRetainsDeclaredDimensionsAndUnknownMeasurements() {
|
||||
response.set(page("current","size",1,100,1,1,"{\"customerCode\":\"C\",\"sku\":\"SKU\",\"productName\":\"商品\",\"length\":5,\"width\":11,\"height\":5,\"sizeUnit\":\"cm\",\"wmsLength\":\"\",\"wmsWidth\":\"\",\"wmsHeight\":\"\",\"wmsSizeUnit\":\"\"}"));
|
||||
response.set(page("page","pageSize",1,100,1,1,"{\"customerCode\":\"C\",\"sku\":\"SKU\",\"productName\":\"商品\",\"length\":5,\"width\":11,\"height\":5,\"sizeUnit\":\"cm\",\"wmsLength\":\"\",\"wmsWidth\":\"\",\"wmsHeight\":\"\",\"wmsSizeUnit\":\"\"}"));
|
||||
var result=client().queryProducts(new ProductQueryRequest(1,100),context());
|
||||
assertThat(result.records().get(0).length()).isEqualByComparingTo("5");
|
||||
assertThat(result.records().get(0).wmsLength()).isNull();
|
||||
@@ -39,6 +39,20 @@ class LingxingWmsClientTest {
|
||||
assertThatThrownBy(()->client().queryProducts(new ProductQueryRequest(1,101),context())).isInstanceOf(LingxingWmsException.class);
|
||||
assertThat(calls.get()).isEqualTo(1);
|
||||
}
|
||||
@Test void masterDataUsesSupplierResponsePaginationAndRejectsWrongPage() throws Exception {
|
||||
response.set(page("page","pageSize",2,1,2,2,"{\"customerCode\":\"C\",\"sku\":\"SKU\"}"));
|
||||
var result=client().queryProducts(new ProductQueryRequest(2,1),context());
|
||||
assertThat(result.current()).isEqualTo(2);
|
||||
assertThat(result.sourceCurrent()).isEqualTo(2);
|
||||
assertThat(result.sourceSize()).isEqualTo(1);
|
||||
var request=mapper.readTree(body.get()).path("data");
|
||||
assertThat(request.path("current").asInt()).isEqualTo(2);
|
||||
assertThat(request.path("size").asInt()).isEqualTo(1);
|
||||
assertThat(request.has("page")).isFalse();
|
||||
response.set(page("page","pageSize",1,1,2,2,"{\"customerCode\":\"C\",\"sku\":\"SKU\"}"));
|
||||
assertThatThrownBy(()->client().queryProducts(new ProductQueryRequest(2,1),context()))
|
||||
.isInstanceOf(LingxingWmsException.class).hasMessageContaining("CURRENT_MISMATCH");
|
||||
}
|
||||
private static final Instant NOW = Instant.parse("2026-10-12T00:00:00Z");
|
||||
private static final String PRIVATE = "private-secret@example.test";
|
||||
private static final String ORDER = """
|
||||
|
||||
Reference in New Issue
Block a user