Browse Source

fix: separate OMG i18n bundle entries

qmj 2 weeks ago
parent
commit
91ccc3b32c

+ 1 - 0
ruoyi-admin/src/main/resources/i18n/messages.properties

@@ -217,6 +217,7 @@ line.pay.refund.already.completed=LINE Pay 支付已经退款
 line.pay.order.completion.not.allowed=当前 LINE Pay 订单状态不允许完成
 line.pay.legacy.endpoint.disabled=LINE Pay 订单请使用专用订单操作接口
 rider.operation.role.required=只有骑手可以操作配送订单
+
 omg.payment.ddid.required=OMG 支付订单号不能为空
 omg.payment.merchantTradeNo.required=OMG MerchantTradeNo 不能为空
 omg.payment.storeId.required=OMG 门店 ID 不能为空

+ 1 - 0
ruoyi-admin/src/main/resources/i18n/messages_zh_CN.properties

@@ -221,6 +221,7 @@ line.pay.refund.already.completed=LINE Pay 支付已经退款
 line.pay.order.completion.not.allowed=当前 LINE Pay 订单状态不允许完成
 line.pay.legacy.endpoint.disabled=LINE Pay 订单请使用专用订单操作接口
 rider.operation.role.required=只有骑手可以操作配送订单
+
 omg.payment.ddid.required=OMG 支付订单号不能为空
 omg.payment.merchantTradeNo.required=OMG MerchantTradeNo 不能为空
 omg.payment.storeId.required=OMG 门店 ID 不能为空

+ 1 - 0
ruoyi-admin/src/main/resources/i18n/messages_zh_TW.properties

@@ -221,6 +221,7 @@ line.pay.refund.already.completed=LINE Pay 支付已經退款
 line.pay.order.completion.not.allowed=目前 LINE Pay 訂單狀態不允許完成
 line.pay.legacy.endpoint.disabled=LINE Pay 訂單請使用專用訂單操作介面
 rider.operation.role.required=只有騎手可以操作配送訂單
+
 omg.payment.ddid.required=OMG 支付訂單號不能為空
 omg.payment.merchantTradeNo.required=OMG MerchantTradeNo 不能為空
 omg.payment.storeId.required=OMG 門店 ID 不能為空

+ 73 - 0
ruoyi-system/src/test/java/com/ruoyi/system/omgpay/service/OmgPaymentAttemptI18nContractTest.java

@@ -0,0 +1,73 @@
+package com.ruoyi.system.omgpay.service;
+
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Properties;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class OmgPaymentAttemptI18nContractTest {
+
+    private static final List<String> OMG_KEYS = List.of(
+            "omg.payment.ddid.required",
+            "omg.payment.merchantTradeNo.required",
+            "omg.payment.storeId.required",
+            "omg.payment.merchantId.required",
+            "omg.payment.amount.invalid"
+    );
+
+    @Test
+    void omgValidationKeysResolveInAllBundlesAndBoundaryIsSeparated() throws IOException {
+        for (Path bundle : allBundles()) {
+            Properties properties = loadProperties(bundle);
+            for (String key : OMG_KEYS) {
+                assertNotNull(properties.getProperty(key),
+                        () -> bundle.getFileName() + " should resolve " + key);
+            }
+        }
+
+        for (Path bundle : malformedBoundaryBundles()) {
+            String normalized = Files.readString(bundle, StandardCharsets.UTF_8).replace("\r\n", "\n");
+            assertTrue(normalized.contains("\n\nomg.payment.ddid.required="),
+                    () -> bundle.getFileName() + " should start OMG keys on a separated block boundary");
+        }
+    }
+
+    private static Properties loadProperties(Path bundle) throws IOException {
+        Properties properties = new Properties();
+        try (Reader reader = Files.newBufferedReader(bundle, StandardCharsets.UTF_8)) {
+            properties.load(reader);
+        }
+        return properties;
+    }
+
+    private static List<Path> allBundles() {
+        return List.of(
+                bundle("messages.properties"),
+                bundle("messages_en_US.properties"),
+                bundle("messages_vi.properties"),
+                bundle("messages_zh_CN.properties"),
+                bundle("messages_zh_TW.properties")
+        );
+    }
+
+    private static List<Path> malformedBoundaryBundles() {
+        return List.of(
+                bundle("messages.properties"),
+                bundle("messages_zh_CN.properties"),
+                bundle("messages_zh_TW.properties")
+        );
+    }
+
+    private static Path bundle(String name) {
+        return Paths.get("..", "ruoyi-admin", "src", "main", "resources", "i18n", name);
+    }
+}