mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-01 02:38:43 +08:00 
			
		
		
		
	Merge branch 'master' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feature/mall_product
# Conflicts: # yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java # yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java # yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java # yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java # yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java # yudao-server/src/main/resources/application-local.yaml
This commit is contained in:
		| @@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.system.controller.admin.sensitiveword.vo.Sensitiv | ||||
| import cn.iocoder.yudao.module.system.controller.admin.sensitiveword.vo.SensitiveWordUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.sensitiveword.SensitiveWordDO; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper; | ||||
| import org.junit.jupiter.api.BeforeEach; | ||||
| import org.junit.jupiter.api.Test; | ||||
| import org.springframework.context.annotation.Import; | ||||
|  | ||||
| @@ -42,6 +43,11 @@ public class SensitiveWordServiceImplTest extends BaseDbUnitTest { | ||||
|     @Resource | ||||
|     private SensitiveWordMapper sensitiveWordMapper; | ||||
|  | ||||
|     @BeforeEach | ||||
|     public void setUp() { | ||||
|         SensitiveWordServiceImpl.ENABLED = true; | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testInitLocalCache() { | ||||
|         SensitiveWordDO wordDO1 = randomPojo(SensitiveWordDO.class, o -> o.setName("傻瓜") | ||||
|   | ||||
| @@ -2,11 +2,14 @@ package cn.iocoder.yudao.module.system.service.sms; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.sms.core.client.SmsClient; | ||||
| import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||||
| import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; | ||||
| import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelCreateReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.system.convert.sms.SmsChannelConvert; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper; | ||||
| import org.junit.jupiter.api.Test; | ||||
| @@ -19,7 +22,8 @@ import java.util.List; | ||||
| import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | ||||
| import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; | ||||
| import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | ||||
| import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | ||||
| 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.*; | ||||
| import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SMS_CHANNEL_HAS_CHILDREN; | ||||
| import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SMS_CHANNEL_NOT_EXISTS; | ||||
| @@ -41,27 +45,6 @@ public class SmsChannelServiceTest extends BaseDbUnitTest { | ||||
|     @MockBean | ||||
|     private SmsTemplateService smsTemplateService; | ||||
|  | ||||
|     @Test | ||||
|     public void testInitLocalCache_success() { | ||||
|         // mock 数据 | ||||
|         SmsChannelDO smsChannelDO01 = randomPojo(SmsChannelDO.class); | ||||
|         smsChannelMapper.insert(smsChannelDO01); | ||||
|         SmsChannelDO smsChannelDO02 = randomPojo(SmsChannelDO.class); | ||||
|         smsChannelMapper.insert(smsChannelDO02); | ||||
|  | ||||
|         // 调用 | ||||
|         smsChannelService.initLocalCache(); | ||||
|         // 校验调用 | ||||
|         verify(smsClientFactory, times(1)).createOrUpdateSmsClient( | ||||
|                 argThat(properties -> isPojoEquals(smsChannelDO01, properties))); | ||||
|         verify(smsClientFactory, times(1)).createOrUpdateSmsClient( | ||||
|                 argThat(properties -> isPojoEquals(smsChannelDO02, properties))); | ||||
|         // 断言 channelCache 缓存 | ||||
|         assertEquals(2, smsChannelService.getChannelCache().size()); | ||||
|         assertPojoEquals(smsChannelDO01, smsChannelService.getChannelCache().get(0)); | ||||
|         assertPojoEquals(smsChannelDO02, smsChannelService.getChannelCache().get(1)); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testCreateSmsChannel_success() { | ||||
|         // 准备参数 | ||||
| @@ -74,6 +57,9 @@ public class SmsChannelServiceTest extends BaseDbUnitTest { | ||||
|         // 校验记录的属性是否正确 | ||||
|         SmsChannelDO smsChannel = smsChannelMapper.selectById(smsChannelId); | ||||
|         assertPojoEquals(reqVO, smsChannel); | ||||
|         // 断言 cache | ||||
|         assertNull(smsChannelService.getIdClientCache().getIfPresent(smsChannel.getId())); | ||||
|         assertNull(smsChannelService.getCodeClientCache().getIfPresent(smsChannel.getCode())); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
| @@ -93,6 +79,9 @@ public class SmsChannelServiceTest extends BaseDbUnitTest { | ||||
|         // 校验是否更新正确 | ||||
|         SmsChannelDO smsChannel = smsChannelMapper.selectById(reqVO.getId()); // 获取最新的 | ||||
|         assertPojoEquals(reqVO, smsChannel); | ||||
|         // 断言 cache | ||||
|         assertNull(smsChannelService.getIdClientCache().getIfPresent(smsChannel.getId())); | ||||
|         assertNull(smsChannelService.getCodeClientCache().getIfPresent(smsChannel.getCode())); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
| @@ -116,6 +105,9 @@ public class SmsChannelServiceTest extends BaseDbUnitTest { | ||||
|         smsChannelService.deleteSmsChannel(id); | ||||
|         // 校验数据不存在了 | ||||
|         assertNull(smsChannelMapper.selectById(id)); | ||||
|         // 断言 cache | ||||
|         assertNull(smsChannelService.getIdClientCache().getIfPresent(dbSmsChannel.getId())); | ||||
|         assertNull(smsChannelService.getCodeClientCache().getIfPresent(dbSmsChannel.getCode())); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
| @@ -199,4 +191,46 @@ public class SmsChannelServiceTest extends BaseDbUnitTest { | ||||
|        assertPojoEquals(dbSmsChannel, pageResult.getList().get(0)); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetSmsClient_id() { | ||||
|         // mock 数据 | ||||
|         SmsChannelDO channel = randomPojo(SmsChannelDO.class); | ||||
|         smsChannelMapper.insert(channel); | ||||
|         // mock 参数 | ||||
|         Long id = channel.getId(); | ||||
|         // mock 方法 | ||||
|         SmsClient mockClient = mock(SmsClient.class); | ||||
|         when(smsClientFactory.getSmsClient(eq(id))).thenReturn(mockClient); | ||||
|  | ||||
|         // 调用 | ||||
|         SmsClient client = smsChannelService.getSmsClient(id); | ||||
|         // 断言 | ||||
|         assertSame(client, mockClient); | ||||
|         verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> { | ||||
|             SmsChannelProperties properties = SmsChannelConvert.INSTANCE.convert02(channel); | ||||
|             return properties.equals(arg); | ||||
|         })); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetSmsClient_code() { | ||||
|         // mock 数据 | ||||
|         SmsChannelDO channel = randomPojo(SmsChannelDO.class); | ||||
|         smsChannelMapper.insert(channel); | ||||
|         // mock 参数 | ||||
|         String code = channel.getCode(); | ||||
|         // mock 方法 | ||||
|         SmsClient mockClient = mock(SmsClient.class); | ||||
|         when(smsClientFactory.getSmsClient(eq(code))).thenReturn(mockClient); | ||||
|  | ||||
|         // 调用 | ||||
|         SmsClient client = smsChannelService.getSmsClient(code); | ||||
|         // 断言 | ||||
|         assertSame(client, mockClient); | ||||
|         verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> { | ||||
|             SmsChannelProperties properties = SmsChannelConvert.INSTANCE.convert02(channel); | ||||
|             return properties.equals(arg); | ||||
|         })); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.common.core.KeyValue; | ||||
| import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||||
| import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | ||||
| import cn.iocoder.yudao.framework.sms.core.client.SmsClient; | ||||
| import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||||
| import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; | ||||
| import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO; | ||||
| import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO; | ||||
| @@ -52,9 +51,6 @@ public class SmsSendServiceImplTest extends BaseMockitoUnitTest { | ||||
|     @Mock | ||||
|     private SmsProducer smsProducer; | ||||
|  | ||||
|     @Mock | ||||
|     private SmsClientFactory smsClientFactory; | ||||
|  | ||||
|     @Test | ||||
|     public void testSendSingleSmsToAdmin() { | ||||
|         // 准备参数 | ||||
| @@ -253,7 +249,7 @@ public class SmsSendServiceImplTest extends BaseMockitoUnitTest { | ||||
|         SmsSendMessage message = randomPojo(SmsSendMessage.class); | ||||
|         // mock SmsClientFactory 的方法 | ||||
|         SmsClient smsClient = spy(SmsClient.class); | ||||
|         when(smsClientFactory.getSmsClient(eq(message.getChannelId()))).thenReturn(smsClient); | ||||
|         when(smsChannelService.getSmsClient(eq(message.getChannelId()))).thenReturn(smsClient); | ||||
|         // mock SmsClient 的方法 | ||||
|         SmsCommonResult<SmsSendRespDTO> sendResult = randomPojo(SmsCommonResult.class, SmsSendRespDTO.class); | ||||
|         sendResult.setData(randomPojo(SmsSendRespDTO.class)); | ||||
| @@ -275,7 +271,7 @@ public class SmsSendServiceImplTest extends BaseMockitoUnitTest { | ||||
|         String text = randomString(); | ||||
|         // mock SmsClientFactory 的方法 | ||||
|         SmsClient smsClient = spy(SmsClient.class); | ||||
|         when(smsClientFactory.getSmsClient(eq(channelCode))).thenReturn(smsClient); | ||||
|         when(smsChannelService.getSmsClient(eq(channelCode))).thenReturn(smsClient); | ||||
|         // mock SmsClient 的方法 | ||||
|         List<SmsReceiveRespDTO> receiveResults = randomPojoList(SmsReceiveRespDTO.class); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV