@Test void testMultipleFieldMultipleValues() { MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>(); queryParams.add("filter[book.title]", "abc,def"); queryParams.add("filter[book.genre]", "def,jkl"); Map<String, Set<FilterPredicate>> predicates = parse(queryParams); assertTrue(predicates.containsKey("book")); for (FilterPredicate predicate : predicates.get("book")) { switch (predicate.getField()) { case "title": assertEquals(Operator.IN, predicate.getOperator()); assertEquals(Arrays.asList("abc", "def"), predicate.getValues()); break; case "genre": assertEquals(Operator.IN, predicate.getOperator()); assertEquals(Arrays.asList("def", "jkl"), predicate.getValues()); break; default: fail(predicate.toString() + " case not covered"); } } }
@Override public String toString() { List<PathElement> elements = path.getPathElements(); StringBuilder formattedPath = new StringBuilder(); if (!elements.isEmpty()) { formattedPath.append(StringUtils.uncapitalize(EntityDictionary.getSimpleName(elements.get(0).getType()))); } for (PathElement element : elements) { formattedPath.append(PERIOD).append(element.getFieldName()); } return formattedPath.append(' ').append(operator).append(' ').append(values).toString(); }
FilterPredicate implements FilterExpression, Function<RequestScope, Predicate> { @Override public String toString() { List<PathElement> elements = path.getPathElements(); StringBuilder formattedPath = new StringBuilder(); if (!elements.isEmpty()) { formattedPath.append(StringUtils.uncapitalize(EntityDictionary.getSimpleName(elements.get(0).getType()))); } for (PathElement element : elements) { formattedPath.append(PERIOD).append(element.getFieldName()); } return formattedPath.append(' ').append(operator).append(' ').append(values).toString(); } }
FilterPredicate implements FilterExpression, Function<RequestScope, Predicate> { @Override public String toString() { List<PathElement> elements = path.getPathElements(); StringBuilder formattedPath = new StringBuilder(); if (!elements.isEmpty()) { formattedPath.append(StringUtils.uncapitalize(EntityDictionary.getSimpleName(elements.get(0).getType()))); } for (PathElement element : elements) { formattedPath.append(PERIOD).append(element.getFieldName()); } return formattedPath.append(' ').append(operator).append(' ').append(values).toString(); } FilterPredicate(PathElement pathElement, Operator op, List<Object> values);  FilterPredicate(FilterPredicate copy);  FilterPredicate(Path path, Operator op, List<Object> values); }
FilterPredicate implements FilterExpression, Function<RequestScope, Predicate> { @Override public String toString() { List<PathElement> elements = path.getPathElements(); StringBuilder formattedPath = new StringBuilder(); if (!elements.isEmpty()) { formattedPath.append(StringUtils.uncapitalize(EntityDictionary.getSimpleName(elements.get(0).getType()))); } for (PathElement element : elements) { formattedPath.append(PERIOD).append(element.getFieldName()); } return formattedPath.append(' ').append(operator).append(' ').append(values).toString(); } FilterPredicate(PathElement pathElement, Operator op, List<Object> values);  FilterPredicate(FilterPredicate copy);  FilterPredicate(Path path, Operator op, List<Object> values); static boolean toManyInPath(EntityDictionary dictionary, Path path); static boolean toManyInPathExceptLastPathElement(EntityDictionary dictionary, Path path); static boolean isLastPathElementAssignableFrom(EntityDictionary dictionary, Path path, Class<?> clz); List<FilterParameter> getParameters(); FilterPredicate scopedBy(PathElement scope); String getAlias(); static String getTypeAlias(Class<?> type); Class getEntityType(); @Override T accept(FilterExpressionVisitor<T> visitor); @Override Predicate apply(RequestScope dictionary); boolean isMatchingOperator(); @Override String toString(); FilterPredicate negate(); }
FilterPredicate implements FilterExpression, Function<RequestScope, Predicate> { @Override public String toString() { List<PathElement> elements = path.getPathElements(); StringBuilder formattedPath = new StringBuilder(); if (!elements.isEmpty()) { formattedPath.append(StringUtils.uncapitalize(EntityDictionary.getSimpleName(elements.get(0).getType()))); } for (PathElement element : elements) { formattedPath.append(PERIOD).append(element.getFieldName()); } return formattedPath.append(' ').append(operator).append(' ').append(values).toString(); } FilterPredicate(PathElement pathElement, Operator op, List<Object> values);  FilterPredicate(FilterPredicate copy);  FilterPredicate(Path path, Operator op, List<Object> values); static boolean toManyInPath(EntityDictionary dictionary, Path path); static boolean toManyInPathExceptLastPathElement(EntityDictionary dictionary, Path path); static boolean isLastPathElementAssignableFrom(EntityDictionary dictionary, Path path, Class<?> clz); List<FilterParameter> getParameters(); FilterPredicate scopedBy(PathElement scope); String getAlias(); static String getTypeAlias(Class<?> type); Class getEntityType(); @Override T accept(FilterExpressionVisitor<T> visitor); @Override Predicate apply(RequestScope dictionary); boolean isMatchingOperator(); @Override String toString(); FilterPredicate negate();  }