Search in sources :

Example 16 with Restaurant

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

the class RestaurantIntegrationTest method shouldFilterByPropertyIsTrue.

/**
 * @see DATAGRAPH-904
 */
@Test
public void shouldFilterByPropertyIsTrue() {
    Restaurant kazan = new Restaurant("Kazan", 77.0);
    kazan.setHalal(true);
    session.save(kazan);
    Restaurant kuroda = new Restaurant("Kuroda", 72.4);
    kuroda.setHalal(false);
    session.save(kuroda);
    Filter isHalal = new Filter("halal", ComparisonOperator.IS_TRUE);
    Collection<Restaurant> results = session.loadAll(Restaurant.class, new Filters().add(isHalal));
    assertThat(results).isNotNull();
    assertThat(results).hasSize(1);
    assertThat(results.iterator().next().getName()).isEqualTo("Kazan");
    Filter notHalal = new Filter("halal", ComparisonOperator.IS_TRUE);
    notHalal.setNegated(true);
    results = session.loadAll(Restaurant.class, new Filters().add(notHalal));
    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) Test(org.junit.Test)

Example 17 with Restaurant

use of org.neo4j.ogm.domain.restaurant.Restaurant 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)");
}
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 18 with Restaurant

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

the class CompilerTest method createSingleStatementForLabelsInDifferentOrder.

@Test
public void createSingleStatementForLabelsInDifferentOrder() throws Exception {
    Franchise franchise = new Franchise();
    Restaurant r1 = new Restaurant();
    r1.setName("La Strada Tooting");
    r1.labels = Arrays.asList("Delicious", "Foreign");
    Restaurant r2 = new Restaurant();
    r2.setName("La Strada Brno");
    r2.labels = Arrays.asList("Foreign", "Delicious");
    franchise.addBranch(new Branch(new Location(0.0, 0.0), franchise, r1));
    franchise.addBranch(new Branch(new Location(0.0, 0.0), franchise, r2));
    Compiler compiler = mapAndCompile(franchise, -1);
    assertThat(compiler.createNodesStatements()).extracting(Statement::getStatement).containsOnly("UNWIND $rows as row CREATE (n:`Franchise`) SET n=row.props RETURN row.nodeRef as ref, ID(n) as id, $type as type", // the point is only one query for this combination of labels
    "UNWIND $rows as row CREATE (n:`Delicious`:`Foreign`:`Restaurant`) SET n=row.props RETURN row.nodeRef as ref, ID(n) as id, $type as type");
}
Also used : Restaurant(org.neo4j.ogm.domain.restaurant.Restaurant) Branch(org.neo4j.ogm.domain.restaurant.Branch) Franchise(org.neo4j.ogm.domain.restaurant.Franchise) 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