@Test public void shouldBuilderAppendMultipleFilters() throws Exception { FilterPredicate activePredicate = Mockito.mock(FilterPredicate.class); FilterPredicate validPredicate = Mockito.mock(FilterPredicate.class); Mockito.when(activePredicate.toString(defaultSerializer)).thenReturn("active"); Mockito.when(validPredicate.toString(defaultSerializer)).thenReturn("valid"); GetRequestInformation requestInfo = builder.filter(activePredicate,validPredicate).build(); Assert.assertThat(requestInfo.getParametersString(), Matchers.allOf(Matchers.containsString("filter=active"), Matchers.containsString("filter=valid"))); }
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();  }