@Test public void testTypedExpressionParsing() throws Exception { SubqueryFilterDialect dialect1 = mock(SubqueryFilterDialect.class); SubqueryFilterDialect dialect2 = mock(SubqueryFilterDialect.class); Map<String, FilterExpression> expressionMap = Collections.EMPTY_MAP; MultipleFilterDialect dialect = new MultipleFilterDialect( Collections.EMPTY_LIST, Arrays.asList(dialect1, dialect2) ); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>(); queryParams.add( "filter[author.books.title][in]", "foo,bar,baz" ); queryParams.add( "filter[author.name][infix]", "Hemingway" ); when(dialect1.parseTypedExpression("/author", queryParams)).thenThrow(new ParseException("")); when(dialect2.parseTypedExpression("/author", queryParams)).thenReturn(expressionMap); Map<String, FilterExpression> returnMap = dialect.parseTypedExpression("/author", queryParams); verify(dialect1, times(1)).parseTypedExpression("/author", queryParams); verify(dialect2, times(1)).parseTypedExpression("/author", queryParams); assertEquals(returnMap, expressionMap); }
@Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> queryParams) throws ParseException { if (subqueryDialects.isEmpty()) { throw new ParseException("Type filtering not supported"); } return parseExpression(subqueryDialects, (dialect) -> dialect.parseTypedExpression(path, queryParams)); }
MultipleFilterDialect implements JoinFilterDialect, SubqueryFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> queryParams) throws ParseException { if (subqueryDialects.isEmpty()) { throw new ParseException("Type filtering not supported"); } return parseExpression(subqueryDialects, (dialect) -> dialect.parseTypedExpression(path, queryParams)); } }
MultipleFilterDialect implements JoinFilterDialect, SubqueryFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> queryParams) throws ParseException { if (subqueryDialects.isEmpty()) { throw new ParseException("Type filtering not supported"); } return parseExpression(subqueryDialects, (dialect) -> dialect.parseTypedExpression(path, queryParams)); } MultipleFilterDialect(EntityDictionary dictionary); }
MultipleFilterDialect implements JoinFilterDialect, SubqueryFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> queryParams) throws ParseException { if (subqueryDialects.isEmpty()) { throw new ParseException("Type filtering not supported"); } return parseExpression(subqueryDialects, (dialect) -> dialect.parseTypedExpression(path, queryParams)); } MultipleFilterDialect(EntityDictionary dictionary); @Override FilterExpression parseGlobalExpression(String path,
                                                  MultivaluedMap<String, String> queryParams); @Override Map<String, FilterExpression> parseTypedExpression(String path,
                                                              MultivaluedMap<String, String> queryParams); }
MultipleFilterDialect implements JoinFilterDialect, SubqueryFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> queryParams) throws ParseException { if (subqueryDialects.isEmpty()) { throw new ParseException("Type filtering not supported"); } return parseExpression(subqueryDialects, (dialect) -> dialect.parseTypedExpression(path, queryParams)); } MultipleFilterDialect(EntityDictionary dictionary); @Override FilterExpression parseGlobalExpression(String path,
                                                  MultivaluedMap<String, String> queryParams); @Override Map<String, FilterExpression> parseTypedExpression(String path,
                                                              MultivaluedMap<String, String> queryParams);  }