@Test public void testCreateFilterMap() { productCollectionModel = context.request().adaptTo(ProductCollectionImpl.class); Map<String, String[]> queryParameters = new HashMap<>(); queryParameters.put("color", new String[] {}); Map<String, String> filterMap = productCollectionModel.createFilterMap(queryParameters); Assert.assertEquals("filters out query parameters without values", 0, filterMap.size()); queryParameters = new HashMap<>(); queryParameters.put("color", new String[] { "123" }); filterMap = productCollectionModel.createFilterMap(queryParameters); Assert.assertEquals("retails valid query filters", 1, filterMap.size()); }
protected Map<String, String> createFilterMap(final Map<String, String[]> parameterMap) { Map<String, String> filters = new HashMap<>(); parameterMap.forEach((code, value) -> { if (value.length != 1) { return; } filters.put(code, value[0]); }); return filters; }
ProductCollectionImpl implements ProductCollection { protected Map<String, String> createFilterMap(final Map<String, String[]> parameterMap) { Map<String, String> filters = new HashMap<>(); parameterMap.forEach((code, value) -> { if (value.length != 1) { return; } filters.put(code, value[0]); }); return filters; } }
ProductCollectionImpl implements ProductCollection { protected Map<String, String> createFilterMap(final Map<String, String[]> parameterMap) { Map<String, String> filters = new HashMap<>(); parameterMap.forEach((code, value) -> { if (value.length != 1) { return; } filters.put(code, value[0]); }); return filters; }  }
ProductCollectionImpl implements ProductCollection { protected Map<String, String> createFilterMap(final Map<String, String[]> parameterMap) { Map<String, String> filters = new HashMap<>(); parameterMap.forEach((code, value) -> { if (value.length != 1) { return; } filters.put(code, value[0]); }); return filters; }  Integer calculateCurrentPageCursor(final String currentPageIndexCandidate); @Override boolean loadClientPrice(); @Override String getPaginationType(); @Nonnull @Override Collection<ProductListItem> getProducts(); @Nonnull @Override SearchResultsSet getSearchResultsSet(); }
ProductCollectionImpl implements ProductCollection { protected Map<String, String> createFilterMap(final Map<String, String[]> parameterMap) { Map<String, String> filters = new HashMap<>(); parameterMap.forEach((code, value) -> { if (value.length != 1) { return; } filters.put(code, value[0]); }); return filters; }  Integer calculateCurrentPageCursor(final String currentPageIndexCandidate); @Override boolean loadClientPrice(); @Override String getPaginationType(); @Nonnull @Override Collection<ProductListItem> getProducts(); @Nonnull @Override SearchResultsSet getSearchResultsSet();  }