fix: prepare mixed-SKU dropship acceptance data

This commit is contained in:
2026-09-11 16:21:14 +08:00
parent 51ce609ab1
commit 010475a4c3
4 changed files with 38 additions and 4 deletions
@@ -19,6 +19,7 @@ import org.springframework.test.util.ReflectionTestUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -98,6 +99,23 @@ class InboundCartonLabelServiceTest {
any(Long.class), any(String.class), any(), any(Integer.class), any(Integer.class));
}
@Test
void mixedCartonSkuSummaryStaysWithinPrintContractLimit() {
InboundCartonLabelEntity label = new InboundCartonLabelEntity();
label.setId(90001L);
List<InboundCartonLabelSkuMapper.SkuRow> rows = List.of(
skuRow(90001L, "SKU-SMALL-ADMIN-API-20260911081504632"),
skuRow(90001L, "SKU-MEDIUM-ADMIN-API-20260911081504632"),
skuRow(90001L, "SKU-LARGE-ADMIN-API-20260911081504632"),
skuRow(90001L, "SKU-EXTRA-LARGE-ADMIN-API-20260911081504632"));
String summary = ReflectionTestUtils.invokeMethod(service, "displaySkuCodes", label,
Map.of(90001L, rows));
assertThat(summary.codePointCount(0, summary.length())).isLessThanOrEqualTo(64);
assertThat(summary).startsWith("SKU-SMALL-").endsWith(" / +3 SKU");
}
@Test
void repeatedAndPartialPrintsReadFrozenMappingWithoutReallocation() {
InboundOrderEntity inbound = inbound();
@@ -312,6 +330,13 @@ class InboundCartonLabelServiceTest {
units, new BigDecimal("60"), new BigDecimal("40"), new BigDecimal("30"), null, group);
}
private InboundCartonLabelSkuMapper.SkuRow skuRow(long labelId, String skuCode) {
InboundCartonLabelSkuMapper.SkuRow row = new InboundCartonLabelSkuMapper.SkuRow();
row.setCartonLabelId(labelId);
row.setSkuCode(skuCode);
return row;
}
private List<InboundCartonLabelEntity> labels(InboundOrderEntity inbound, int total) {
List<InboundCartonLabelEntity> values = new ArrayList<>();
for (int index = 1; index <= total; index++) {