use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldUpdateLabelsCorrectly.
@Test
public void shouldUpdateLabelsCorrectly() 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("Average", "Foreign");
franchise.addBranch(new Branch(new Location(0.0, 0.0), franchise, r1));
franchise.addBranch(new Branch(new Location(0.0, 0.0), franchise, r2));
session.save(franchise);
// remove labels, different label for each entity
r1.labels = Arrays.asList("Foreign");
r2.labels = Arrays.asList("Foreign");
session.save(franchise);
session.clear();
Restaurant loadedR1 = session.load(Restaurant.class, r1.getId());
assertThat(loadedR1.labels).containsOnly("Foreign");
Restaurant loadedR2 = session.load(Restaurant.class, r2.getId());
assertThat(loadedR2.labels).containsOnly("Foreign");
}
use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldSyncMappedLabelsFromEntityToTheNode_and_NodeToEntity.
/**
* @see issue #159
*/
@Test
public void shouldSyncMappedLabelsFromEntityToTheNode_and_NodeToEntity() {
Restaurant restaurant = new Restaurant();
restaurant.setName("House of Mushroom & Pepperoni");
List<String> labels = new ArrayList<>();
labels.add("Delicious");
labels.add("Ambiance");
labels.add("Convenience");
restaurant.labels = labels;
session.save(restaurant);
session.clear();
Restaurant loaded = session.load(Restaurant.class, restaurant.getId());
assertThat(loaded.labels.contains("Delicious")).isTrue();
assertThat(loaded.labels.contains("Ambiance")).isTrue();
assertThat(loaded.labels.contains("Convenience")).isTrue();
assertThat(loaded.labels).hasSize(3);
}
use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldFilterByPropertyExists.
/**
* @see DATAGRAPH-904
*/
@Test
public void shouldFilterByPropertyExists() {
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 exists = new Filter("name", ComparisonOperator.EXISTS);
Collection<Restaurant> results = session.loadAll(Restaurant.class, new Filters().add(exists));
assertThat(results).isNotNull();
assertThat(results).hasSize(2);
Filter notExists = new Filter("name", ComparisonOperator.EXISTS);
notExists.setNegated(true);
results = session.loadAll(Restaurant.class, new Filters().add(notExists));
assertThat(results).isNotNull();
assertThat(results).isEmpty();
}
use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldFilterByIsNullOrNotNull.
/**
* @see DATAGRAPH-904
*/
@Test
public void shouldFilterByIsNullOrNotNull() {
Restaurant kuroda = new Restaurant("Kuroda", "Mainly Ramen");
session.save(kuroda);
Restaurant cyma = new Restaurant();
cyma.setName("Cyma");
session.save(cyma);
session.clear();
Filter descriptionIsNull = new Filter("description", ComparisonOperator.IS_NULL, null);
Collection<Restaurant> results = session.loadAll(Restaurant.class, new Filters().add(descriptionIsNull));
assertThat(results).hasSize(1);
Restaurant restaurant = results.iterator().next();
assertThat(restaurant.getName()).isEqualTo("Cyma");
Filter descriptionIsNotNull = new Filter("description", ComparisonOperator.IS_NULL, null);
descriptionIsNotNull.setNegated(true);
results = session.loadAll(Restaurant.class, new Filters().add(descriptionIsNotNull));
assertThat(results).hasSize(1);
restaurant = results.iterator().next();
assertThat(restaurant.getName()).isEqualTo("Kuroda");
}
use of org.neo4j.ogm.domain.restaurant.Restaurant in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldSaveBranchWitlCompositeLocationConverter.
@Test
public void shouldSaveBranchWitlCompositeLocationConverter() throws Exception {
Franchise franchise = new Franchise();
Restaurant restaurant = new Restaurant();
Branch branch = new Branch(new Location(37.61649, -122.38681), franchise, restaurant);
session.save(branch);
session.clear();
Branch loaded = session.load(Branch.class, branch.getId());
assertThat(loaded.getLocation().getLatitude()).isCloseTo(37.61649, within(0.00001));
assertThat(loaded.getLocation().getLongitude()).isCloseTo(-122.38681, within(0.00001));
}
Aggregations