QueryParameters implements Serializable { public String getQueryString() { return parameters.entrySet().stream() .flatMap(this::getParameterAndValues) .collect(Collectors.joining(PARAMETERS_SEPARATOR)); } QueryParameters(Map<String, List<String>> parameters); static QueryParameters empty(); static QueryParameters full(Map<String, String[]> parameters); static QueryParameters simple(Map<String, String> parameters); Map<String, List<String>> getParameters(); String getQueryString();  }
@Test public void parameterWithoutValue() { QueryParameters params = new QueryParameters( Collections.singletonMap("foo", Collections.emptyList())); Assert.assertEquals("foo", params.getQueryString()); params = new QueryParameters( Collections.singletonMap("foo", Arrays.asList(null, "bar"))); Assert.assertEquals("foo&foo=bar", params.getQueryString()); params = new QueryParameters( Collections.singletonMap("foo", Arrays.asList("bar", null))); Assert.assertEquals("foo=bar&foo", params.getQueryString()); }
@Test public void parameterWithEmptyValue() { QueryParameters fullParams = new QueryParameters( Collections.singletonMap("foo", Collections.singletonList(""))); Assert.assertEquals("foo=", fullParams.getQueryString()); }