@Test @Transactional public void testPostUpdate_updatingExistingButWithInvalidJar() throws Exception { final MessageFormat messageFormat = messageFormatTestTools.createMessageFormat("MyMessageFormat" + System.currentTimeMillis()); final String expectedName = messageFormat.getName(); final String expectedClasspath = messageFormat.getClasspath(); final String expectedJarName = messageFormat.getJar(); final String expectedJarContents = "OriginalContents"; final String expectedParametersJson = messageFormat.getOptionParameters(); final Path expectedJarPath = Paths.get(deserializerUploadPath, messageFormat.getJar()); FileTestTools.createDummyFile(deserializerUploadPath + messageFormat.getJar(), expectedJarContents); final MockMultipartFile jarUpload = new MockMultipartFile("file", "testPlugins.jar", null, "MyContent".getBytes(Charsets.UTF_8)); mockMvc .perform(multipart("/configuration/messageFormat/update") .file(jarUpload) .with(user(adminUserDetails)) .with(csrf()) .param("id", String.valueOf(messageFormat.getId())) .param("name", "Updated Name") .param("classpath", "made.up.classpath") .param("customOptionNames", "option1") .param("customOptionNames", "option2") .param("customOptionValues", "value1") .param("customOptionValues", "value2")) .andExpect(model().hasErrors()) .andExpect(model().attributeHasFieldErrors("messageFormatForm", "file")) .andExpect(status().isOk()); final MessageFormat updatedMessageFormat = messageFormatRepository.findById(messageFormat.getId()).get(); assertNotNull("Has message format", updatedMessageFormat); assertEquals("Name not updated", expectedName, updatedMessageFormat.getName()); assertEquals("classpath not updated", expectedClasspath, updatedMessageFormat.getClasspath()); assertEquals("Jar name not updated", expectedJarName, updatedMessageFormat.getJar()); assertFalse("Should not be a default format", updatedMessageFormat.isDefaultFormat()); assertEquals("Parameters not updated", expectedParametersJson, updatedMessageFormat.getOptionParameters()); assertTrue("File should exist", Files.exists(expectedJarPath)); final String jarContents = FileTestTools.readFile(expectedJarPath.toString()); assertEquals("Jar contents should not have changed", expectedJarContents, jarContents); Files.deleteIfExists(expectedJarPath); }
@RequestMapping(path = "/create", method = RequestMethod.GET) public String createMessageFormat(final MessageFormatForm messageFormatForm, final Model model) { setupBreadCrumbs(model, "Create", null); return "configuration/messageFormat/create"; }
MessageFormatController extends BaseController { @RequestMapping(path = "/create", method = RequestMethod.GET) public String createMessageFormat(final MessageFormatForm messageFormatForm, final Model model) { setupBreadCrumbs(model, "Create", null); return "configuration/messageFormat/create"; } }
MessageFormatController extends BaseController { @RequestMapping(path = "/create", method = RequestMethod.GET) public String createMessageFormat(final MessageFormatForm messageFormatForm, final Model model) { setupBreadCrumbs(model, "Create", null); return "configuration/messageFormat/create"; }  }
MessageFormatController extends BaseController { @RequestMapping(path = "/create", method = RequestMethod.GET) public String createMessageFormat(final MessageFormatForm messageFormatForm, final Model model) { setupBreadCrumbs(model, "Create", null); return "configuration/messageFormat/create"; }  @RequestMapping(path = "", method = RequestMethod.GET) String index(final Model model); @RequestMapping(path = "/create", method = RequestMethod.GET) String createMessageFormat(final MessageFormatForm messageFormatForm, final Model model); @RequestMapping(path = "/edit/{id}", method = RequestMethod.GET) String editMessageFormat(
        @PathVariable final Long id,
        final MessageFormatForm messageFormatForm,
        final Model model,
        final RedirectAttributes redirectAttributes); @RequestMapping(path = "/update", method = RequestMethod.POST) String create(
        @Valid final MessageFormatForm messageFormatForm,
        final BindingResult bindingResult,
        final RedirectAttributes redirectAttributes,
        @RequestParam final Map<String, String> allRequestParams); @RequestMapping(path = "/delete/{id}", method = RequestMethod.POST) String deleteCluster(@PathVariable final Long id, final RedirectAttributes redirectAttributes); }
MessageFormatController extends BaseController { @RequestMapping(path = "/create", method = RequestMethod.GET) public String createMessageFormat(final MessageFormatForm messageFormatForm, final Model model) { setupBreadCrumbs(model, "Create", null); return "configuration/messageFormat/create"; }  @RequestMapping(path = "", method = RequestMethod.GET) String index(final Model model); @RequestMapping(path = "/create", method = RequestMethod.GET) String createMessageFormat(final MessageFormatForm messageFormatForm, final Model model); @RequestMapping(path = "/edit/{id}", method = RequestMethod.GET) String editMessageFormat(
        @PathVariable final Long id,
        final MessageFormatForm messageFormatForm,
        final Model model,
        final RedirectAttributes redirectAttributes); @RequestMapping(path = "/update", method = RequestMethod.POST) String create(
        @Valid final MessageFormatForm messageFormatForm,
        final BindingResult bindingResult,
        final RedirectAttributes redirectAttributes,
        @RequestParam final Map<String, String> allRequestParams); @RequestMapping(path = "/delete/{id}", method = RequestMethod.POST) String deleteCluster(@PathVariable final Long id, final RedirectAttributes redirectAttributes);  }