✅ 增加 social 模块的单测覆盖率
This commit is contained in:
@@ -23,7 +23,7 @@ public class SocialUserPageReqVO extends PageParam {
|
||||
@Schema(description = "用户昵称", example = "李四")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "社交 openid", example = "oz-Jdt0kd_jdhUxJHQdBJMlOFN7w\n")
|
||||
@Schema(description = "社交 openid", example = "oz-Jdt0kd_jdhUxJHQdBJMlOFN7w")
|
||||
private String openid;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
|
||||
@@ -142,7 +142,8 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* @param userType 用户类型
|
||||
* @return AuthRequest 对象
|
||||
*/
|
||||
private AuthRequest buildAuthRequest(Integer socialType, Integer userType) {
|
||||
@VisibleForTesting
|
||||
AuthRequest buildAuthRequest(Integer socialType, Integer userType) {
|
||||
// 1. 先查找默认的配置项,从 application-*.yaml 中读取
|
||||
AuthRequest request = authRequestFactory.get(SocialTypeEnum.valueOfType(socialType).getSource());
|
||||
Assert.notNull(request, String.format("社交平台(%d) 不存在", socialType));
|
||||
@@ -180,7 +181,8 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* @param userType 用户类型
|
||||
* @return WxMpService 对象
|
||||
*/
|
||||
private WxMpService getWxMpService(Integer userType) {
|
||||
@VisibleForTesting
|
||||
WxMpService getWxMpService(Integer userType) {
|
||||
// 第一步,查询 DB 的配置项,获得对应的 WxMpService 对象
|
||||
SocialClientDO client = socialClientMapper.selectBySocialTypeAndUserType(
|
||||
SocialTypeEnum.WECHAT_MP.getType(), userType);
|
||||
@@ -198,7 +200,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* @param clientSecret 微信公众号 secret
|
||||
* @return WxMpService 对象
|
||||
*/
|
||||
private WxMpService buildWxMpService(String clientId, String clientSecret) {
|
||||
public WxMpService buildWxMpService(String clientId, String clientSecret) {
|
||||
// 第一步,创建 WxMpRedisConfigImpl 对象
|
||||
WxMpRedisConfigImpl configStorage = new WxMpRedisConfigImpl(
|
||||
new RedisTemplateWxRedisOps(stringRedisTemplate),
|
||||
@@ -231,7 +233,8 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* @param userType 用户类型
|
||||
* @return WxMpService 对象
|
||||
*/
|
||||
private WxMaService getWxMaService(Integer userType) {
|
||||
@VisibleForTesting
|
||||
WxMaService getWxMaService(Integer userType) {
|
||||
// 第一步,查询 DB 的配置项,获得对应的 WxMaService 对象
|
||||
SocialClientDO client = socialClientMapper.selectBySocialTypeAndUserType(
|
||||
SocialTypeEnum.WECHAT_MINI_APP.getType(), userType);
|
||||
@@ -311,7 +314,6 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* @param userType 用户类型
|
||||
* @param socialType 社交类型
|
||||
*/
|
||||
@VisibleForTesting
|
||||
private void validateSocialClientUnique(Long id, Integer userType, Integer socialType) {
|
||||
SocialClientDO client = socialClientMapper.selectBySocialTypeAndUserType(
|
||||
socialType, userType);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SocialUserServiceImpl implements SocialUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String bindSocialUser(SocialUserBindReqDTO reqDTO) {
|
||||
// 获得社交用户
|
||||
SocialUserDO socialUser = authSocialUser(reqDTO.getSocialType(), reqDTO.getUserType(),
|
||||
@@ -108,7 +108,6 @@ public class SocialUserServiceImpl implements SocialUserService {
|
||||
return new SocialUserRespDTO(socialUser.getOpenid(), socialUserBind.getUserId());
|
||||
}
|
||||
|
||||
// TODO 芋艿:调整下单测
|
||||
/**
|
||||
* 授权获得对应的社交用户
|
||||
* 如果授权失败,则会抛出 {@link ServiceException} 异常
|
||||
|
||||
Reference in New Issue
Block a user