use of org.neo4j.ogm.domain.gh851.Flight in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method createFlights.
private void createFlights() {
// Create a few airports
Airport lhr = new Airport("LHR", "London Heathrow");
Airport lax = new Airport("LAX", "Los Angeles");
Airport cdg = new Airport("CDG", "Paris Charles de Gaulle");
// Create some flights
session.save(new Flight("FL 001", lhr, lax));
session.save(new Flight("FL 002", lhr, cdg));
session.save(new Flight("FL 003", lax, lhr));
}
use of org.neo4j.ogm.domain.gh851.Flight 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.domain.gh851.Flight in project neo4j-ogm by neo4j.
the class QueryCapabilityTest method deepNestedFiltersOnSameEntitiesButDifferentRelationsShouldWork.
// GH-851
@Test
public void deepNestedFiltersOnSameEntitiesButDifferentRelationsShouldWork() {
Filters filters = new Filters();
Filter filter = new Filter("code", ComparisonOperator.EQUALS, "LHR");
filter.setOwnerEntityType(Flight.class);
filter.setNestedPath(new Filter.NestedPathSegment("departure", Airport.class));
filters.and(filter);
filter = new Filter("code", ComparisonOperator.EQUALS, "LAX");
filter.setOwnerEntityType(Flight.class);
filter.setNestedPath(new Filter.NestedPathSegment("arrival", Airport.class));
filters.and(filter);
Collection<Flight> flights = session.loadAll(Flight.class, filters);
assertThat(flights).hasSize(1).first().extracting(Flight::getName).isEqualTo("FL 001");
}