@Test(expected = NumberFormatException.class) public void shouldRaiseNumberFormatExceptionWhenValueIsNotNumber() throws Exception { expected.setValue("SOME_RANDOM_CHARACTER"); int actual = service.getConfigurationIntValue("KEY_NAME"); }
public int getConfigurationIntValue(String key) { ConfigurationSetting configuration = getByKey(key); if (configuration == null || configuration.getValue() == null || configuration.getValue().isEmpty()) return 0; return Integer.parseInt(configuration.getValue()); }
ConfigurationSettingService { public int getConfigurationIntValue(String key) { ConfigurationSetting configuration = getByKey(key); if (configuration == null || configuration.getValue() == null || configuration.getValue().isEmpty()) return 0; return Integer.parseInt(configuration.getValue()); } }
ConfigurationSettingService { public int getConfigurationIntValue(String key) { ConfigurationSetting configuration = getByKey(key); if (configuration == null || configuration.getValue() == null || configuration.getValue().isEmpty()) return 0; return Integer.parseInt(configuration.getValue()); } @Autowired  ConfigurationSettingService(ConfigurationSettingRepository configurationSettingRepository); }
ConfigurationSettingService { public int getConfigurationIntValue(String key) { ConfigurationSetting configuration = getByKey(key); if (configuration == null || configuration.getValue() == null || configuration.getValue().isEmpty()) return 0; return Integer.parseInt(configuration.getValue()); } @Autowired  ConfigurationSettingService(ConfigurationSettingRepository configurationSettingRepository); ConfigurationSetting getByKey(String key); int getConfigurationIntValue(String key); String getConfigurationStringValue(String key); Boolean getBoolValue(String key); List<Object> getConfigurationListValue(String key, String delimiter); List<ConfigurationSetting> getConfigurations(); void update(List<ConfigurationSetting> settings); void saveBooleanValue(String key, Boolean value); List<ConfigurationSetting> getSearchResults(String s); }
ConfigurationSettingService { public int getConfigurationIntValue(String key) { ConfigurationSetting configuration = getByKey(key); if (configuration == null || configuration.getValue() == null || configuration.getValue().isEmpty()) return 0; return Integer.parseInt(configuration.getValue()); } @Autowired  ConfigurationSettingService(ConfigurationSettingRepository configurationSettingRepository); ConfigurationSetting getByKey(String key); int getConfigurationIntValue(String key); String getConfigurationStringValue(String key); Boolean getBoolValue(String key); List<Object> getConfigurationListValue(String key, String delimiter); List<ConfigurationSetting> getConfigurations(); void update(List<ConfigurationSetting> settings); void saveBooleanValue(String key, Boolean value); List<ConfigurationSetting> getSearchResults(String s);  }