From b1ad2d17c7f93e819c67fe5ab5c2ca94e764e517 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 18 八月 2026 10:42:23 +0800
Subject: [PATCH] 清理配置文件

---
 yudao-module-system/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java |  268 -----------------------------------------------------
 1 files changed, 0 insertions(+), 268 deletions(-)

diff --git a/yudao-module-system/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java b/yudao-module-system/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java
index 4abffa4..29b6997 100644
--- a/yudao-module-system/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java
+++ b/yudao-module-system/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java
@@ -1,41 +1,26 @@
 package cn.iocoder.yudao.module.system.service.social;
 
-import cn.binarywang.wx.miniapp.api.WxMaOrderShippingService;
-import cn.binarywang.wx.miniapp.api.WxMaService;
-import cn.binarywang.wx.miniapp.api.WxMaUserService;
-import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
-import cn.binarywang.wx.miniapp.bean.shop.request.shipping.WxMaOrderShippingInfoUploadRequest;
-import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoBaseResponse;
 import cn.hutool.core.util.ReflectUtil;
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
-import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaOrderUploadShippingInfoReqDTO;
 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO;
 import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO;
 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO;
 import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper;
 import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
 import cn.iocoder.yudao.module.system.framework.justauth.core.AuthRequestFactory;
-import com.binarywang.spring.starter.wxjava.miniapp.properties.WxMaProperties;
-import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
 import jakarta.annotation.Resource;
-import me.chanjar.weixin.common.bean.WxJsapiSignature;
-import me.chanjar.weixin.common.error.WxError;
-import me.chanjar.weixin.common.error.WxErrorException;
-import me.chanjar.weixin.mp.api.WxMpService;
 import me.zhyd.oauth.config.AuthConfig;
 import me.zhyd.oauth.model.AuthResponse;
 import me.zhyd.oauth.model.AuthUser;
 import me.zhyd.oauth.request.AuthDefaultRequest;
 import me.zhyd.oauth.request.AuthRequest;
 import me.zhyd.oauth.utils.AuthStateUtils;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.mockito.MockedStatic;
 import org.springframework.context.annotation.Import;
-import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.test.context.bean.override.mockito.MockitoBean;
 
 import static cn.hutool.core.util.RandomUtil.randomEle;
@@ -63,17 +48,6 @@
 
     @MockitoBean
     private AuthRequestFactory authRequestFactory;
-
-    @MockitoBean
-    private WxMpService wxMpService;
-    @MockitoBean
-    private WxMpProperties wxMpProperties;
-    @MockitoBean
-    private StringRedisTemplate stringRedisTemplate;
-    @MockitoBean
-    private WxMaService wxMaService;
-    @MockitoBean
-    private WxMaProperties wxMaProperties;
 
     @Test
     public void testGetAuthorizeUrl() {
@@ -205,152 +179,6 @@
         assertNotSame(authConfig, ReflectUtil.getFieldValue(authRequest, "config"));
     }
 
-    // =================== 寰俊鍏紬鍙风嫭鏈� ===================
-
-    @Test
-    public void testCreateWxMpJsapiSignature() throws WxErrorException {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        String url = randomString();
-        // mock 鏂规硶
-        WxJsapiSignature signature = randomPojo(WxJsapiSignature.class);
-        when(wxMpService.createJsapiSignature(eq(url))).thenReturn(signature);
-
-        // 璋冪敤
-        WxJsapiSignature result = socialClientService.createWxMpJsapiSignature(userType, url);
-        // 鏂█
-        assertSame(signature, result);
-    }
-
-    @Test
-    public void testGetWxMpService_clientNull() {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        // mock 鏂规硶
-
-        // 璋冪敤
-        WxMpService result = socialClientService.getWxMpService(userType);
-        // 鏂█
-        assertSame(wxMpService, result);
-    }
-
-    @Test
-    public void testGetWxMpService_clientDisable() {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        // mock 鏁版嵁
-        SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())
-                .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MP.getType()));
-        socialClientMapper.insert(client);
-
-        // 璋冪敤
-        WxMpService result = socialClientService.getWxMpService(userType);
-        // 鏂█
-        assertSame(wxMpService, result);
-    }
-
-    @Test
-    public void testGetWxMpService_clientEnable() {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        // mock 鏁版嵁
-        SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())
-                .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MP.getType()));
-        socialClientMapper.insert(client);
-        // mock 鏂规硶
-        WxMpProperties.ConfigStorage configStorage = mock(WxMpProperties.ConfigStorage.class);
-        when(wxMpProperties.getConfigStorage()).thenReturn(configStorage);
-
-        // 璋冪敤
-        WxMpService result = socialClientService.getWxMpService(userType);
-        // 鏂█
-        assertNotSame(wxMpService, result);
-        assertEquals(client.getClientId(), result.getWxMpConfigStorage().getAppId());
-        assertEquals(client.getClientSecret(), result.getWxMpConfigStorage().getSecret());
-    }
-
-    // =================== 寰俊灏忕▼搴忕嫭鏈� ===================
-
-    @Test
-    public void testGetWxMaPhoneNumberInfo_success() throws WxErrorException {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        String phoneCode = randomString();
-        // mock 鏂规硶
-        WxMaUserService userService = mock(WxMaUserService.class);
-        when(wxMaService.getUserService()).thenReturn(userService);
-        WxMaPhoneNumberInfo phoneNumber = randomPojo(WxMaPhoneNumberInfo.class);
-        when(userService.getPhoneNumber(eq(phoneCode))).thenReturn(phoneNumber);
-
-        // 璋冪敤
-        WxMaPhoneNumberInfo result = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode);
-        // 鏂█
-        assertSame(phoneNumber, result);
-    }
-
-    @Test
-    public void testGetWxMaPhoneNumberInfo_exception() throws WxErrorException {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        String phoneCode = randomString();
-        // mock 鏂规硶
-        WxMaUserService userService = mock(WxMaUserService.class);
-        when(wxMaService.getUserService()).thenReturn(userService);
-        WxErrorException wxErrorException = new WxErrorException(new NullPointerException());
-        when(userService.getPhoneNumber(eq(phoneCode))).thenThrow(wxErrorException);
-
-        // 璋冪敤骞舵柇瑷�寮傚父
-        assertServiceException(() -> socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode),
-                SOCIAL_CLIENT_WEIXIN_MINI_APP_PHONE_CODE_ERROR);
-    }
-
-    @Test
-    public void testGetWxMaService_clientNull() {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        // mock 鏂规硶
-
-        // 璋冪敤
-        WxMaService result = socialClientService.getWxMaService(userType);
-        // 鏂█
-        assertSame(wxMaService, result);
-    }
-
-    @Test
-    public void testGetWxMaService_clientDisable() {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        // mock 鏁版嵁
-        SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())
-                .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MINI_PROGRAM.getType()));
-        socialClientMapper.insert(client);
-
-        // 璋冪敤
-        WxMaService result = socialClientService.getWxMaService(userType);
-        // 鏂█
-        assertSame(wxMaService, result);
-    }
-
-    @Test
-    public void testGetWxMaService_clientEnable() {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        // mock 鏁版嵁
-        SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())
-                .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MINI_PROGRAM.getType()));
-        socialClientMapper.insert(client);
-        // mock 鏂规硶
-        WxMaProperties.ConfigStorage configStorage = mock(WxMaProperties.ConfigStorage.class);
-        when(wxMaProperties.getConfigStorage()).thenReturn(configStorage);
-
-        // 璋冪敤
-        WxMaService result = socialClientService.getWxMaService(userType);
-        // 鏂█
-        assertNotSame(wxMaService, result);
-        assertEquals(client.getClientId(), result.getWxMaConfig().getAppid());
-        assertEquals(client.getClientSecret(), result.getWxMaConfig().getSecret());
-    }
-
     // =================== 瀹㈡埛绔鐞� ===================
 
     @Test
@@ -472,102 +300,6 @@
         assertEquals(1, pageResult.getTotal());
         assertEquals(1, pageResult.getList().size());
         assertPojoEquals(dbSocialClient, pageResult.getList().get(0));
-    }
-
-    // =================== 寰俊灏忕▼搴忚鍗曞彂璐� ===================
-
-    @BeforeAll
-    public static void setUpUploadShippingBackoff() {
-        // 娴嬭瘯鍦烘櫙涓嬫妸閫�閬挎暟缁勭殑姣忎竴椤规敼涓� 1ms锛岄伩鍏嶆嫋鎱㈢敤渚嬶紙鏁扮粍寮曠敤鏄� final 浣嗗厓绱犲彲鏀癸級
-        long[] backoff = (long[]) ReflectUtil.getFieldValue(SocialClientServiceImpl.class,
-                "UPLOAD_SHIPPING_INFO_RETRY_BACKOFF_MILLIS");
-        for (int i = 0; i < backoff.length; i++) {
-            backoff[i] = 1L;
-        }
-    }
-
-    @Test
-    public void testUploadWxaOrderShippingInfo_success() throws WxErrorException {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        SocialWxaOrderUploadShippingInfoReqDTO reqDTO = randomUploadShippingReqDTO();
-        // mock 鏂规硶锛氶娆¤皟鐢ㄥ氨鎴愬姛
-        WxMaOrderShippingService shippingService = mockWxMaOrderShippingService();
-        when(shippingService.upload(any(WxMaOrderShippingInfoUploadRequest.class)))
-                .thenReturn(new WxMaOrderShippingInfoBaseResponse());
-
-        // 璋冪敤
-        socialClientService.uploadWxaOrderShippingInfo(userType, reqDTO);
-        // 鏂█锛氫粎璋冪敤 1 娆★紝鏃犻噸璇�
-        verify(shippingService, times(1)).upload(any(WxMaOrderShippingInfoUploadRequest.class));
-    }
-
-    @Test
-    public void testUploadWxaOrderShippingInfo_retryThenSuccess() throws WxErrorException {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        SocialWxaOrderUploadShippingInfoReqDTO reqDTO = randomUploadShippingReqDTO();
-        // mock 鏂规硶锛氶娆℃姏 10060001锛岀浜屾鎴愬姛
-        WxMaOrderShippingService shippingService = mockWxMaOrderShippingService();
-        when(shippingService.upload(any(WxMaOrderShippingInfoUploadRequest.class)))
-                .thenThrow(buildWxErrorException(10060001))
-                .thenReturn(new WxMaOrderShippingInfoBaseResponse());
-
-        // 璋冪敤
-        socialClientService.uploadWxaOrderShippingInfo(userType, reqDTO);
-        // 鏂█锛氫笂浼犺皟鐢ㄤ簡 2 娆★紝瑙﹀彂浜� 1 娆¢噸璇�
-        verify(shippingService, times(2)).upload(any(WxMaOrderShippingInfoUploadRequest.class));
-    }
-
-    @Test
-    public void testUploadWxaOrderShippingInfo_retryExhausted() throws WxErrorException {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        SocialWxaOrderUploadShippingInfoReqDTO reqDTO = randomUploadShippingReqDTO();
-        // mock 鏂规硶锛氬缁堟姏 10060001
-        WxMaOrderShippingService shippingService = mockWxMaOrderShippingService();
-        when(shippingService.upload(any(WxMaOrderShippingInfoUploadRequest.class)))
-                .thenThrow(buildWxErrorException(10060001));
-
-        // 璋冪敤骞舵柇瑷�锛氶噸璇曠敤灏芥姏涓氬姟寮傚父
-        assertServiceException(() -> socialClientService.uploadWxaOrderShippingInfo(userType, reqDTO),
-                SOCIAL_CLIENT_WEIXIN_MINI_APP_ORDER_UPLOAD_SHIPPING_INFO_ERROR);
-        // 鏂█锛氬叡 4 娆″皾璇曪紙1 娆¢鍙� + 3 娆¢噸璇曪級
-        verify(shippingService, times(4)).upload(any(WxMaOrderShippingInfoUploadRequest.class));
-    }
-
-    @Test
-    public void testUploadWxaOrderShippingInfo_otherErrorNoRetry() throws WxErrorException {
-        // 鍑嗗鍙傛暟
-        Integer userType = randomPojo(UserTypeEnum.class).getValue();
-        SocialWxaOrderUploadShippingInfoReqDTO reqDTO = randomUploadShippingReqDTO();
-        // mock 鏂规硶锛氭姏闈� 10060001 閿欒锛堝 access_token 澶辨晥锛�
-        WxMaOrderShippingService shippingService = mockWxMaOrderShippingService();
-        when(shippingService.upload(any(WxMaOrderShippingInfoUploadRequest.class)))
-                .thenThrow(buildWxErrorException(40001));
-
-        // 璋冪敤骞舵柇瑷�锛氱珛鍗虫姏涓氬姟寮傚父锛屾棤閲嶈瘯
-        assertServiceException(() -> socialClientService.uploadWxaOrderShippingInfo(userType, reqDTO),
-                SOCIAL_CLIENT_WEIXIN_MINI_APP_ORDER_UPLOAD_SHIPPING_INFO_ERROR);
-        verify(shippingService, times(1)).upload(any(WxMaOrderShippingInfoUploadRequest.class));
-    }
-
-    /** 鏋勯�犱竴涓彂璐т笂浼犺姹� */
-    private SocialWxaOrderUploadShippingInfoReqDTO randomUploadShippingReqDTO() {
-        return randomPojo(SocialWxaOrderUploadShippingInfoReqDTO.class,
-                o -> o.setLogisticsType(SocialWxaOrderUploadShippingInfoReqDTO.LOGISTICS_TYPE_EXPRESS));
-    }
-
-    /** mock 鍑� wxMaService.getWxMaOrderShippingService() 鐨勮繑鍥炲�煎苟杩斿洖璇� mock */
-    private WxMaOrderShippingService mockWxMaOrderShippingService() {
-        WxMaOrderShippingService shippingService = mock(WxMaOrderShippingService.class);
-        when(wxMaService.getWxMaOrderShippingService()).thenReturn(shippingService);
-        return shippingService;
-    }
-
-    /** 鏋勯�犳寚瀹� errorCode 鐨� WxErrorException */
-    private WxErrorException buildWxErrorException(int errorCode) {
-        return new WxErrorException(WxError.builder().errorCode(errorCode).errorMsg("mock error").build());
     }
 
 }

--
Gitblit v1.9.3