@Test(expected = HTTP400Exception.class) public void testGetIntParam() throws HTTP400Exception { String param1 = "sourceSystem.code"; String value1 = "BRAHMS"; String param2 = "_size"; String value2 = "100"; String param3 = "_from"; String value3 = "100"; MultivaluedHashMap<String, String> parameterMap = new MultivaluedHashMap<>(); parameterMap.put(param1, new ArrayList<>(Arrays.asList(value1))); parameterMap.put(param2, new ArrayList<>(Arrays.asList(value2))); parameterMap.put(param3, new ArrayList<>(Arrays.asList(value3))); UriInfo uriInfo = mock(UriInfo.class); when(uriInfo.getQueryParameters()).thenReturn(parameterMap); GroupByScientificNameQuerySpec qs = new HttpGroupByScientificNameQuerySpecBuilder(uriInfo) .build(); assertEquals("Test of Size parameter ", value2, qs.getSize().toString()); assertEquals("Test of From parameter ", value3, qs.getFrom().toString()); parameterMap.get(param2).set(0, "test"); when(uriInfo.getQueryParameters()).thenReturn(parameterMap); new HttpGroupByScientificNameQuerySpecBuilder(uriInfo).build(); }
private Integer getIntParam(String param, String value) { if (value.length() == 0) { return null; } try { return Integer.valueOf(value); } catch (NumberFormatException e) { String msg = String.format(ERR_BAD_INT_PARAM, param, value); throw new HTTP400Exception(uriInfo, msg); } }
HttpGroupByScientificNameQuerySpecBuilder { private Integer getIntParam(String param, String value) { if (value.length() == 0) { return null; } try { return Integer.valueOf(value); } catch (NumberFormatException e) { String msg = String.format(ERR_BAD_INT_PARAM, param, value); throw new HTTP400Exception(uriInfo, msg); } } }
HttpGroupByScientificNameQuerySpecBuilder { private Integer getIntParam(String param, String value) { if (value.length() == 0) { return null; } try { return Integer.valueOf(value); } catch (NumberFormatException e) { String msg = String.format(ERR_BAD_INT_PARAM, param, value); throw new HTTP400Exception(uriInfo, msg); } } HttpGroupByScientificNameQuerySpecBuilder(UriInfo uriInfo);  HttpGroupByScientificNameQuerySpecBuilder(MultivaluedMap<String, String> formData,
			UriInfo uriInfo); }
HttpGroupByScientificNameQuerySpecBuilder { private Integer getIntParam(String param, String value) { if (value.length() == 0) { return null; } try { return Integer.valueOf(value); } catch (NumberFormatException e) { String msg = String.format(ERR_BAD_INT_PARAM, param, value); throw new HTTP400Exception(uriInfo, msg); } } HttpGroupByScientificNameQuerySpecBuilder(UriInfo uriInfo);  HttpGroupByScientificNameQuerySpecBuilder(MultivaluedMap<String, String> formData,
			UriInfo uriInfo); GroupByScientificNameQuerySpec build(); }
HttpGroupByScientificNameQuerySpecBuilder { private Integer getIntParam(String param, String value) { if (value.length() == 0) { return null; } try { return Integer.valueOf(value); } catch (NumberFormatException e) { String msg = String.format(ERR_BAD_INT_PARAM, param, value); throw new HTTP400Exception(uriInfo, msg); } } HttpGroupByScientificNameQuerySpecBuilder(UriInfo uriInfo);  HttpGroupByScientificNameQuerySpecBuilder(MultivaluedMap<String, String> formData,
			UriInfo uriInfo); GroupByScientificNameQuerySpec build(); static final String PARAM_QUERY_SPEC; static final String PARAM_FIELDS; static final String PARAM_FROM; static final String PARAM_SIZE; static final String PARAM_OPERATOR; static final String PARAM_SORT_FIELDS; static final String PARAM_IGNORE_CASE; static final String PARAM_GROUP_SORT; static final String PARAM_GROUP_FILTER; static final String PARAM_SPECIMENS_FROM; static final String PARAM_SPECIMENS_SIZE; static final String PARAM_SPECIMENS_SORT_FIELDS; static final String PARAM_SPECIMENS_NO_TAXA; }