@PutMapping("/{id}")
    public ShenyuAdminResult updateRule(@PathVariable("id") @Valid
                                        @Existed(provider = RuleMapper.class,
                                                message = "rule is not existed") final String id,
                                        @Valid @RequestBody final RuleDTO ruleDTO) {
        ruleDTO.setId(id);
        Integer updateCount = ruleService.createOrUpdate(ruleDTO);
        return ShenyuAdminResult.success(ShenyuResultMessage.UPDATE_SUCCESS, updateCount);
    }
@Test
    public void testUpdateRule() throws Exception {
        RuleConditionDTO ruleConditionDTO = RuleConditionDTO.builder()
                .id("888")
                .ruleId("666")
                .paramType("uri")
                .operator("match")
                .paramName("/")
                .paramValue("/http/order/update")
                .build();
        List<RuleConditionDTO> conList = new ArrayList<>();
        conList.add(ruleConditionDTO);

        RuleDTO ruleDTO = RuleDTO.builder()
                .id("666")
                .selectorId("168")
                .matchMode(0)
                .name("/http/order/update")
                .enabled(true)
                .loged(true)
                .matchRestful(false)
                .sort(1)
                .handle("{\"loadBalance\":\"random\",\"retry\":0,\"timeout\":3000}")
                .ruleConditions(conList)
                .build();
        SpringBeanUtils.getInstance().setApplicationContext(mock(ConfigurableApplicationContext.class));
        when(SpringBeanUtils.getInstance().getBean(RuleMapper.class)).thenReturn(ruleMapper);
        when(ruleMapper.existed(ruleDTO.getId())).thenReturn(true);
        when(SpringBeanUtils.getInstance().getBean(SelectorMapper.class)).thenReturn(selectorMapper);
        when(selectorMapper.existed(ruleDTO.getSelectorId())).thenReturn(true);
        given(this.ruleService.createOrUpdate(ruleDTO)).willReturn(1);
        this.mockMvc.perform(MockMvcRequestBuilders.put("/rule/{id}", "666")
                        .contentType(MediaType.APPLICATION_JSON)
                        .content(GsonUtils.getInstance().toJson(ruleDTO))
                )
                .andExpect(status().isOk())
                .andExpect(jsonPath("$.message", is(ShenyuResultMessage.UPDATE_SUCCESS)))
                .andReturn();
    }