use of org.neo4j.ogm.cypher.function.ContainsAnyComparison 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.function.ContainsAnyComparison in project neo4j-ogm by neo4j.
the class FilterTest method inCollectionFilterTest.
@Test
public void inCollectionFilterTest() {
ContainsAnyComparison filterFunction = new ContainsAnyComparison("test");
Filter filter = new Filter("property", filterFunction);
assertThat(filter.toCypher("n", true)).isEqualTo("WHERE ANY(collectionFields IN $`property_0` WHERE collectionFields in n.`property`) ");
assertThat(filter.parameters().get("property_0")).isEqualTo("test");
}
Aggregations