use of org.neo4j.ogm.domain.cineasts.annotated.Movie in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method nestedFilteringCanBeTheOneAndOnlyOredFilter.
@Test
public void nestedFilteringCanBeTheOneAndOnlyOredFilter() {
Filter filterB = new Filter("name", ComparisonOperator.EQUALS, "Catty");
filterB.setNestedPath(new Filter.NestedPathSegment("ratings", Rating.class), new Filter.NestedPathSegment("user", User.class), new Filter.NestedPathSegment("pets", Pet.class));
filterB.setBooleanOperator(BooleanOperator.OR);
Filters filters = new Filters(filterB);
Collection<Movie> films = session.loadAll(Movie.class, filters);
assertThat(films).hasSize(2);
}
use of org.neo4j.ogm.domain.cineasts.annotated.Movie in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method loadFilmByRatingUsersPet.
@Test
public void loadFilmByRatingUsersPet() {
// Pulp Fiction and Top Gear rated by Michal who owns Catty
Filter filter = new Filter("name", ComparisonOperator.EQUALS, "Catty");
filter.setOwnerEntityType(Movie.class);
filter.setNestedPath(new Filter.NestedPathSegment("ratings", Rating.class), new Filter.NestedPathSegment("user", User.class), new Filter.NestedPathSegment("pets", Pet.class));
Collection<Movie> films = session.loadAll(Movie.class, filter);
assertThat(films).hasSize(2);
}
use of org.neo4j.ogm.domain.cineasts.annotated.Movie in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method loadRatingsForSpecificFilm.
@Test
public void loadRatingsForSpecificFilm() {
Collection<Movie> films = session.loadAll(Movie.class, new Filter("title", ComparisonOperator.EQUALS, "Top Gear"));
assertThat(films).hasSize(1);
Movie film = films.iterator().next();
assertThat(film.getRatings()).hasSize(2);
for (Rating rating : film.getRatings()) {
assertThat(rating.getStars() > 0).as("The star rating should've been mapped").isTrue();
assertThat(rating.getUser()).as("The user start node should've been mapped").isNotNull();
assertThat(rating.getMovie()).as("The wrong film was mapped to the rating").isSameAs(film);
}
}
use of org.neo4j.ogm.domain.cineasts.annotated.Movie in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method loadFilmByRatingUserPlays.
@Test
public void loadFilmByRatingUserPlays() {
Filter filter = new Filter("level", ComparisonOperator.EQUALS, "ok");
filter.setOwnerEntityType(Movie.class);
filter.setNestedPath(new Filter.NestedPathSegment("ratings", Rating.class), new Filter.NestedPathSegment("user", User.class), new Filter.NestedPathSegment("plays", Plays.class));
Collection<Movie> films = session.loadAll(Movie.class, filter);
assertThat(films).hasSize(2);
}
use of org.neo4j.ogm.domain.cineasts.annotated.Movie in project neo4j-ogm by neo4j.
the class CineastsRelationshipEntityTest method shouldHydrateTheEndNodeOfAnRECorrectly.
// DATAGRAPH-552
@Test
public void shouldHydrateTheEndNodeOfAnRECorrectly() {
Movie movie = new Movie("Pulp Fiction", 1994);
Actor actor = new Actor("John Travolta");
actor.playedIn(movie, "Vincent");
session.save(movie);
User michal = new User();
michal.setName("Michal");
michal.setLogin("bachmania");
Rating awesome = new Rating();
awesome.setMovie(movie);
awesome.setUser(michal);
awesome.setStars(5);
michal.setRatings(Collections.singleton(awesome));
session.save(michal);
// Check that Pulp Fiction has one rating from Michal
Collection<Movie> films = session.loadAll(Movie.class, new Filter("title", ComparisonOperator.EQUALS, "Pulp Fiction"));
assertThat(films).hasSize(1);
Movie film = films.iterator().next();
assertThat(film).isNotNull();
assertThat(film.getRatings()).hasSize(1);
assertThat(film.getRatings().iterator().next().getUser().getName()).isEqualTo("Michal");
assertThat(film.getRoles().iterator().next().getRole()).isEqualTo("Vincent");
session.clear();
Rating rating = session.load(Rating.class, awesome.getId(), 2);
assertThat(rating).isNotNull();
Movie loadedMovie = rating.getMovie();
assertThat(loadedMovie).isNotNull();
assertThat(loadedMovie.getTitle()).isEqualTo("Pulp Fiction");
assertThat(loadedMovie.getRoles().iterator().next().getRole()).isEqualTo("Vincent");
}
Aggregations