DefaultMultipleParameterRetriever implements MultipleParameterRetriever { @Override public List<?> getMultiParameter(final String[] values) { List<String> stringResult = Arrays.asList(values); boolean isDigits = stringResult.stream().anyMatch(e -> NumberUtils.isNumber(e)); return isDigits ? stringResult.stream().map(e -> Long.valueOf(e)).collect(Collectors.toList()) : stringResult; }  @Override List<?> getMultiParameter(final String[] values); static final String EMPTY_STRING; static final String COMMA; static final String OPEN_BRACKET; static final String CLOSE_BRACKET; }
@Test public void testGetMultiParameter() throws Exception { String id1 = "fsdfs"; String id2 = "rewr"; String id3 = "vxcv"; String[] value = {id1, id2, id3}; List<String> expected = Arrays.<String>asList(id1, id2, id3); List<?> actual = unit.getMultiParameter(value); assertEquals(expected, actual); }
@Test public void testGetMultiParameterWithNumericValues() throws Exception { Long id1 = 1L; Long id2 = 2L; Long id3 = 3L; String[] value = {String.valueOf(id1), String.valueOf(id2), String.valueOf(id3)}; List<Long> expected = Arrays.<Long>asList(id1, id2, id3); List<?> actual = unit.getMultiParameter(value); assertEquals(expected, actual); }
@Test public void testGetMultiParameterWithSingleValue() throws Exception { String id1 = "fsdsd"; String[] value = {id1}; List<String> expected = Arrays.<String>asList(id1); List<?> actual = unit.getMultiParameter(value); assertEquals(expected, actual); }
@Test public void testGetMultiParameterWithSingleValueAndSpaces() throws Exception { String id1 = "fsdfsd"; String[] value = {id1}; List<String> expected = Arrays.<String>asList(id1); List<?> actual = unit.getMultiParameter(value); assertEquals(expected, actual); }
@Test public void testGetMultiParameterWithSpaces() throws Exception { String id1 = "fsdfs"; String id2 = "rewr"; String id3 = "vxcv"; String[] value = {id1, id2, id3}; List<String> expected = Arrays.<String>asList(id1, id2, id3); List<?> actual = unit.getMultiParameter(value); assertEquals(expected, actual); }
@Test public void testGetMultiParameterWithBeginningSpaces() throws Exception { String id1 = "fsdfs"; String id2 = "rewr"; String id3 = "vxcv"; String[] value = {id1, id2, id3}; List<String> expected = Arrays.<String>asList(id1, id2, id3); List<?> actual = unit.getMultiParameter(value); assertEquals(expected, actual); }