贴标申请,仓储转运
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
|||||||
|
package com.baiyue.lastleg.returnreceipt.service;
|
||||||
|
|
||||||
|
import com.baiyue.lastleg.returnreceipt.mapper.ReturnInventoryMovementMapper;
|
||||||
|
import org.apache.ibatis.builder.annotation.MapperAnnotationBuilder;
|
||||||
|
import org.apache.ibatis.session.Configuration;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
class ReturnInventoryMovementSqlTest {
|
||||||
|
@Test
|
||||||
|
void everyUnionBranchNormalizesAllSixTextColumns() {
|
||||||
|
String[] branches = ReturnInventoryMovementMapper.MOVEMENTS.split("UNION ALL");
|
||||||
|
assertEquals(7, branches.length);
|
||||||
|
for (String branch : branches) {
|
||||||
|
String projection = branch.substring(0, branch.indexOf("FROM"));
|
||||||
|
assertEquals(6, projection.split("COLLATE utf8mb4_unicode_ci", -1).length - 1, branch);
|
||||||
|
assertEquals(6, projection.split("USING utf8mb4", -1).length - 1, branch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void countAndPageShareNormalizedProjectionAndKeepScopeFilters() {
|
||||||
|
Configuration configuration = new Configuration();
|
||||||
|
new MapperAnnotationBuilder(configuration, ReturnInventoryMovementMapper.class).parse();
|
||||||
|
Map<String, Object> params = Map.of("customerId", "CUSTOMER", "warehouseId", "WAREHOUSE",
|
||||||
|
"skuCode", "SKU", "offset", 0L, "size", 20L);
|
||||||
|
for (String method : new String[]{"platformCount", "platformPage"}) {
|
||||||
|
var boundSql = configuration.getMappedStatement(ReturnInventoryMovementMapper.class.getName() + "." + method)
|
||||||
|
.getBoundSql(params);
|
||||||
|
String sql = boundSql.getSql();
|
||||||
|
assertEquals(42, sql.split("COLLATE utf8mb4_unicode_ci", -1).length - 1);
|
||||||
|
assertTrue(sql.contains("m.customerId=?"));
|
||||||
|
assertTrue(sql.contains("m.overseasWarehouseId=?"));
|
||||||
|
assertTrue(sql.contains("m.skuCode LIKE CONCAT('%',?,'%')"));
|
||||||
|
assertEquals(method.equals("platformPage") ? 5 : 3, boundSql.getParameterMappings().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user