@Test public void shouldBuilderAppendMultipleParametersWithSameName() throws Exception { Mockito.when(defaultSerializer.serialize("John")).thenReturn("John"); Mockito.when(defaultSerializer.serialize("Doe")).thenReturn("Doe"); GetRequestInformation requestInfo = builder.parameter("name", "John", "Doe").build(); Assert.assertThat(requestInfo.getParametersString(), Matchers.allOf(Matchers.containsString("name=John"), Matchers.containsString("name=Doe"))); }
public String getParametersString() { List<String> params = new LinkedList<String>(); for (Entry<String, List<String>> entries : parameters.entrySet()) { for (String value : entries.getValue()) { params.add(value == null || value.isEmpty() ? entries.getKey() : String.format("%s=%s", entries.getKey(), value)); } } return String.join("&", params); }
GetRequestInformation { public String getParametersString() { List<String> params = new LinkedList<String>(); for (Entry<String, List<String>> entries : parameters.entrySet()) { for (String value : entries.getValue()) { params.add(value == null || value.isEmpty() ? entries.getKey() : String.format("%s=%s", entries.getKey(), value)); } } return String.join("&", params); } }
GetRequestInformation { public String getParametersString() { List<String> params = new LinkedList<String>(); for (Entry<String, List<String>> entries : parameters.entrySet()) { for (String value : entries.getValue()) { params.add(value == null || value.isEmpty() ? entries.getKey() : String.format("%s=%s", entries.getKey(), value)); } } return String.join("&", params); } private  GetRequestInformation(String path, Map<String, List<String>> parameters); }
GetRequestInformation { public String getParametersString() { List<String> params = new LinkedList<String>(); for (Entry<String, List<String>> entries : parameters.entrySet()) { for (String value : entries.getValue()) { params.add(value == null || value.isEmpty() ? entries.getKey() : String.format("%s=%s", entries.getKey(), value)); } } return String.join("&", params); } private  GetRequestInformation(String path, Map<String, List<String>> parameters); String getParametersString(); String getPathWithParameters(); }
GetRequestInformation { public String getParametersString() { List<String> params = new LinkedList<String>(); for (Entry<String, List<String>> entries : parameters.entrySet()) { for (String value : entries.getValue()) { params.add(value == null || value.isEmpty() ? entries.getKey() : String.format("%s=%s", entries.getKey(), value)); } } return String.join("&", params); } private  GetRequestInformation(String path, Map<String, List<String>> parameters); String getParametersString(); String getPathWithParameters();  }