refactor(组织管理): 增加组织列表的测试覆盖率
This commit is contained in:
parent
2646bf82aa
commit
43394a1b28
|
@ -299,12 +299,10 @@ public class OrganizationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> userRoleIds = userIdRoleIdMap.get(orgUserExtend.getId());
|
Set<String> userRoleIds = userIdRoleIdMap.get(orgUserExtend.getId());
|
||||||
if (CollectionUtils.isNotEmpty(userRoleIds)){
|
|
||||||
List<UserRole> userRoleFilters = userRoles.stream().filter(t -> userRoleIds.contains(t.getId())).toList();
|
List<UserRole> userRoleFilters = userRoles.stream().filter(t -> userRoleIds.contains(t.getId())).toList();
|
||||||
List<IdNameStructureDTO> userRoleList = new ArrayList<>();
|
List<IdNameStructureDTO> userRoleList = new ArrayList<>();
|
||||||
setUserRoleList(userRoleList, userRoleFilters);
|
setUserRoleList(userRoleList, userRoleFilters);
|
||||||
orgUserExtend.setUserRoleIdNameMap(userRoleList);
|
orgUserExtend.setUserRoleIdNameMap(userRoleList);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return orgUserExtends;
|
return orgUserExtends;
|
||||||
|
|
|
@ -224,6 +224,11 @@ public class OrganizationControllerTests extends BaseTest {
|
||||||
organizationMemberRequest.setMemberIds(Arrays.asList("sys_default_user", "sys_default_user2"));
|
organizationMemberRequest.setMemberIds(Arrays.asList("sys_default_user", "sys_default_user2"));
|
||||||
organizationMemberRequest.setProjectIds(Arrays.asList("sys_org_projectId2", "sys_org_projectId3"));
|
organizationMemberRequest.setProjectIds(Arrays.asList("sys_org_projectId2", "sys_org_projectId3"));
|
||||||
this.requestPost(ORGANIZATION_PROJECT_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
this.requestPost(ORGANIZATION_PROJECT_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
||||||
|
organizationMemberRequest = new OrgMemberExtendProjectRequest();
|
||||||
|
organizationMemberRequest.setOrganizationId("sys_default_organization_3");
|
||||||
|
organizationMemberRequest.setMemberIds(Arrays.asList("sys_default_user"));
|
||||||
|
organizationMemberRequest.setProjectIds(Arrays.asList("sys_org_projectId2"));
|
||||||
|
this.requestPost(ORGANIZATION_PROJECT_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
||||||
// 批量添加成员成功后, 验证是否添加成功
|
// 批量添加成员成功后, 验证是否添加成功
|
||||||
listByKeyWord("testUserOne", "sys_default_organization_3", false, InternalUserRole.PROJECT_MEMBER.getValue(), "sys_org_projectId2", false, null, null);
|
listByKeyWord("testUserOne", "sys_default_organization_3", false, InternalUserRole.PROJECT_MEMBER.getValue(), "sys_org_projectId2", false, null, null);
|
||||||
}
|
}
|
||||||
|
@ -250,6 +255,8 @@ public class OrganizationControllerTests extends BaseTest {
|
||||||
organizationMemberRequest.setUserRoleIds(Arrays.asList("sys_default_org_role_id_3"));
|
organizationMemberRequest.setUserRoleIds(Arrays.asList("sys_default_org_role_id_3"));
|
||||||
this.requestPost(ORGANIZATION_LIST_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
this.requestPost(ORGANIZATION_LIST_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
||||||
listByKeyWord("testUserThree", "sys_default_organization_3", false, null, null, false, null, null);
|
listByKeyWord("testUserThree", "sys_default_organization_3", false, null, null, false, null, null);
|
||||||
|
listByKeyWord(null, "sys_default_organization_3", false, null, null, false, null, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -488,9 +495,11 @@ public class OrganizationControllerTests extends BaseTest {
|
||||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= organizationRequest.getPageSize());
|
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= organizationRequest.getPageSize());
|
||||||
// 返回值中取出第一条数据, 并判断是否包含关键字admin
|
// 返回值中取出第一条数据, 并判断是否包含关键字admin
|
||||||
OrgUserExtend orgUserExtend = JSON.parseArray(JSON.toJSONString(pageData.getList()), OrgUserExtend.class).get(0);
|
OrgUserExtend orgUserExtend = JSON.parseArray(JSON.toJSONString(pageData.getList()), OrgUserExtend.class).get(0);
|
||||||
|
if (StringUtils.isNotBlank(keyWord)) {
|
||||||
Assertions.assertTrue(StringUtils.contains(orgUserExtend.getName(), organizationRequest.getKeyword())
|
Assertions.assertTrue(StringUtils.contains(orgUserExtend.getName(), organizationRequest.getKeyword())
|
||||||
|| StringUtils.contains(orgUserExtend.getEmail(), organizationRequest.getKeyword())
|
|| StringUtils.contains(orgUserExtend.getEmail(), organizationRequest.getKeyword())
|
||||||
|| StringUtils.contains(orgUserExtend.getPhone(), organizationRequest.getKeyword()));
|
|| StringUtils.contains(orgUserExtend.getPhone(), organizationRequest.getKeyword()));
|
||||||
|
}
|
||||||
if (compare) {
|
if (compare) {
|
||||||
Assertions.assertNotNull(orgUserExtend.getUserRoleIdNameMap());
|
Assertions.assertNotNull(orgUserExtend.getUserRoleIdNameMap());
|
||||||
List<String> userRoleIds = orgUserExtend.getUserRoleIdNameMap().stream().map(IdNameStructureDTO::getId).toList();
|
List<String> userRoleIds = orgUserExtend.getUserRoleIdNameMap().stream().map(IdNameStructureDTO::getId).toList();
|
||||||
|
|
Loading…
Reference in New Issue