mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
✅ 增加 dept 模块的单测覆盖率
This commit is contained in:
parent
dab751dc74
commit
4dab6d0217
@ -1,6 +1,5 @@
|
||||
package cn.iocoder.yudao.module.system.service.dept;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostSaveReqVO;
|
||||
@ -10,8 +9,6 @@ import org.springframework.lang.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet;
|
||||
|
||||
/**
|
||||
* 岗位 Service 接口
|
||||
*
|
||||
@ -44,12 +41,10 @@ public interface PostService {
|
||||
/**
|
||||
* 获得岗位列表
|
||||
*
|
||||
* @param ids 岗位编号数组。如果为空,不进行筛选
|
||||
* @param ids 岗位编号数组
|
||||
* @return 部门列表
|
||||
*/
|
||||
default List<PostDO> getPostList(@Nullable Collection<Long> ids) {
|
||||
return getPostList(ids, asSet(CommonStatusEnum.ENABLE.getStatus(), CommonStatusEnum.DISABLE.getStatus()));
|
||||
}
|
||||
List<PostDO> getPostList(@Nullable Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得符合条件的岗位列表
|
||||
@ -58,7 +53,8 @@ public interface PostService {
|
||||
* @param statuses 状态数组。如果为空,不进行筛选
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<PostDO> getPostList(@Nullable Collection<Long> ids, @Nullable Collection<Integer> statuses);
|
||||
List<PostDO> getPostList(@Nullable Collection<Long> ids,
|
||||
@Nullable Collection<Integer> statuses);
|
||||
|
||||
/**
|
||||
* 获得岗位分页列表
|
||||
|
@ -13,6 +13,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -107,6 +108,14 @@ public class PostServiceImpl implements PostService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PostDO> getPostList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return postMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PostDO> getPostList(Collection<Long> ids, Collection<Integer> statuses) {
|
||||
return postMapper.selectList(ids, statuses);
|
||||
|
@ -155,6 +155,24 @@ public class PostServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Test
|
||||
public void testGetPostList() {
|
||||
// mock 数据
|
||||
PostDO postDO01 = randomPojo(PostDO.class);
|
||||
postMapper.insert(postDO01);
|
||||
// 测试 id 不匹配
|
||||
PostDO postDO02 = randomPojo(PostDO.class);
|
||||
postMapper.insert(postDO02);
|
||||
// 准备参数
|
||||
List<Long> ids = singletonList(postDO01.getId());
|
||||
|
||||
// 调用
|
||||
List<PostDO> list = postService.getPostList(ids);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(postDO01, list.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPostList_idsAndStatus() {
|
||||
// mock 数据
|
||||
PostDO postDO01 = randomPojo(PostDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
postMapper.insert(postDO01);
|
||||
|
Loading…
Reference in New Issue
Block a user