| | |
| | | /** |
| | | * {@link TenantServiceImpl} 的单元测试类 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Import(TenantServiceImpl.class) |
| | | public class TenantServiceImplTest extends BaseDbUnitTest { |
| | |
| | | when(userService.createUser(argThat(user -> { |
| | | assertEquals("yunai", user.getUsername()); |
| | | assertEquals("yuanma", user.getPassword()); |
| | | assertEquals("芋道", user.getNickname()); |
| | | assertEquals("超级管理员", user.getNickname()); |
| | | assertEquals("15601691300", user.getMobile()); |
| | | return true; |
| | | }))).thenReturn(300L); |
| | | |
| | | // 准备参数 |
| | | TenantSaveReqVO reqVO = randomPojo(TenantSaveReqVO.class, o -> { |
| | | o.setContactName("芋道"); |
| | | o.setContactName("超级管理员"); |
| | | o.setContactMobile("15601691300"); |
| | | o.setPackageId(100L); |
| | | o.setStatus(randomCommonStatus()); |
| | |
| | | public void testGetTenantPage() { |
| | | // mock 数据 |
| | | TenantDO dbTenant = randomPojo(TenantDO.class, o -> { // 等会查询到 |
| | | o.setName("芋道源码"); |
| | | o.setName("超级管理员"); |
| | | o.setContactName("芋艿"); |
| | | o.setContactMobile("15601691300"); |
| | | o.setStatus(CommonStatusEnum.ENABLE.getStatus()); |
| | |
| | | tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setCreateTime(buildTime(2021, 12, 12)))); |
| | | // 准备参数 |
| | | TenantPageReqVO reqVO = new TenantPageReqVO(); |
| | | reqVO.setName("芋道"); |
| | | reqVO.setName("超级管理员"); |
| | | reqVO.setContactName("艿"); |
| | | reqVO.setContactMobile("1560"); |
| | | reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); |
| | |
| | | @Test |
| | | public void testGetTenantByName() { |
| | | // mock 数据 |
| | | TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setName("芋道")); |
| | | TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setName("超级管理员")); |
| | | tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 |
| | | |
| | | // 调用 |
| | | TenantDO result = tenantService.getTenantByName("芋道"); |
| | | TenantDO result = tenantService.getTenantByName("超级管理员"); |
| | | // 校验存在 |
| | | assertPojoEquals(result, dbTenant); |
| | | } |