Forráskód Böngészése

mall + pay:
1. 修复单元测试的报错

YunaiV 1 éve
szülő
commit
3a24d05bdc

+ 1 - 1
pom.xml

@@ -20,7 +20,7 @@
 <!--        <module>yudao-module-bpm</module>-->
 <!--        <module>yudao-module-report</module>-->
 <!--        <module>yudao-module-mp</module>-->
-        <module>yudao-module-mall</module>
+<!--        <module>yudao-module-mall</module>-->
         <!-- 示例项目 -->
         <module>yudao-example</module>
     </modules>

+ 0 - 2
yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java

@@ -8,7 +8,6 @@ import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration
 import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
 import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
 import org.redisson.spring.starter.RedissonAutoConfiguration;
-import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -41,7 +40,6 @@ public class BaseDbAndRedisUnitTest {
 
             // Redis 配置类
             RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer
-            RedisAutoConfiguration.class, // Spring Redis 自动配置类
             YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类
             RedissonAutoConfiguration.class, // Redisson 自动高配置类
     })

+ 1 - 1
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java

@@ -39,7 +39,7 @@ public class MemberAddressDO extends BaseDO {
     /**
      * 地区编号
      */
-    private Integer areaId;
+    private Long areaId;
     /**
      * 收件详细地址
      */

+ 1 - 2
yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql

@@ -23,9 +23,8 @@ CREATE TABLE IF NOT EXISTS "member_address" (
     "name" varchar(10) NOT NULL,
     "mobile" varchar(20) NOT NULL,
     "area_id" bigint(20) NOT NULL,
-    "post_code" varchar(16) NOT NULL,
     "detail_address" varchar(250) NOT NULL,
-    "defaulted" bit NOT NULL,
+    "default_status" bit NOT NULL,
     "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
     "creator" varchar(64) DEFAULT '',
     "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

+ 3 - 1
yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java

@@ -20,9 +20,11 @@ import org.springframework.context.annotation.Import;
 import javax.annotation.Resource;
 import javax.validation.Validator;
 
+import java.time.Duration;
 import java.util.Collections;
 import java.util.List;
 
+import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime;
 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
@@ -68,7 +70,7 @@ public class PayChannelServiceTest extends BaseDbUnitTest {
     public void testRefreshLocalCache() {
         // mock 数据 01
         PayChannelDO dbChannel = randomPojo(PayChannelDO.class,
-                o -> o.setConfig(randomWxPayClientConfig()));
+                o -> o.setConfig(randomWxPayClientConfig()).setUpdateTime(addTime(Duration.ofMinutes(-2))));
         channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据
         channelService.initLocalCache();
         // mock 数据 02

+ 1 - 1
yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql

@@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS "pay_app" (
     "name"              varchar(64)   NOT NULL,
     "status"            tinyint       NOT NULL,
     "remark"            varchar(255)           DEFAULT NULL,
-    `pay_notify_url`    varchar(1024) NOT NULL,
+    `order_notify_url`    varchar(1024) NOT NULL,
     `refund_notify_url` varchar(1024) NOT NULL,
     "creator"           varchar(64)            DEFAULT '',
     "create_time"       datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP,

+ 15 - 3
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java

@@ -84,6 +84,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
             o.setParams(Lists.newArrayList("code", "op"));
         });
         when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
+        String title = RandomUtils.randomString();
+        when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams)))
+                .thenReturn(title);
         String content = RandomUtils.randomString();
         when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams)))
                 .thenReturn(content);
@@ -101,7 +104,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
         assertEquals(mailLogId, resultMailLogId);
         // 断言调用
         verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(user.getEmail()),
-                eq(account.getId()), eq(template.getNickname()), eq(template.getTitle()), eq(content));
+                eq(account.getId()), eq(template.getNickname()), eq(title), eq(content));
     }
 
     @Test
@@ -122,6 +125,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
             o.setParams(Lists.newArrayList("code", "op"));
         });
         when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
+        String title = RandomUtils.randomString();
+        when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams)))
+                .thenReturn(title);
         String content = RandomUtils.randomString();
         when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams)))
                 .thenReturn(content);
@@ -139,7 +145,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
         assertEquals(mailLogId, resultMailLogId);
         // 断言调用
         verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail),
-                eq(account.getId()), eq(template.getNickname()), eq(template.getTitle()), eq(content));
+                eq(account.getId()), eq(template.getNickname()), eq(title), eq(content));
     }
 
     /**
@@ -161,6 +167,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
             o.setParams(Lists.newArrayList("code", "op"));
         });
         when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
+        String title = RandomUtils.randomString();
+        when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams)))
+                .thenReturn(title);
         String content = RandomUtils.randomString();
         when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams)))
                 .thenReturn(content);
@@ -178,7 +187,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
         assertEquals(mailLogId, resultMailLogId);
         // 断言调用
         verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail),
-                eq(account.getId()), eq(template.getNickname()), eq(template.getTitle()), eq(content));
+                eq(account.getId()), eq(template.getNickname()), eq(title), eq(content));
     }
 
     /**
@@ -200,6 +209,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
             o.setParams(Lists.newArrayList("code", "op"));
         });
         when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
+        String title = RandomUtils.randomString();
+        when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams)))
+                .thenReturn(title);
         String content = RandomUtils.randomString();
         when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams)))
                 .thenReturn(content);

+ 2 - 2
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImplTest.java

@@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.service.social;
 
 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
 import cn.iocoder.yudao.framework.social.core.YudaoAuthRequestFactory;
-import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest;
+import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
 import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO;
 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
@@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.*;
 
 @Import(SocialUserServiceImpl.class)
-public class SocialUserServiceImplTest extends BaseDbAndRedisUnitTest {
+public class SocialUserServiceImplTest extends BaseDbUnitTest {
 
     @Resource
     private SocialUserServiceImpl socialUserService;

+ 15 - 15
yudao-server/pom.xml

@@ -68,21 +68,21 @@
 <!--        </dependency>-->
 
         <!-- 商城相关模块。默认注释,保证编译速度 -->
-        <dependency>
-            <groupId>cn.iocoder.boot</groupId>
-            <artifactId>yudao-module-promotion-biz</artifactId>
-            <version>${revision}</version>
-        </dependency>
-        <dependency>
-            <groupId>cn.iocoder.boot</groupId>
-            <artifactId>yudao-module-product-biz</artifactId>
-            <version>${revision}</version>
-        </dependency>
-        <dependency>
-            <groupId>cn.iocoder.boot</groupId>
-            <artifactId>yudao-module-trade-biz</artifactId>
-            <version>${revision}</version>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>cn.iocoder.boot</groupId>-->
+<!--            <artifactId>yudao-module-promotion-biz</artifactId>-->
+<!--            <version>${revision}</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>cn.iocoder.boot</groupId>-->
+<!--            <artifactId>yudao-module-product-biz</artifactId>-->
+<!--            <version>${revision}</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>cn.iocoder.boot</groupId>-->
+<!--            <artifactId>yudao-module-trade-biz</artifactId>-->
+<!--            <version>${revision}</version>-->
+<!--        </dependency>-->
 
         <!-- spring boot 配置所需依赖 -->
         <dependency>

+ 1 - 1
yudao-ui-admin/src/views/pay/app/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-
+    <doc-alert title="支付功能开启" url="https://doc.iocoder.cn/pay/build/" />
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="应用名" prop="name">

+ 5 - 0
yudao-ui-admin/src/views/pay/demo/index.vue

@@ -1,5 +1,10 @@
 <template>
   <div class="app-container">
+    <doc-alert title="支付宝支付接入" url="https://doc.iocoder.cn/pay/alipay-pay-demo/" />
+    <doc-alert title="支付宝、微信退款接入" url="https://doc.iocoder.cn/pay/refund-demo/" />
+    <doc-alert title="微信公众号支付接入" url="https://doc.iocoder.cn/pay/wx-pub-pay-demo/" />
+    <doc-alert title="微信小程序支付接入" url="https://doc.iocoder.cn/pay/wx-lite-pay-demo/" />
+
     <!-- 操作工具栏 -->
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">

+ 1 - 0
yudao-ui-admin/src/views/pay/notify/index.vue

@@ -1,5 +1,6 @@
 <template>
   <div class="app-container">
+    <doc-alert title="支付功能开启" url="https://doc.iocoder.cn/pay/build/" />
 
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">

+ 3 - 0
yudao-ui-admin/src/views/pay/order/index.vue

@@ -1,5 +1,8 @@
 <template>
   <div class="app-container">
+    <doc-alert title="支付宝支付接入" url="https://doc.iocoder.cn/pay/alipay-pay-demo/" />
+    <doc-alert title="微信公众号支付接入" url="https://doc.iocoder.cn/pay/wx-pub-pay-demo/" />
+    <doc-alert title="微信小程序支付接入" url="https://doc.iocoder.cn/pay/wx-lite-pay-demo/" />
 
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">

+ 2 - 0
yudao-ui-admin/src/views/pay/refund/index.vue

@@ -1,5 +1,7 @@
 <template>
   <div class="app-container">
+    <doc-alert title="支付宝、微信退款接入" url="https://doc.iocoder.cn/pay/refund-demo/" />
+
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
       <el-form-item label="应用编号" prop="appId">