mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
system微服务api模块、枚举单元测试完善
This commit is contained in:
-13
@@ -1,7 +1,6 @@
|
||||
package com.cf.imes.module.system.api.user;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.collection.CollectionUtils;
|
||||
import com.cf.imes.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.cf.imes.module.system.api.user.dto.OrganAdminUserRespDTO;
|
||||
import com.cf.imes.module.system.enums.ApiConstants;
|
||||
@@ -15,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory =
|
||||
@@ -44,17 +42,6 @@ public interface AdminUserApi {
|
||||
@Parameter(name = "postIds", description = "岗位编号数组", example = "2,3", required = true)
|
||||
CommonResult<List<AdminUserRespDTO>> getUserListByPostIds(@RequestParam("postIds") Collection<Long> postIds);
|
||||
|
||||
/**
|
||||
* 获得用户 Map
|
||||
*
|
||||
* @param ids 用户编号数组
|
||||
* @return 用户 Map
|
||||
*/
|
||||
default Map<Long, AdminUserRespDTO> getUserMap(Collection<Long> ids) {
|
||||
List<AdminUserRespDTO> users = getUserList(ids).getCheckedData();
|
||||
return CollectionUtils.convertMap(users, AdminUserRespDTO::getId);
|
||||
}
|
||||
|
||||
@GetMapping(PREFIX + "/valid")
|
||||
@Operation(summary = "校验用户们是否有效")
|
||||
@Parameter(name = "ids", description = "用户编号数组", example = "3,5", required = true)
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.cf.imes.module.system.api.organ;
|
||||
|
||||
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsIsLapseRespDTO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link OrgStatisticsIsLapseRespDTO} 的单元测试
|
||||
*/
|
||||
public class OrgStatisticsIsLapseRespDTOTest {
|
||||
private OrgStatisticsIsLapseRespDTO dto(String date, int status) {
|
||||
return OrgStatisticsIsLapseRespDTO.builder()
|
||||
.date(date)
|
||||
.orgStatus(status)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCompareDifferentYear() {
|
||||
// 年份大 > 小
|
||||
assertTrue(dto("2023-01-02", 1).compareTo(dto("2022-01-02", 1)) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCompareDifferentMonth() {
|
||||
// 月份大 > 小
|
||||
assertTrue(dto("2023-05-01", 1).compareTo(dto("2023-03-01", 1)) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCompareDifferentWeek() {
|
||||
// 周 大 > 小
|
||||
assertTrue(dto("2023-05-02", 1).compareTo(dto("2023-05-01", 1)) > 0);
|
||||
// 相同周 状态小 < 大
|
||||
assertTrue(dto("2023-05-02", 1).compareTo(dto("2023-05-02", 2)) < 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBothWithoutWeek() {
|
||||
// 都不带周 状态大 > 小
|
||||
assertTrue(dto("2023-05", 2).compareTo(dto("2023-05", 1)) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOneWithoutMonth() {
|
||||
// 前不带月, 状态小 < 大
|
||||
assertTrue(dto("2023", 1).compareTo(dto("2023-05", 2)) < 0);
|
||||
// 后不带月, 状态大 > 小
|
||||
assertTrue(dto("2023-05", 2).compareTo(dto("2023", 1)) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOneWithoutWeek() {
|
||||
// 前不带周, 状态小 < 大
|
||||
assertTrue(dto("2023-05", 1).compareTo(dto("2023-05-02", 2)) < 0);
|
||||
// 后不带周, 状态大 > 小
|
||||
assertTrue(dto("2023-05-02", 2).compareTo(dto("2023-05", 1)) > 0);
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.cf.imes.module.system.api.permission.dto;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* {@link com.cf.imes.module.system.api.permission.dto.DeptDataPermissionRespDTO} 的单元测试
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2025/12/12 9:47
|
||||
*/
|
||||
public class DeptDataPermissionRespDTOTest {
|
||||
@Test
|
||||
void test() {
|
||||
DeptDataPermissionRespDTO deptDataPermissionRespDTO = new DeptDataPermissionRespDTO();
|
||||
assertEquals(deptDataPermissionRespDTO.getAll(), false);
|
||||
assertEquals(deptDataPermissionRespDTO.getSelf(), false);
|
||||
assertEquals(deptDataPermissionRespDTO.getDeptIds().size(), 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user