完善 TenantServiceImpl 单元测试

This commit is contained in:
YunaiV 2023-02-02 23:47:17 +08:00
parent 83003021e1
commit 1d3ca8a990
2 changed files with 4 additions and 4 deletions

View File

@ -138,7 +138,7 @@ public class TenantServiceImpl implements TenantService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateTenant(TenantUpdateReqVO updateReqVO) { public void updateTenant(TenantUpdateReqVO updateReqVO) {
// 校验存在 // 校验存在
TenantDO tenant = checkUpdateTenant(updateReqVO.getId()); TenantDO tenant = validateUpdateTenant(updateReqVO.getId());
// 校验套餐被禁用 // 校验套餐被禁用
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId()); TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId());
@ -179,12 +179,12 @@ public class TenantServiceImpl implements TenantService {
@Override @Override
public void deleteTenant(Long id) { public void deleteTenant(Long id) {
// 校验存在 // 校验存在
checkUpdateTenant(id); validateUpdateTenant(id);
// 删除 // 删除
tenantMapper.deleteById(id); tenantMapper.deleteById(id);
} }
private TenantDO checkUpdateTenant(Long id) { private TenantDO validateUpdateTenant(Long id) {
TenantDO tenant = tenantMapper.selectById(id); TenantDO tenant = tenantMapper.selectById(id);
if (tenant == null) { if (tenant == null) {
throw exception(TENANT_NOT_EXISTS); throw exception(TENANT_NOT_EXISTS);

View File

@ -196,7 +196,7 @@ public class TenantServiceImplTest extends BaseDbUnitTest {
role100.setTenantId(dbTenant.getId()); role100.setTenantId(dbTenant.getId());
RoleDO role101 = randomPojo(RoleDO.class, o -> o.setId(101L)); RoleDO role101 = randomPojo(RoleDO.class, o -> o.setId(101L));
role101.setTenantId(dbTenant.getId()); role101.setTenantId(dbTenant.getId());
when(roleService.getRoleList(isNull())).thenReturn(asList(role100, role101)); when(roleService.getRoleListByStatus(isNull())).thenReturn(asList(role100, role101));
// mock 每个角色的权限 // mock 每个角色的权限
when(permissionService.getRoleMenuIds(eq(101L))).thenReturn(asSet(201L, 202L)); when(permissionService.getRoleMenuIds(eq(101L))).thenReturn(asSet(201L, 202L));