Files
peipei-backend/play-admin/src/test/java/com/starry/admin/api/MockWxMpServiceConfig.java
irving da2902c61c 重构:优化订单通知消息标签,支持动态显示订单类型
- 新增 OrderMessageLabelResolver 用于解析订单场景标签
- 修改微信公众号下单通知,根据下单类型(随机单/指定单/打赏/礼物)显示对应标签
- 更新 WxCustomMpService 接口,传递 placeType 和 rewardType 参数
- 完善相关单元测试和 Mock 配置
2025-11-03 22:51:48 -05:00

32 lines
1.1 KiB
Java

package com.starry.admin.api;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.WxMpTemplateMsgService;
import org.mockito.Mockito;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
/**
* Provides stubbed WeChat MP services in the apitest profile so integration tests never hit external APIs.
*/
@TestConfiguration
@Profile("apitest")
public class MockWxMpServiceConfig {
@Bean
@Primary
public WxMpService wxMpService() {
WxMpService service = mock(WxMpService.class, Mockito.RETURNS_DEEP_STUBS);
WxMpTemplateMsgService templateMsgService = mock(WxMpTemplateMsgService.class);
when(service.getTemplateMsgService()).thenReturn(templateMsgService);
when(service.switchoverTo(Mockito.anyString())).thenReturn(service);
when(service.switchover(Mockito.anyString())).thenReturn(true);
return service;
}
}