|
|
@@ -7,6 +7,7 @@ import com.payment.platform.module.payment.har.client.dto.HarPrecreateRequest;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
|
|
@@ -86,4 +87,54 @@ class HarClientBizContentTest {
|
|
|
req.setAuthCode("280812345678901234");
|
|
|
assertSubjectTracksTitle(req, req::setTitle);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 断言 {@code biz} 出网键名与取值都对,且跟着 setter 走。
|
|
|
+ *
|
|
|
+ * <p>为什么 {@code trade_type} 与 {@code biz} 两个都发:260924 那份把
|
|
|
+ * {@code trade_type} 整行划了红线(参数名/描述/类型/必填/备注五格全带
|
|
|
+ * {@code <w:strike/>}),另起一行 {@code biz} 却是红字**不划线**。两种标注格式
|
|
|
+ * 不同,光读文档判不出 {@code trade_type} 是「作废」还是「改了枚举名」。
|
|
|
+ * 两个都发在两种读法下都成立(上游容忍多余字段,见类注释),
|
|
|
+ * 哪一半不被认,联调读数会直接指出来。
|
|
|
+ */
|
|
|
+ private void assertBizTracksValue(Object req, java.util.function.Consumer<String> setBiz) throws Exception {
|
|
|
+ setBiz.accept("har_ali_un_stage");
|
|
|
+ JsonNode n = bizContentOf(req);
|
|
|
+ assertTrue(n.has("merchant_code"), "正对照:bizContent 应有 merchant_code,实际=" + n);
|
|
|
+ assertEquals("har_ali_un_stage", n.path("biz").asText(null),
|
|
|
+ "bizContent 缺 biz 或值不对,实际=" + n);
|
|
|
+
|
|
|
+ // 换个值再测一遍:只测一个值时,写死成那个常量同样能绿
|
|
|
+ setBiz.accept("另一个业务类型");
|
|
|
+ assertEquals("另一个业务类型", bizContentOf(req).path("biz").asText(null));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void precreate_bizContent_carriesBiz() throws Exception {
|
|
|
+ HarPrecreateRequest req = new HarPrecreateRequest();
|
|
|
+ req.setMerchantCode("M001");
|
|
|
+ assertBizTracksValue(req, req::setBiz);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void pay_bizContent_carriesBiz() throws Exception {
|
|
|
+ HarPayRequest req = new HarPayRequest();
|
|
|
+ req.setMerchantCode("M001");
|
|
|
+ req.setAuthCode("280812345678901234");
|
|
|
+ assertBizTracksValue(req, req::setBiz);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * biz 是选填(260924 订单创建参数表 biz 行「不为空」列是空的):没给就不该出现,
|
|
|
+ * 免得把一个空串当成业务类型送到上游。
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void precreate_bizAbsentWhenNotSet() throws Exception {
|
|
|
+ HarPrecreateRequest req = new HarPrecreateRequest();
|
|
|
+ req.setMerchantCode("M001");
|
|
|
+ JsonNode n = bizContentOf(req);
|
|
|
+ assertTrue(n.has("merchant_code"), "正对照:bizContent 应有 merchant_code,实际=" + n);
|
|
|
+ assertFalse(n.has("biz"), "biz 未设置时不应出现在 bizContent 里,实际=" + n);
|
|
|
+ }
|
|
|
}
|