### Question:
GuiFragmentController { public void setGuiFragmentValidator(GuiFragmentValidator guiFragmentValidator) { this.guiFragmentValidator = guiFragmentValidator; }  void setGuiFragmentService(IGuiFragmentService guiFragmentService); void setGuiFragmentValidator(GuiFragmentValidator guiFragmentValidator); @RestAccessControl(permission = Permission.SUPERUSER) @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<PagedRestResponse<GuiFragmentDtoSmall>> getGuiFragments(RestListRequest requestList); @RestAccessControl(permission = Permission.SUPERUSER) @RequestMapping(value = "/{fragmentCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<SimpleRestResponse<GuiFragmentDto>> getGuiFragment(@PathVariable String fragmentCode); @RestAccessControl(permission = Permission.SUPERUSER) @RequestMapping(value = "/{fragmentCode}/usage", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<SimpleRestResponse<ComponentUsage>> getComponentUsage(@PathVariable String fragmentCode); @RestAccessControl(permission = Permission.SUPERUSER) @RequestMapping(value = "/{fragmentCode}/usage/details", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<PagedRestResponse<ComponentUsageEntity>> getComponentUsageDetails(@PathVariable String fragmentCode, PageSearchRequest searchRequest); @RestAccessControl(permission = Permission.SUPERUSER) @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<SimpleRestResponse<GuiFragmentDto>> addGuiFragment(@Valid @RequestBody GuiFragmentRequestBody guiFragmentRequest, BindingResult bindingResult); @RestAccessControl(permission = Permission.SUPERUSER) @RequestMapping(value = "/{fragmentCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<SimpleRestResponse<GuiFragmentDto>> updateGuiFragment(@PathVariable String fragmentCode, @Valid @RequestBody GuiFragmentRequestBody guiFragmentRequest, BindingResult bindingResult); @RestAccessControl(permission = Permission.SUPERUSER) @RequestMapping(value = "/{fragmentCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<SimpleRestResponse<Map>> deleteGuiFragment(@PathVariable String fragmentCode); @RestAccessControl(permission = Permission.SUPERUSER) @RequestMapping(value = "/info/plugins", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<SimpleRestResponse<List<String>>> getPluginCodes(); static final String COMPONENT_ID; }### Answer:
@Test public void should_validate_put_path_mismatch() throws ApsSystemException, Exception { UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build(); String accessToken = mockOAuthInterceptor(user); ObjectMapper mapper = new ObjectMapper(); GuiFragmentRequestBody requestBody = new GuiFragmentRequestBody(); requestBody.setCode("__new_fragment_"); requestBody.setGuiCode("<h1>This is the fragment</h1>"); String payload = mapper.writeValueAsString(requestBody); this.controller.setGuiFragmentValidator(new GuiFragmentValidator()); ResultActions result = mockMvc.perform(put("/fragments/{fragmentCode}", "new_fragment") .content(payload) .contentType(MediaType.APPLICATION_JSON) .header("Authorization", "Bearer " + accessToken)); result.andExpect(status().isBadRequest()); String response = result.andReturn().getResponse().getContentAsString(); }