feat(REQ-2298): 单测示例commit
This commit is contained in:
parent
1e1d35ef7b
commit
a144671ecb
@ -0,0 +1,53 @@
|
||||
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.roleuser.req.RoleUserReq;
|
||||
import cn.axzo.tyr.server.controller.roleuser.RoleUserController;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasRoleUserRelationDao;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleUserRelation;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author likunpeng
|
||||
* @version 1.0
|
||||
* @date 2024/5/24
|
||||
*/
|
||||
public class RoleUserControllerTest extends BaseTest {
|
||||
|
||||
@Autowired
|
||||
private RoleUserController roleUserController;
|
||||
@Autowired
|
||||
private SaasRoleUserRelationDao saasRoleUserRelationDao;
|
||||
|
||||
@Test
|
||||
@Rollback
|
||||
public void testSaveOrUpdate() {
|
||||
Long workspaceId = 2L;
|
||||
Long ouId = 1L;
|
||||
Long identityId = 1L;
|
||||
IdentityType identityType = IdentityType.PRACTITIONER;
|
||||
RoleUserReq req = RoleUserReq.builder()
|
||||
.workspaceId(workspaceId)
|
||||
.ouId(ouId)
|
||||
.identityId(identityId)
|
||||
.updateRoleIds(Sets.newHashSet(1L))
|
||||
.identityType(IdentityType.PRACTITIONER)
|
||||
.build();
|
||||
|
||||
ApiResult<Void> apiResult = roleUserController.saveOrUpdate(req);
|
||||
Assertions.assertEquals(apiResult.getCode(), HttpStatus.HTTP_OK, "保存用户权限误");
|
||||
|
||||
List<SaasRoleUserRelation> saasRoleUserRelations = saasRoleUserRelationDao.query(identityId, identityType.getCode(), workspaceId, ouId);
|
||||
Assertions.assertTrue(CollectionUtils.isNotEmpty(saasRoleUserRelations), "用户权限未保存成功");
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -31,6 +32,7 @@ public class DemoTest extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Rollback
|
||||
public void testDeleteUserRole() {
|
||||
Long personId = 1L;
|
||||
Long workspaceId = 1L;
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
select 1;
|
||||
|
||||
-- saas_role 表初始化数据
|
||||
INSERT INTO `saas_role` (`id`, `NAME`, `description`, `role_type`, `role_code`, `workspace_id`, `owner_ou_id`, `product_unit_type`, `workspace_type`, `is_delete`, `create_at`, `update_at`, `create_by`, `update_by`, `fit_ou_type_bit`, `fit_ou_node_type_bit`, `position_template_id`, `project_team_manage_role_resource_id`, `from_pre_role_id`, `job_code`, `is_display`, `enabled`, `sort`) VALUES (1, '代班长', '', 'common', '7722', 2, 1, 0, 2, 0, '2022-10-19 15:53:32', '2024-04-17 11:02:19', 0, 0, 32, 1, 2, 59, 0, '', 1, 1, 1);
|
||||
|
||||
-- saas_role_user_relation 表初始化数据
|
||||
-- DemoTest.testDeleteUserRole 使用
|
||||
INSERT INTO `saas_role_user_relation` (`id`, `identity_id`, `role_id`, `identity_type`, `natural_person_id`, `workspace_id`, `ou_id`, `resource_type`, `resource_id`, `is_delete`, `create_at`, `update_at`, `create_by`, `update_by`, `job_type`) VALUES (1, 2008231, 100001, 2, 1, 1, 1, 1, 9592, 0, '2024-05-22 18:23:40', '2024-05-22 18:23:39', 0, 0, 2);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user