@Test public void testExpandParameters() throws Exception { Map<String, List> collected; final SearchContext ctx = new SearchContext(Collections.singletonMap("abc", Collections.singletonList("def")), 0, 0, null, false, "abc"); collected = ctx.expandParameter("abc", "abc1", "abc2", "abc3"); assertNotNull(collected); assertFalse(collected.isEmpty()); assertEquals(4, collected.size()); assertEquals(Collections.singletonList(SearchContext.JoinMode.OR), collected.get(SearchContext.JOIN)); assertEquals(Collections.singletonList("def"), collected.get("abc1")); assertEquals(Collections.singletonList("def"), collected.get("abc2")); assertEquals(Collections.singletonList("def"), collected.get("abc3")); }
public Map<String, List> expandParameter(final String key, final String ... expand) { final Map<String, List> expanded = new LinkedHashMap<>(); final List existing = parameters.get(key); if (existing != null && expand != null) { for (final String item : expand) { expanded.put(item, existing); } JoinMode.OR.setMode(expanded); } return expanded; }
SearchContext { public Map<String, List> expandParameter(final String key, final String ... expand) { final Map<String, List> expanded = new LinkedHashMap<>(); final List existing = parameters.get(key); if (existing != null && expand != null) { for (final String item : expand) { expanded.put(item, existing); } JoinMode.OR.setMode(expanded); } return expanded; } }
SearchContext { public Map<String, List> expandParameter(final String key, final String ... expand) { final Map<String, List> expanded = new LinkedHashMap<>(); final List existing = parameters.get(key); if (existing != null && expand != null) { for (final String item : expand) { expanded.put(item, existing); } JoinMode.OR.setMode(expanded); } return expanded; } SearchContext(final Map<String, List> parameters,
                         final int start,
                         final int size,
                         final String sortBy,
                         final boolean sortDesc,
                         final String ... allowed); }
SearchContext { public Map<String, List> expandParameter(final String key, final String ... expand) { final Map<String, List> expanded = new LinkedHashMap<>(); final List existing = parameters.get(key); if (existing != null && expand != null) { for (final String item : expand) { expanded.put(item, existing); } JoinMode.OR.setMode(expanded); } return expanded; } SearchContext(final Map<String, List> parameters,
                         final int start,
                         final int size,
                         final String sortBy,
                         final boolean sortDesc,
                         final String ... allowed); Map<String, List> getParameters(); Map<String, List> reduceParameters(final String ... allowed); Map<String, List> expandParameter(final String key, final String ... expand); int getStart(); int getSize(); String getSortBy(); boolean isSortDesc(); }
SearchContext { public Map<String, List> expandParameter(final String key, final String ... expand) { final Map<String, List> expanded = new LinkedHashMap<>(); final List existing = parameters.get(key); if (existing != null && expand != null) { for (final String item : expand) { expanded.put(item, existing); } JoinMode.OR.setMode(expanded); } return expanded; } SearchContext(final Map<String, List> parameters,
                         final int start,
                         final int size,
                         final String sortBy,
                         final boolean sortDesc,
                         final String ... allowed); Map<String, List> getParameters(); Map<String, List> reduceParameters(final String ... allowed); Map<String, List> expandParameter(final String key, final String ... expand); int getStart(); int getSize(); String getSortBy(); boolean isSortDesc(); static final String JOIN; }