use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldSaveRestaurantWithCompositeLocationConverter.
@Test
public void shouldSaveRestaurantWithCompositeLocationConverter() {
Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Location(37.61649, -122.38681), 94128);
session.save(restaurant);
session.clear();
assertThat(session.query("MATCH (n:`Restaurant` {name: 'San Francisco International Airport (SFO)', latitude: 37.61649, " + "longitude: -122.38681, zip: 94128, score: 0.0, halal: false, specialities:[]}) return n", emptyMap()).queryResults()).hasSize(1);
}
use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method saveAndRetrieveRestaurantWithLocation.
@Test
public void saveAndRetrieveRestaurantWithLocation() {
Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Location(37.61649, -122.38681), 94128);
session.save(restaurant);
session.clear();
Collection<Restaurant> results = session.loadAll(Restaurant.class, new Filter("name", ComparisonOperator.EQUALS, "San Francisco International Airport (SFO)"));
assertThat(results).hasSize(1);
Restaurant result = results.iterator().next();
assertThat(result.getLocation()).isNotNull();
assertThat(result.getLocation().getLatitude()).isCloseTo(37.61649, within(0d));
assertThat(result.getLocation().getLongitude()).isCloseTo(-122.38681, within(0d));
}
use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldProvideUniqueParameterNamesForFilters.
/**
* @see issue #137
*/
@Test
public void shouldProvideUniqueParameterNamesForFilters() {
Restaurant restaurant = new Restaurant();
restaurant.setName("La Cocina De Flaming Lips");
session.save(restaurant);
Restaurant another = new Restaurant();
another.setName("Antica Pesa");
session.save(another);
Filters filters = new Filters();
Filter firstFilter = new Filter("name", ComparisonOperator.EQUALS, "Foobar");
firstFilter.setBooleanOperator(BooleanOperator.OR);
filters.add(firstFilter);
Filter secondFilter = new Filter("name", ComparisonOperator.EQUALS, "Antica Pesa");
secondFilter.setBooleanOperator(BooleanOperator.OR);
filters.add(secondFilter);
Collection<Restaurant> results = session.loadAll(Restaurant.class, filters);
assertThat(results.size() >= 1).isTrue();
}
use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldFilterByCollectionContaining.
@Test
public void shouldFilterByCollectionContaining() {
Restaurant sfo = new Restaurant("San Francisco International Airport (SFO)", 72.4);
sfo.getSpecialities().add("burger");
sfo.getSpecialities().add("pizza");
session.save(sfo);
Restaurant kuroda = new Restaurant("Kuroda", 80.5);
kuroda.getSpecialities().add("sushi");
session.save(kuroda);
Filter f1 = new Filter("specialities", new ContainsAnyComparison(Arrays.asList("burger")));
Collection<Restaurant> burgers = session.loadAll(Restaurant.class, new Filters(f1));
assertThat(burgers).hasSize(1);
assertThat(burgers.iterator().next().getName()).isEqualTo("San Francisco International Airport (SFO)");
Filter f2 = new Filter("specialities", new ContainsAnyComparison(Arrays.asList("burger", "sushi")));
Collection<Restaurant> all = session.loadAll(Restaurant.class, new Filters(f2));
assertThat(all).hasSize(2);
Filter f3 = new Filter("specialities", new ContainsAnyComparison(Arrays.asList("sushi", "other")));
Collection<Restaurant> sushi = session.loadAll(Restaurant.class, new Filters(f3));
assertThat(sushi).hasSize(1);
}
use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldQueryByDistanceUsingFilter.
@Test
public void shouldQueryByDistanceUsingFilter() {
Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Location(37.61649, -122.38681), 94128);
session.save(restaurant);
session.clear();
Filter filter = new Filter(new DistanceComparison(new DistanceFromPoint(37.61649, -122.38681, 1000 * 1000.0)), ComparisonOperator.LESS_THAN);
Collection<Restaurant> found = session.loadAll(Restaurant.class, filter);
assertThat(found).isNotNull();
assertThat(found.size() >= 1).isTrue();
}
Aggregations