use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldProvideUniqueParameterNamesForFilters.
/**
* @see issue #137
*/
@Test
public void shouldProvideUniqueParameterNamesForFilters() {
Restaurant restaurant = new Restaurant();
restaurant.setName("La Cocina De Flaming Lips");
session.save(restaurant);
Restaurant another = new Restaurant();
another.setName("Antica Pesa");
session.save(another);
Filters filters = new Filters();
Filter firstFilter = new Filter("name", ComparisonOperator.EQUALS, "Foobar");
firstFilter.setBooleanOperator(BooleanOperator.OR);
filters.add(firstFilter);
Filter secondFilter = new Filter("name", ComparisonOperator.EQUALS, "Antica Pesa");
secondFilter.setBooleanOperator(BooleanOperator.OR);
filters.add(secondFilter);
Collection<Restaurant> results = session.loadAll(Restaurant.class, filters);
assertThat(results.size() >= 1).isTrue();
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldFilterByCollectionContaining.
@Test
public void shouldFilterByCollectionContaining() {
Restaurant sfo = new Restaurant("San Francisco International Airport (SFO)", 72.4);
sfo.getSpecialities().add("burger");
sfo.getSpecialities().add("pizza");
session.save(sfo);
Restaurant kuroda = new Restaurant("Kuroda", 80.5);
kuroda.getSpecialities().add("sushi");
session.save(kuroda);
Filter f1 = new Filter("specialities", new ContainsAnyComparison(Arrays.asList("burger")));
Collection<Restaurant> burgers = session.loadAll(Restaurant.class, new Filters(f1));
assertThat(burgers).hasSize(1);
assertThat(burgers.iterator().next().getName()).isEqualTo("San Francisco International Airport (SFO)");
Filter f2 = new Filter("specialities", new ContainsAnyComparison(Arrays.asList("burger", "sushi")));
Collection<Restaurant> all = session.loadAll(Restaurant.class, new Filters(f2));
assertThat(all).hasSize(2);
Filter f3 = new Filter("specialities", new ContainsAnyComparison(Arrays.asList("sushi", "other")));
Collection<Restaurant> sushi = session.loadAll(Restaurant.class, new Filters(f3));
assertThat(sushi).hasSize(1);
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldFilterByPropertyExists.
/**
* @see DATAGRAPH-904
*/
@Test
public void shouldFilterByPropertyExists() {
Restaurant sfo = new Restaurant("San Francisco International Airport (SFO)", 72.4);
sfo.setLaunchDate(new Date(1000));
session.save(sfo);
Restaurant kuroda = new Restaurant("Kuroda", 80.5);
kuroda.setLaunchDate(new Date(2000));
session.save(kuroda);
Filter exists = new Filter("name", ComparisonOperator.EXISTS);
Collection<Restaurant> results = session.loadAll(Restaurant.class, new Filters().add(exists));
assertThat(results).isNotNull();
assertThat(results).hasSize(2);
Filter notExists = new Filter("name", ComparisonOperator.EXISTS);
notExists.setNegated(true);
results = session.loadAll(Restaurant.class, new Filters().add(notExists));
assertThat(results).isNotNull();
assertThat(results).isEmpty();
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method nestedFilteringCanBeTheOneAndOnlyOredFilter.
@Test
public void nestedFilteringCanBeTheOneAndOnlyOredFilter() {
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.OR);
Filters filters = new Filters(filterB);
Collection<Movie> films = session.loadAll(Movie.class, filters);
assertThat(films).hasSize(2);
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class NodeQueryStatementsTest method testFindByDifferentNestedPropertiesOred.
// DATAGRAPH-662
@Test(expected = UnsupportedOperationException.class)
public void testFindByDifferentNestedPropertiesOred() {
Filter planetParam = collidesWithEarthFilter();
Filter moonParam = orbitsMoonFilter();
moonParam.setBooleanOperator(BooleanOperator.OR);
queryStatements.findByType("Asteroid", new Filters().add(planetParam).add(moonParam), 1).getStatement();
}
Aggregations