@PostMapping("")
    @RequiresPermissions("system:role:add")
    public ShenyuAdminResult createRole(@Valid @RequestBody final RoleDTO roleDTO) {
        if (SUPER.equals(roleDTO.getRoleName())) {
            return ShenyuAdminResult.error(ShenyuResultMessage.ROLE_CREATE_ERROR);
        }
        return ShenyuAdminResult.success(ShenyuResultMessage.CREATE_SUCCESS, roleService.createOrUpdate(roleDTO));
    }
@Test
    public void testCreateRole() throws Exception {
        RoleDTO roleDTO = buildRoleDTO();
        given(roleService.createOrUpdate(roleDTO)).willReturn(1);
        SpringBeanUtils.getInstance().setApplicationContext(mock(ConfigurableApplicationContext.class));
        when(SpringBeanUtils.getInstance().getBean(RoleMapper.class)).thenReturn(roleMapper);
        when(roleMapper.existed(roleDTO.getId())).thenReturn(true);
        this.mockMvc.perform(MockMvcRequestBuilders.post("/role")
            .contentType(MediaType.APPLICATION_JSON)
            .content(GsonUtils.getInstance().toJson(roleDTO)))
            .andExpect(status().isOk())
            .andExpect(jsonPath("$.message", is(ShenyuResultMessage.CREATE_SUCCESS)))
            .andReturn();
        roleDTO.setRoleName(SUPER);
        given(roleService.createOrUpdate(roleDTO)).willReturn(1);
        this.mockMvc.perform(MockMvcRequestBuilders.post("/role")
            .contentType(MediaType.APPLICATION_JSON)
            .content(GsonUtils.getInstance().toJson(roleDTO)))
            .andExpect(status().isOk())
            .andExpect(jsonPath("$.message", is(ShenyuResultMessage.ROLE_CREATE_ERROR)))
            .andReturn();
    }