@Test(expected = IllegalArgumentException.class) public void testSaveSettingsEmptyProperty() throws BundleException { SettingsDto dto = new SettingsDto(); dto.setTaskPossibleErrors(null); controller.saveSettings(dto); verify(settingsFacade, never()).setProperty(anyString(), anyString()); }
@ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/settings", method = RequestMethod.POST) public void saveSettings(@RequestBody SettingsDto settings) { String taskPossibleErrors = settings.getTaskPossibleErrors(); try(OutputStream os = new ByteArrayOutputStream()) { settings.getTaskRetriesProps().store(os, "TaskRetries"); if (settings.isValid()) { settingsFacade.setProperty(TASK_POSSIBLE_ERRORS, taskPossibleErrors); settingsFacade.saveRawConfig(TASK_PROPERTIES_FILE_NAME, new String(os.toString())); } else { throw new IllegalArgumentException("Settings are not valid"); } } catch (IOException e) { throw new MotechException("Error parsing task retries", e); } }
SettingsController { @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/settings", method = RequestMethod.POST) public void saveSettings(@RequestBody SettingsDto settings) { String taskPossibleErrors = settings.getTaskPossibleErrors(); try(OutputStream os = new ByteArrayOutputStream()) { settings.getTaskRetriesProps().store(os, "TaskRetries"); if (settings.isValid()) { settingsFacade.setProperty(TASK_POSSIBLE_ERRORS, taskPossibleErrors); settingsFacade.saveRawConfig(TASK_PROPERTIES_FILE_NAME, new String(os.toString())); } else { throw new IllegalArgumentException("Settings are not valid"); } } catch (IOException e) { throw new MotechException("Error parsing task retries", e); } } }
SettingsController { @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/settings", method = RequestMethod.POST) public void saveSettings(@RequestBody SettingsDto settings) { String taskPossibleErrors = settings.getTaskPossibleErrors(); try(OutputStream os = new ByteArrayOutputStream()) { settings.getTaskRetriesProps().store(os, "TaskRetries"); if (settings.isValid()) { settingsFacade.setProperty(TASK_POSSIBLE_ERRORS, taskPossibleErrors); settingsFacade.saveRawConfig(TASK_PROPERTIES_FILE_NAME, new String(os.toString())); } else { throw new IllegalArgumentException("Settings are not valid"); } } catch (IOException e) { throw new MotechException("Error parsing task retries", e); } }  }
SettingsController { @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/settings", method = RequestMethod.POST) public void saveSettings(@RequestBody SettingsDto settings) { String taskPossibleErrors = settings.getTaskPossibleErrors(); try(OutputStream os = new ByteArrayOutputStream()) { settings.getTaskRetriesProps().store(os, "TaskRetries"); if (settings.isValid()) { settingsFacade.setProperty(TASK_POSSIBLE_ERRORS, taskPossibleErrors); settingsFacade.saveRawConfig(TASK_PROPERTIES_FILE_NAME, new String(os.toString())); } else { throw new IllegalArgumentException("Settings are not valid"); } } catch (IOException e) { throw new MotechException("Error parsing task retries", e); } }  @RequestMapping(value = "/settings", method = RequestMethod.GET) @ResponseBody SettingsDto getSettings(); @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/settings", method = RequestMethod.POST) void saveSettings(@RequestBody SettingsDto settings); }
SettingsController { @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/settings", method = RequestMethod.POST) public void saveSettings(@RequestBody SettingsDto settings) { String taskPossibleErrors = settings.getTaskPossibleErrors(); try(OutputStream os = new ByteArrayOutputStream()) { settings.getTaskRetriesProps().store(os, "TaskRetries"); if (settings.isValid()) { settingsFacade.setProperty(TASK_POSSIBLE_ERRORS, taskPossibleErrors); settingsFacade.saveRawConfig(TASK_PROPERTIES_FILE_NAME, new String(os.toString())); } else { throw new IllegalArgumentException("Settings are not valid"); } } catch (IOException e) { throw new MotechException("Error parsing task retries", e); } }  @RequestMapping(value = "/settings", method = RequestMethod.GET) @ResponseBody SettingsDto getSettings(); @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/settings", method = RequestMethod.POST) void saveSettings(@RequestBody SettingsDto settings);  }