完善 TenantServiceImpl 单元测试
This commit is contained in:
parent
83003021e1
commit
1d3ca8a990
@ -138,7 +138,7 @@ public class TenantServiceImpl implements TenantService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTenant(TenantUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
TenantDO tenant = checkUpdateTenant(updateReqVO.getId());
|
||||
TenantDO tenant = validateUpdateTenant(updateReqVO.getId());
|
||||
// 校验套餐被禁用
|
||||
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId());
|
||||
|
||||
@ -179,12 +179,12 @@ public class TenantServiceImpl implements TenantService {
|
||||
@Override
|
||||
public void deleteTenant(Long id) {
|
||||
// 校验存在
|
||||
checkUpdateTenant(id);
|
||||
validateUpdateTenant(id);
|
||||
// 删除
|
||||
tenantMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private TenantDO checkUpdateTenant(Long id) {
|
||||
private TenantDO validateUpdateTenant(Long id) {
|
||||
TenantDO tenant = tenantMapper.selectById(id);
|
||||
if (tenant == null) {
|
||||
throw exception(TENANT_NOT_EXISTS);
|
||||
|
@ -196,7 +196,7 @@ public class TenantServiceImplTest extends BaseDbUnitTest {
|
||||
role100.setTenantId(dbTenant.getId());
|
||||
RoleDO role101 = randomPojo(RoleDO.class, o -> o.setId(101L));
|
||||
role101.setTenantId(dbTenant.getId());
|
||||
when(roleService.getRoleList(isNull())).thenReturn(asList(role100, role101));
|
||||
when(roleService.getRoleListByStatus(isNull())).thenReturn(asList(role100, role101));
|
||||
// mock 每个角色的权限
|
||||
when(permissionService.getRoleMenuIds(eq(101L))).thenReturn(asSet(201L, 202L));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user