Search in sources :

Example 1 with Restaurant

use of org.neo4j.ogm.domain.restaurant.Restaurant 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");
}
Also used : Restaurant(org.neo4j.ogm.domain.restaurant.Restaurant) Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Date(java.util.Date) Test(org.junit.Test)

Example 2 with Restaurant

use of org.neo4j.ogm.domain.restaurant.Restaurant 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();
}
Also used : Restaurant(org.neo4j.ogm.domain.restaurant.Restaurant) Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Date(java.util.Date) Test(org.junit.Test)

Example 3 with Restaurant

use of org.neo4j.ogm.domain.restaurant.Restaurant 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)");
}
Also used : Restaurant(org.neo4j.ogm.domain.restaurant.Restaurant) Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Date(java.util.Date) Test(org.junit.Test)

Example 4 with Restaurant

use of org.neo4j.ogm.domain.restaurant.Restaurant 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)");
}
Also used : Restaurant(org.neo4j.ogm.domain.restaurant.Restaurant) Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Date(java.util.Date) Test(org.junit.Test)

Example 5 with Restaurant

use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.

the class RestaurantIntegrationTest method shouldQueryByDistance.

@Test
public void shouldQueryByDistance() {
    Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Location(37.61649, -122.38681), 94128);
    session.save(restaurant);
    HashMap<String, Object> parameters = new HashMap<>();
    parameters.put("distance", 1000);
    Restaurant found = session.queryForObject(Restaurant.class, "MATCH (r:Restaurant) " + "WHERE distance(point({latitude: r.latitude, longitude:r.longitude}),point({latitude:37.0, longitude:-118.0, crs: 'WGS-84'})) < $distance*1000 RETURN r;", parameters);
    assertThat(found).isNotNull();
}
Also used : Restaurant(org.neo4j.ogm.domain.restaurant.Restaurant) HashMap(java.util.HashMap) Location(org.neo4j.ogm.domain.restaurant.Location) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)18 Restaurant (org.neo4j.ogm.domain.restaurant.Restaurant)18 Filter (org.neo4j.ogm.cypher.Filter)12 Filters (org.neo4j.ogm.cypher.Filters)10 Location (org.neo4j.ogm.domain.restaurant.Location)7 Date (java.util.Date)6 Branch (org.neo4j.ogm.domain.restaurant.Branch)3 Franchise (org.neo4j.ogm.domain.restaurant.Franchise)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ContainsAnyComparison (org.neo4j.ogm.cypher.function.ContainsAnyComparison)1 DistanceComparison (org.neo4j.ogm.cypher.function.DistanceComparison)1 DistanceFromPoint (org.neo4j.ogm.cypher.function.DistanceFromPoint)1