1. 新增分页接口聚合查询注解支持
2. 优化 databus api 日志记录的字段缺失问题 3. 新增 eplat sso 页面登录校验 4. 用户、部门编辑新增 seata 事务支持 5. 新增 iwork 流程发起接口 6. 新增 eban 同步用户时的岗位处理逻辑 7. 新增无 skywalking 时的 traceId 支持
This commit is contained in:
@@ -17,8 +17,6 @@ import com.zt.plat.module.system.enums.logger.LoginResultEnum;
|
||||
import com.zt.plat.module.system.enums.sms.SmsSceneEnum;
|
||||
import com.zt.plat.module.system.enums.social.SocialTypeEnum;
|
||||
import com.zt.plat.module.system.service.logger.LoginLogService;
|
||||
import com.zt.plat.module.system.service.member.MemberService;
|
||||
import com.zt.plat.module.system.service.oauth2.EbanOAuth2Service;
|
||||
import com.zt.plat.module.system.service.oauth2.OAuth2TokenService;
|
||||
import com.zt.plat.module.system.service.social.SocialUserService;
|
||||
import com.zt.plat.module.system.service.user.AdminUserService;
|
||||
@@ -60,10 +58,6 @@ public class AdminAuthServiceImplTest extends BaseDbUnitTest {
|
||||
@MockBean
|
||||
private OAuth2TokenService oauth2TokenService;
|
||||
@MockBean
|
||||
private MemberService memberService;
|
||||
@MockBean
|
||||
private EbanOAuth2Service ebanOAuth2Service;
|
||||
@MockBean
|
||||
private Validator validator;
|
||||
|
||||
@BeforeEach
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,44 @@
|
||||
package com.zt.plat.module.system.service.sso.client;
|
||||
|
||||
import com.zt.plat.module.system.framework.sso.config.ExternalSsoProperties;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* 仅加载 ExternalSsoClientConfiguration,校验上下文能成功创建 ExternalSsoClient Bean。
|
||||
* 使用 Mock 的 RedisTemplate,避免外部依赖。
|
||||
*/
|
||||
@SpringBootTest(classes = { ExternalSsoClientConfiguration.class, ExternalSsoClientConfigurationLoadTest.TestBeans.class })
|
||||
@Import(ExternalSsoProperties.class)
|
||||
class ExternalSsoClientConfigurationLoadTest {
|
||||
|
||||
@TestConfiguration
|
||||
static class TestBeans {
|
||||
@Bean
|
||||
public StringRedisTemplate stringRedisTemplate() {
|
||||
return mock(StringRedisTemplate.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ExternalSsoProperties externalSsoProperties() {
|
||||
ExternalSsoProperties props = new ExternalSsoProperties();
|
||||
// 提供必要的基础配置,避免初始化过程出现 NPE
|
||||
props.getRemote().setBaseUrl("http://localhost");
|
||||
return props;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void contextLoads(org.springframework.context.ApplicationContext context) {
|
||||
Object bean = context.getBean(ExternalSsoClient.class);
|
||||
assertThat(bean).isNotNull();
|
||||
assertThat(bean).isInstanceOf(DefaultExternalSsoClient.class);
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,7 @@ import com.zt.plat.module.system.service.userdept.UserDeptService;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -57,25 +54,60 @@ public class UserSyncServiceImplTest extends BaseMockitoUnitTest {
|
||||
securityFrameworkUtilsMock.close();
|
||||
}
|
||||
|
||||
// @Test
|
||||
// void testCreateUser() {
|
||||
// // Arrange
|
||||
// UserCreateRequestVO requestVO = randomPojo(UserCreateRequestVO.class);
|
||||
// Long newUserId = randomLongId();
|
||||
// when(adminUserService.createUser(any(UserSaveReqVO.class))).thenReturn(newUserId);
|
||||
//
|
||||
// // Act
|
||||
// UserCreateResponseVO response = userSyncService.createUser(requestVO);
|
||||
//
|
||||
// // Assert
|
||||
// assertNotNull(response);
|
||||
// assertEquals("0", response.getResultCode());
|
||||
// assertEquals("success", response.getMessage());
|
||||
// assertEquals(String.valueOf(newUserId), response.getUid());
|
||||
// assertEquals(requestVO.getBimRequestId(), response.getBimRequestId());
|
||||
//
|
||||
// verify(adminUserService).createUser(any(UserSaveReqVO.class));
|
||||
// }
|
||||
@Test
|
||||
void testCreateUser_WithPostName() {
|
||||
// Arrange
|
||||
UserCreateRequestVO requestVO = randomPojo(UserCreateRequestVO.class, vo -> {
|
||||
vo.setPostName("岗位A");
|
||||
vo.setDeptIds(null);
|
||||
});
|
||||
Long newUserId = randomLongId();
|
||||
Long postId = randomLongId();
|
||||
when(postService.getOrCreatePostByName(requestVO.getPostName())).thenReturn(postId);
|
||||
when(adminUserService.createUser(any(UserSaveReqVO.class))).thenReturn(newUserId);
|
||||
|
||||
// Act
|
||||
UserCreateResponseVO response = userSyncService.createUser(requestVO);
|
||||
|
||||
// Assert
|
||||
assertNotNull(response);
|
||||
assertEquals("0", response.getResultCode());
|
||||
assertEquals("success", response.getMessage());
|
||||
assertEquals(String.valueOf(newUserId), response.getUid());
|
||||
assertEquals(requestVO.getBimRequestId(), response.getBimRequestId());
|
||||
|
||||
ArgumentCaptor<UserSaveReqVO> captor = ArgumentCaptor.forClass(UserSaveReqVO.class);
|
||||
verify(adminUserService).createUser(captor.capture());
|
||||
assertNotNull(captor.getValue().getPostIds());
|
||||
assertTrue(captor.getValue().getPostIds().contains(postId));
|
||||
verify(postService).getOrCreatePostByName(requestVO.getPostName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateUser_WithoutPostName() {
|
||||
// Arrange
|
||||
UserCreateRequestVO requestVO = randomPojo(UserCreateRequestVO.class, vo -> {
|
||||
vo.setPostName(null);
|
||||
vo.setDeptIds(null);
|
||||
});
|
||||
Long newUserId = randomLongId();
|
||||
when(adminUserService.createUser(any(UserSaveReqVO.class))).thenReturn(newUserId);
|
||||
|
||||
// Act
|
||||
UserCreateResponseVO response = userSyncService.createUser(requestVO);
|
||||
|
||||
// Assert
|
||||
assertNotNull(response);
|
||||
assertEquals("0", response.getResultCode());
|
||||
assertEquals("success", response.getMessage());
|
||||
assertEquals(String.valueOf(newUserId), response.getUid());
|
||||
assertEquals(requestVO.getBimRequestId(), response.getBimRequestId());
|
||||
|
||||
ArgumentCaptor<UserSaveReqVO> captor = ArgumentCaptor.forClass(UserSaveReqVO.class);
|
||||
verify(adminUserService).createUser(captor.capture());
|
||||
assertTrue(captor.getValue().getPostIds() == null || captor.getValue().getPostIds().isEmpty());
|
||||
verify(postService, never()).getOrCreatePostByName(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteUser_Success() {
|
||||
|
||||
@@ -649,6 +649,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
|
||||
o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围
|
||||
o.setSex(randomEle(SexEnum.values()).getSex());
|
||||
o.setDeptIds(new HashSet<>(asSet(1L, 2L)));
|
||||
o.setDeptNames("-");
|
||||
o.setCompanyDeptInfos(null);// 保证 deptIds 的范围
|
||||
o.setUserSource(null);
|
||||
};
|
||||
|
||||
@@ -2,6 +2,16 @@ spring:
|
||||
main:
|
||||
lazy-initialization: true # 开启懒加载,加快速度
|
||||
banner-mode: off # 单元测试,禁用 Banner
|
||||
config:
|
||||
import: optional:classpath:application-unit-test-config.yaml # 覆盖主配置中的 Nacos 导入,避免单测加载远程配置
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
enabled: false
|
||||
import-check:
|
||||
enabled: false
|
||||
discovery:
|
||||
enabled: false
|
||||
|
||||
--- #################### 数据库相关配置 ####################
|
||||
|
||||
@@ -37,6 +47,16 @@ mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
config:
|
||||
server-addr: 127.0.0.1:8848
|
||||
namespace: unit-test
|
||||
group: DEFAULT_GROUP
|
||||
username:
|
||||
password:
|
||||
|
||||
env:
|
||||
name: unit-test
|
||||
|
||||
--- #################### 定时任务相关配置 ####################
|
||||
|
||||
--- #################### 配置中心相关配置 ####################
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
spring:
|
||||
config:
|
||||
import: optional:classpath:application-unit-test-config.yaml
|
||||
application:
|
||||
name: system-server
|
||||
profiles:
|
||||
active: unit-test
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
enabled: false
|
||||
import-check:
|
||||
enabled: false
|
||||
discovery:
|
||||
enabled: false
|
||||
|
||||
config:
|
||||
server-addr: 127.0.0.1:8848
|
||||
namespace: unit-test
|
||||
group: DEFAULT_GROUP
|
||||
username:
|
||||
password:
|
||||
|
||||
env:
|
||||
name: unit-test
|
||||
Reference in New Issue
Block a user