use of com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect in project elide by yahoo.
the class MultipleFilterDialectTest method testGlobalExpressionParsing.
/**
* Verify that all dialects are iterated over.
*/
@Test
public void testGlobalExpressionParsing() throws Exception {
JoinFilterDialect dialect1 = mock(JoinFilterDialect.class);
JoinFilterDialect dialect2 = mock(JoinFilterDialect.class);
FilterExpression filterExpression = mock(FilterExpression.class);
MultipleFilterDialect dialect = new MultipleFilterDialect(Arrays.asList(dialect1, dialect2), Collections.emptyList());
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.parseGlobalExpression("/author", queryParams, NO_VERSION)).thenThrow(new ParseException(""));
when(dialect2.parseGlobalExpression("/author", queryParams, NO_VERSION)).thenReturn(filterExpression);
FilterExpression returnExpression = dialect.parseGlobalExpression("/author", queryParams, NO_VERSION);
verify(dialect1, times(1)).parseGlobalExpression("/author", queryParams, NO_VERSION);
verify(dialect2, times(1)).parseGlobalExpression("/author", queryParams, NO_VERSION);
assertEquals(returnExpression, filterExpression);
}
use of com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect in project elide by yahoo.
the class MultipleFilterDialectTest method testTypedExpressionParsing.
/**
* Verify that all dialects are iterated over.
*/
@Test
public void testTypedExpressionParsing() throws Exception {
SubqueryFilterDialect dialect1 = mock(SubqueryFilterDialect.class);
SubqueryFilterDialect dialect2 = mock(SubqueryFilterDialect.class);
Map<String, FilterExpression> expressionMap = Collections.emptyMap();
MultipleFilterDialect dialect = new MultipleFilterDialect(Collections.emptyList(), 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, NO_VERSION)).thenThrow(new ParseException(""));
when(dialect2.parseTypedExpression("/author", queryParams, NO_VERSION)).thenReturn(expressionMap);
Map<String, FilterExpression> returnMap = dialect.parseTypedExpression("/author", queryParams, NO_VERSION);
verify(dialect1, times(1)).parseTypedExpression("/author", queryParams, NO_VERSION);
verify(dialect2, times(1)).parseTypedExpression("/author", queryParams, NO_VERSION);
assertEquals(returnMap, expressionMap);
}
use of com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect in project elide by yahoo.
the class StandardTestBinder method configure.
@Override
protected void configure() {
EntityDictionary dictionary = EntityDictionary.builder().injector(injector::inject).checks(TestCheckMappings.MAPPINGS).build();
bind(dictionary).to(EntityDictionary.class);
// Elide instance
bindFactory(new Factory<Elide>() {
@Override
public Elide provide() {
DefaultFilterDialect defaultFilterStrategy = new DefaultFilterDialect(dictionary);
RSQLFilterDialect rsqlFilterStrategy = RSQLFilterDialect.builder().dictionary(dictionary).build();
MultipleFilterDialect multipleFilterStrategy = new MultipleFilterDialect(Arrays.asList(rsqlFilterStrategy, defaultFilterStrategy), Arrays.asList(rsqlFilterStrategy, defaultFilterStrategy));
Elide elide = new Elide(new ElideSettingsBuilder(IntegrationTest.getDataStore()).withAuditLogger(auditLogger).withJoinFilterDialect(multipleFilterStrategy).withSubqueryFilterDialect(multipleFilterStrategy).withEntityDictionary(dictionary).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", Calendar.getInstance().getTimeZone()).build());
elide.doScans();
return elide;
}
@Override
public void dispose(Elide elide) {
}
}).to(Elide.class).named("elide");
bind(BILLING_SERVICE).to(BillingService.class);
}
Aggregations