@PutMapping("/{id}")
    @RequiresPermissions("system:plugin:edit")
    public ShenyuAdminResult updatePlugin(@PathVariable("id")
                                          @Existed(message = "plugin is not existed",
                                                  provider = PluginMapper.class) final String id,
                                          @Valid @ModelAttribute final PluginDTO pluginDTO) {
        pluginDTO.setId(id);
        return createPlugin(pluginDTO);
    }
@Test
    public void testUpdatePlugin() throws Exception {
        PluginDTO pluginDTO = new PluginDTO();
        pluginDTO.setId("123");
        pluginDTO.setName("test1");
        pluginDTO.setEnabled(true);
        pluginDTO.setRole("1");
        pluginDTO.setSort(100);
        when(SpringBeanUtils.getInstance().getBean(PluginMapper.class)).thenReturn(pluginMapper);
        when(pluginMapper.existed(pluginDTO.getId())).thenReturn(true);
        given(this.pluginService.createOrUpdate(pluginDTO)).willReturn(ShenyuResultMessage.UPDATE_SUCCESS);
        this.mockMvc.perform(MockMvcRequestBuilders.put("/plugin/{id}", pluginDTO.getId())
                        .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
                        .param("name", pluginDTO.getName())
                        .param("enabled", String.valueOf(pluginDTO.getEnabled()))
                        .param("role", pluginDTO.getRole())
                        .param("sort", String.valueOf(pluginDTO.getSort())))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$.message", is(ShenyuResultMessage.UPDATE_SUCCESS)))
                .andReturn();
        when(pluginMapper.existed(pluginDTO.getId())).thenReturn(null);
        this.mockMvc.perform(MockMvcRequestBuilders.put("/plugin/{id}", pluginDTO.getId())
                        .contentType(MediaType.MULTIPART_FORM_DATA_VALUE)
                        .param("name", pluginDTO.getName())
                        .param("enabled", String.valueOf(pluginDTO.getEnabled()))
                        .param("role", pluginDTO.getRole())
                        .param("sort", String.valueOf(pluginDTO.getSort())))
                .andExpect(jsonPath("$.message", Matchers.containsString("Request error! invalid argument")))
                .andReturn();
        when(pluginMapper.existed(pluginDTO.getId())).thenReturn(true);
        given(this.pluginService.createOrUpdate(pluginDTO)).willReturn(ShenyuResultMessage.CREATE_SUCCESS);
        this.mockMvc.perform(MockMvcRequestBuilders.put("/plugin/{id}", pluginDTO.getId())
                        .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
                        .param("name", pluginDTO.getName())
                        .param("enabled", String.valueOf(pluginDTO.getEnabled()))
                        .param("role", pluginDTO.getRole())
                        .param("sort", String.valueOf(pluginDTO.getSort())))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$.message", is(ShenyuResultMessage.CREATE_SUCCESS)))
                .andReturn();
    }