@Test public void returnsNullWhenNonRequiredLongParamMalformed() throws Exception { Map<String, String> params = newHashMap(); params.put("key1", "123s4"); params.put("key2", "value2"); ParamReader paramReader = new ParamReader(params, "object"); Long result = paramReader.getLongValue("key1"); assertThat(result, nullValue()); }
public Long getLongValue(String paramName) { String value = params.get(paramName); if (value == null) { return null; } try { return Long.parseLong(value); } catch (NumberFormatException e) { String message = getNumberFormatErrorMessage(paramName, value); LOG.error(message); return null; } }
ParamReader { public Long getLongValue(String paramName) { String value = params.get(paramName); if (value == null) { return null; } try { return Long.parseLong(value); } catch (NumberFormatException e) { String message = getNumberFormatErrorMessage(paramName, value); LOG.error(message); return null; } } }
ParamReader { public Long getLongValue(String paramName) { String value = params.get(paramName); if (value == null) { return null; } try { return Long.parseLong(value); } catch (NumberFormatException e) { String message = getNumberFormatErrorMessage(paramName, value); LOG.error(message); return null; } } ParamReader(Map<String, String> params, String parametrizedObjectLabel); }
ParamReader { public Long getLongValue(String paramName) { String value = params.get(paramName); if (value == null) { return null; } try { return Long.parseLong(value); } catch (NumberFormatException e) { String message = getNumberFormatErrorMessage(paramName, value); LOG.error(message); return null; } } ParamReader(Map<String, String> params, String parametrizedObjectLabel); String getLabel(); String getRequiredStringValue(String paramName); String getStringValue(String paramName); String getStringValue(String paramName, String defaultValue); Integer getRequiredIntValue(String paramName); Integer getIntValue(String paramName); int getIntValue(String paramName, int defaultValue); Long getRequiredLongValue(String paramName); Long getLongValue(String paramName); long getLongValue(String paramName, long defaultValue); }
ParamReader { public Long getLongValue(String paramName) { String value = params.get(paramName); if (value == null) { return null; } try { return Long.parseLong(value); } catch (NumberFormatException e) { String message = getNumberFormatErrorMessage(paramName, value); LOG.error(message); return null; } } ParamReader(Map<String, String> params, String parametrizedObjectLabel); String getLabel(); String getRequiredStringValue(String paramName); String getStringValue(String paramName); String getStringValue(String paramName, String defaultValue); Integer getRequiredIntValue(String paramName); Integer getIntValue(String paramName); int getIntValue(String paramName, int defaultValue); Long getRequiredLongValue(String paramName); Long getLongValue(String paramName); long getLongValue(String paramName, long defaultValue);  }