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");
}
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)");
}
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");
}
Aggregations