use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldFilterByPropertyStartingWith.
/**
* @see DATAGRAPH-904
*/
@Test
public void shouldFilterByPropertyStartingWith() {
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.STARTING_WITH, "San Francisco");
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 MusicIntegrationTest method shouldSaveAndRetrieveArtistWithTwoRelationshipTypesToAlbums.
/**
* @see DATAGRAPH-637
*/
@Test
public void shouldSaveAndRetrieveArtistWithTwoRelationshipTypesToAlbums() {
Studio emi = new Studio("EMI Studios, London");
Studio olympic = new Studio("Olympic Studios, London");
Artist theBeatles = new Artist("The Beatles");
Artist eric = new Artist("Eric Clapton");
Album slowhand = new Album("Slowhand");
Recording slowRecording = new Recording(slowhand, olympic, 1977);
slowhand.setRecording(slowRecording);
slowhand.setArtist(eric);
session.save(slowhand);
session.clear();
Album theBeatlesAlbum = new Album("The Beatles");
Recording pleaseRecording = new Recording(theBeatlesAlbum, emi, 1968);
theBeatlesAlbum.setRecording(pleaseRecording);
theBeatles.getAlbums().add(theBeatlesAlbum);
theBeatlesAlbum.setArtist(theBeatles);
theBeatlesAlbum.setGuestArtist(eric);
session.save(theBeatlesAlbum);
theBeatles = session.loadAll(Artist.class, new Filters().add(new Filter("name", ComparisonOperator.EQUALS, "The Beatles"))).iterator().next();
assertThat(theBeatles.getName()).isEqualTo("The Beatles");
assertThat(theBeatles.getAlbums()).hasSize(1);
assertThat(theBeatles.getAlbums().iterator().next().getName()).isEqualTo("The Beatles");
assertThat(theBeatles.getAlbums().iterator().next().getRecording().getStudio().getName()).isEqualTo("EMI Studios, London");
assertThat(theBeatles.getAlbums().iterator().next().getGuestArtist()).isEqualTo(eric);
// Eric has 2 albums now
session.clear();
Artist loadedEric = session.loadAll(Artist.class, new Filters().add(new Filter("name", ComparisonOperator.EQUALS, "Eric Clapton"))).iterator().next();
assertThat(loadedEric).isNotNull();
assertThat(loadedEric.getGuestAlbums().iterator().next().getName()).isEqualTo("The Beatles");
assertThat(loadedEric.getAlbums().iterator().next().getName()).isEqualTo("Slowhand");
}
use of org.neo4j.ogm.cypher.Filters 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");
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class RelationshipEntityQuerySortingTest method setUp.
@Before
public void setUp() {
sortOrder = new SortOrder();
filters = new Filters();
}
use of org.neo4j.ogm.cypher.Filters in project neo4j-ogm by neo4j.
the class CountStatementsTest method testCountEdgesWithTypeAndFilters.
@Test
public void testCountEdgesWithTypeAndFilters() throws Exception {
CypherQuery query = statements.countEdges("INFLUENCE", new Filters().add(new Filter("score", ComparisonOperator.EQUALS, -12.2)));
assertThat(query.getStatement()).isEqualTo("MATCH (n)-[r0:`INFLUENCE`]->(m) WHERE r0.`score` = $`score_0` RETURN COUNT(r0)");
assertThat(query.getParameters().toString()).isEqualTo("{score_0=-12.2}");
}
Aggregations