use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method nestedFiltersOnSameEntitiesButDifferentRelationsShouldWork.
// GH-851
@Test
public void nestedFiltersOnSameEntitiesButDifferentRelationsShouldWork() {
Filters filters = new Filters();
Filter filter = new Filter("code", ComparisonOperator.EQUALS, "LHR");
filter.setOwnerEntityType(Flight.class);
filter.setNestedPropertyType(Airport.class);
filter.setNestedPropertyName("departure");
filter.setRelationshipType("DEPARTS");
filter.setRelationshipDirection(Relationship.OUTGOING);
filters.and(filter);
filter = new Filter("code", ComparisonOperator.EQUALS, "LAX");
filter.setOwnerEntityType(Flight.class);
filter.setNestedPropertyType(Airport.class);
filter.setNestedPropertyName("arrival");
filter.setRelationshipType("ARRIVES");
filter.setRelationshipDirection(Relationship.OUTGOING);
filters.and(filter);
Collection<Flight> flights = session.loadAll(Flight.class, filters);
assertThat(flights).hasSize(1).first().extracting(Flight::getName).isEqualTo("FL 001");
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldFilterByPropertyIn.
/**
* @see DATAGRAPH-904
*/
@Test
public void shouldFilterByPropertyIn() {
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 filter = new Filter("name", ComparisonOperator.IN, new String[] { "Kuroda", "Foo", "Bar" });
Collection<Restaurant> results = session.loadAll(Restaurant.class, new Filters().add(filter));
assertThat(results).isNotNull();
assertThat(results).hasSize(1);
assertThat(results.iterator().next().getName()).isEqualTo("Kuroda");
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldFilterByPropertyWithConverter.
/**
* @see DATAGRAPH-904
*/
@Test
public void shouldFilterByPropertyWithConverter() {
Restaurant kuroda = new Restaurant("Kuroda", 72.4);
kuroda.setLaunchDate(new Date(1000));
session.save(kuroda);
Restaurant cyma = new Restaurant("Cyma", 80.5);
cyma.setLaunchDate(new Date(2000));
session.save(cyma);
Filter launchDateFilter = new Filter("launchDate", ComparisonOperator.LESS_THAN, new Date(1001));
Collection<Restaurant> results = session.loadAll(Restaurant.class, new Filters().add(launchDateFilter));
assertThat(results).isNotNull();
assertThat(results).hasSize(1);
assertThat(results.iterator().next().getName()).isEqualTo("Kuroda");
Filter anotherFilter = new Filter("launchDate", ComparisonOperator.EQUALS, new Date(999));
results = session.loadAll(Restaurant.class, new Filters().add(anotherFilter));
assertThat(results).isNotNull();
assertThat(results).isEmpty();
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldFilterByPropertyContaining.
/**
* @see DATAGRAPH-904
*/
@Test
public void shouldFilterByPropertyContaining() {
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 filter = new Filter("name", ComparisonOperator.CONTAINING, "International Airport");
Collection<Restaurant> results = session.loadAll(Restaurant.class, new Filters().add(filter));
assertThat(results).isNotNull();
assertThat(results).hasSize(1);
assertThat(results.iterator().next().getName()).isEqualTo("San Francisco International Airport (SFO)");
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldFilterByPropertyEndingWith.
/**
* @see DATAGRAPH-904
*/
@Test
public void shouldFilterByPropertyEndingWith() {
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 filter = new Filter("name", ComparisonOperator.ENDING_WITH, "Airport (SFO)");
Collection<Restaurant> results = session.loadAll(Restaurant.class, new Filters().add(filter));
assertThat(results).isNotNull();
assertThat(results).hasSize(1);
assertThat(results.iterator().next().getName()).isEqualTo("San Francisco International Airport (SFO)");
}
Aggregations