use of org.neo4j.ogm.cypher.function.FilterFunction in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method nestedFilteringMustThrowExceptionWithOrInThePipeline.
@Test
public void nestedFilteringMustThrowExceptionWithOrInThePipeline() {
// rated by the user who doesn't own Catty or by the user who owns Catty
Filter filterA = new Filter("name", ComparisonOperator.EQUALS, "Catty");
filterA.setNestedPath(new Filter.NestedPathSegment("ratings", Rating.class), new Filter.NestedPathSegment("user", User.class), new Filter.NestedPathSegment("pets", Pet.class));
filterA.setNegated(true);
Filter alwaysTrueFilter = new Filter(new FilterFunction() {
private Filter theFilter;
@Override
public Object getValue() {
return null;
}
@Override
public Map<String, Object> parameters(UnaryOperator createUniqueParameterName, PropertyValueTransformer valueTransformer) {
return Collections.emptyMap();
}
@Override
public String expression(String nodeIdentifier, String filteredProperty, UnaryOperator createUniqueParameterName) {
return "1 = 1 ";
}
});
alwaysTrueFilter.setBooleanOperator(BooleanOperator.OR);
Filter filterB = new Filter("name", ComparisonOperator.EQUALS, "Catty");
filterB.setNestedPath(new Filter.NestedPathSegment("ratings", Rating.class), new Filter.NestedPathSegment("user", User.class), new Filter.NestedPathSegment("pets", Pet.class));
filterB.setBooleanOperator(BooleanOperator.AND);
Filters filters = new Filters(filterA, alwaysTrueFilter, filterB);
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> session.loadAll(Movie.class, filters)).withMessage("Filters containing nested paths cannot be combined via the logical OR operator.");
}
Aggregations