@Test public void extractUnparseableFrom() { Parameters parameters = new Parameters(); parameters.set("from", "foo"); int from = underTest.extractFrom(parameters); assertThat(from, is(0)); }
public int extractFrom(final Parameters parameters) { int from = 0; String fromParameter = Strings.nullToEmpty(parameters.get("from")).trim(); if (!fromParameter.isEmpty()) { try { from = Integer.parseInt(fromParameter); } catch (NumberFormatException e) { log.debug("Invalid from encountered in search parameters {}, using default", parameters, e); } if (from < 0) { from = 0; } } return from; }
NpmSearchParameterExtractor extends ComponentSupport { public int extractFrom(final Parameters parameters) { int from = 0; String fromParameter = Strings.nullToEmpty(parameters.get("from")).trim(); if (!fromParameter.isEmpty()) { try { from = Integer.parseInt(fromParameter); } catch (NumberFormatException e) { log.debug("Invalid from encountered in search parameters {}, using default", parameters, e); } if (from < 0) { from = 0; } } return from; } }
NpmSearchParameterExtractor extends ComponentSupport { public int extractFrom(final Parameters parameters) { int from = 0; String fromParameter = Strings.nullToEmpty(parameters.get("from")).trim(); if (!fromParameter.isEmpty()) { try { from = Integer.parseInt(fromParameter); } catch (NumberFormatException e) { log.debug("Invalid from encountered in search parameters {}, using default", parameters, e); } if (from < 0) { from = 0; } } return from; }  }
NpmSearchParameterExtractor extends ComponentSupport { public int extractFrom(final Parameters parameters) { int from = 0; String fromParameter = Strings.nullToEmpty(parameters.get("from")).trim(); if (!fromParameter.isEmpty()) { try { from = Integer.parseInt(fromParameter); } catch (NumberFormatException e) { log.debug("Invalid from encountered in search parameters {}, using default", parameters, e); } if (from < 0) { from = 0; } } return from; }  String extractText(final Parameters parameters); int extractSize(final Parameters parameters); int extractFrom(final Parameters parameters); }
NpmSearchParameterExtractor extends ComponentSupport { public int extractFrom(final Parameters parameters) { int from = 0; String fromParameter = Strings.nullToEmpty(parameters.get("from")).trim(); if (!fromParameter.isEmpty()) { try { from = Integer.parseInt(fromParameter); } catch (NumberFormatException e) { log.debug("Invalid from encountered in search parameters {}, using default", parameters, e); } if (from < 0) { from = 0; } } return from; }  String extractText(final Parameters parameters); int extractSize(final Parameters parameters); int extractFrom(final Parameters parameters);  }