调整季度稳定收入参数并补充UTF8执行脚本

This commit is contained in:
wkc
2026-03-17 17:22:27 +08:00
parent 88186f37a6
commit 82cb751b8f
7 changed files with 145 additions and 3 deletions

View File

@@ -0,0 +1,48 @@
package com.ruoyi.ccdi.project.sql;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class CcdiModelParamSqlDefaultsTest {
@Test
void defaultSql_shouldUseQuarterlyStableIncomeMinAndMaxParams() throws IOException {
String initSql = readProjectFile("sql", "ccdi_model_param.sql");
String updateSql = readProjectFile("sql", "2026-03-16-update-ccdi-model-param-defaults.sql");
assertQuarterlyStableIncomeRangeConfig(initSql);
assertQuarterlyStableIncomeRangeConfig(updateSql);
}
private void assertQuarterlyStableIncomeRangeConfig(String sqlContent) {
assertAll(
() -> assertTrue(sqlContent.contains("FIXED_COUNTERPARTY_TRANSFER_MIN"),
"应包含季度稳定收入金额下限参数编码"),
() -> assertTrue(sqlContent.contains("FIXED_COUNTERPARTY_TRANSFER_MAX"),
"应包含季度稳定收入金额上限参数编码"),
() -> assertTrue(sqlContent.contains("季度稳定收入金额下限"),
"应包含季度稳定收入金额下限参数名称"),
() -> assertTrue(sqlContent.contains("季度稳定收入金额上限"),
"应包含季度稳定收入金额上限参数名称"),
() -> assertTrue(sqlContent.contains("'3000'"),
"应包含季度稳定收入金额下限默认值3000"),
() -> assertTrue(sqlContent.contains("'15000'"),
"应包含季度稳定收入金额上限默认值15000"),
() -> assertFalse(sqlContent.contains("'FIXED_COUNTERPARTY_TRANSFER'"),
"不应继续保留旧的单值季度稳定收入金额参数编码")
);
}
private String readProjectFile(String... parts) throws IOException {
Path path = Path.of("..", parts);
return Files.readString(path, StandardCharsets.UTF_8);
}
}

View File

@@ -0,0 +1,34 @@
package com.ruoyi.ccdi.project.sql;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertTrue;
class MysqlUtf8ExecScriptTest {
@Test
void mysqlUtf8ExecScript_shouldForceUtf8SessionAndSourceSqlFile() throws IOException {
String script = Files.readString(
Path.of("..", "bin", "mysql_utf8_exec.sh"),
StandardCharsets.UTF_8
);
assertAll(
() -> assertTrue(script.contains("application-dev.yml"),
"脚本应读取 application-dev.yml 中的数据库连接信息"),
() -> assertTrue(script.contains("--default-character-set=utf8mb4"),
"脚本应强制 mysql 客户端使用 utf8mb4"),
() -> assertTrue(script.contains("--init-command")
&& script.contains("SET NAMES utf8mb4"),
"脚本应在 mysql 会话初始化时显式执行 SET NAMES utf8mb4"),
() -> assertTrue(script.contains("< \"${ABS_SQL_FILE}\""),
"脚本应直接重定向 SQL 文件执行")
);
}
}