feat(REQ-2298): 单测示例commit
This commit is contained in:
parent
a144671ecb
commit
163457c815
@ -3,6 +3,8 @@ package cn.axzo.tyr.server.controller;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.base.BaseTest;
|
||||
import cn.axzo.tyr.client.model.enums.IdentityType;
|
||||
import cn.axzo.tyr.client.model.enums.WorkerLeaderRoleEnum;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.GantOrUnGantaWorkerLeaderRoleReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
||||
import cn.axzo.tyr.server.controller.roleuser.RoleUserController;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasRoleUserRelationDao;
|
||||
@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author likunpeng
|
||||
@ -50,4 +53,31 @@ public class RoleUserControllerTest extends BaseTest {
|
||||
List<SaasRoleUserRelation> saasRoleUserRelations = saasRoleUserRelationDao.query(identityId, identityType.getCode(), workspaceId, ouId);
|
||||
Assertions.assertTrue(CollectionUtils.isNotEmpty(saasRoleUserRelations), "用户权限未保存成功");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Rollback
|
||||
public void testGrantOrUngrantWorkerLeader() {
|
||||
Long workspaceId = 2L;
|
||||
Long ouId = 1L;
|
||||
Long teamOuId = 1L;
|
||||
Long identityId = 1L;
|
||||
Long personId = 1L;
|
||||
Long roleId = 100000L;
|
||||
GantOrUnGantaWorkerLeaderRoleReq req = GantOrUnGantaWorkerLeaderRoleReq.builder()
|
||||
.workspaceId(workspaceId)
|
||||
.ouId(ouId)
|
||||
.teamOuId(teamOuId)
|
||||
.identityId(identityId)
|
||||
.personId(personId)
|
||||
.grant(Boolean.TRUE)
|
||||
.workerLeaderRoleEnum(WorkerLeaderRoleEnum.ENT_TEAM_MANAGER)
|
||||
.build();
|
||||
ApiResult<Void> apiResult = roleUserController.grantOrUngrantWorkerLeader(req);
|
||||
Assertions.assertEquals(apiResult.getCode(), HttpStatus.HTTP_OK, "授权平台班组长角色有误");
|
||||
|
||||
List<SaasRoleUserRelation> saasRoleUserRelations = saasRoleUserRelationDao.queryByPersonId(personId, workspaceId, ouId);
|
||||
Assertions.assertTrue(CollectionUtils.isNotEmpty(saasRoleUserRelations), "授权平台班组长角色有误");
|
||||
List<Long> roleIds = saasRoleUserRelations.stream().map(SaasRoleUserRelation::getRoleId).collect(Collectors.toList());
|
||||
Assertions.assertTrue(roleIds.contains(roleId), "授权平台班组长角色有误");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user