@Test @Transactional public void testPostUpdate_updatingExistingNoJarUploaded() throws Exception { final MessageFormat messageFormat = messageFormatTestTools.createMessageFormat("MyMessageFormat" + System.currentTimeMillis()); final String originalClasspath = messageFormat.getClasspath(); final String originalJarName = messageFormat.getJar(); final String originalJarContents = "OriginalContents"; final Path originalJarPath = Paths.get(deserializerUploadPath, messageFormat.getJar()); FileTestTools.createDummyFile(deserializerUploadPath + messageFormat.getJar(), originalJarContents); final InputStream emptyFile = null; final MockMultipartFile jarUpload = new MockMultipartFile("file", "testPlugins.jar", null, emptyFile); final String newName = "MyUpdatedName" + System.currentTimeMillis(); final String newClasspath = "my new class path"; mockMvc .perform(multipart("/configuration/messageFormat/update") .file(jarUpload) .with(user(adminUserDetails)) .with(csrf()) .param("id", String.valueOf(messageFormat.getId())) .param("name", newName) .param("classpath", newClasspath) .param("customOptionNames", "option1") .param("customOptionNames", "option2") .param("customOptionValues", "value1") .param("customOptionValues", "value2")) .andExpect(model().hasNoErrors()) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl("/configuration/messageFormat")); final MessageFormat updatedMessageFormat = messageFormatRepository.findById(messageFormat.getId()).get(); assertNotNull("Has message format", updatedMessageFormat); assertEquals("Name updated", newName, updatedMessageFormat.getName()); assertEquals("classpath was NOT updated", originalClasspath, updatedMessageFormat.getClasspath()); assertNotEquals("classpath was NOT updated", newClasspath, updatedMessageFormat.getClasspath()); assertEquals("Jar name not updated", originalJarName, updatedMessageFormat.getJar()); assertFalse("Should not be a default format", updatedMessageFormat.isDefaultFormat()); final String expectedOptionsJson = "{\"option1\":\"value1\",\"option2\":\"value2\"}"; assertEquals("Parameters should have been updated", expectedOptionsJson, updatedMessageFormat.getOptionParameters()); assertTrue("File should exist", Files.exists(originalJarPath)); final String jarContents = FileTestTools.readFile(originalJarPath.toString()); assertEquals("Jar contents should not have changed", originalJarContents, jarContents); Files.deleteIfExists(originalJarPath); }
@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);  }