use of org.neo4j.ogm.domain.cineasts.annotated.User 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.User in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method loadParticularUserRatingsAndComments.
@Test
public void loadParticularUserRatingsAndComments() {
Collection<User> filmCritics = session.loadAll(User.class, new Filter("name", ComparisonOperator.EQUALS, "Michal"));
assertThat(filmCritics).hasSize(1);
User critic = filmCritics.iterator().next();
assertThat(critic.getRatings()).hasSize(2);
for (Rating rating : critic.getRatings()) {
assertThat(rating.getComment()).as("The comment should've been mapped").isNotNull();
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 movie end node should've been mapped").isNotNull();
}
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method saveAndRetrieveUserWithTitles.
@Test
public void saveAndRetrieveUserWithTitles() {
User user = new User();
user.setLogin("vince");
user.setName("Vince");
user.setPassword("vince");
user.setTitles(Arrays.asList(Title.MR));
session.save(user);
User vince = session.load(User.class, "vince");
assertThat(vince).isNotNull();
assertThat(vince.getName()).isEqualTo("Vince");
assertThat(vince.getTitles()).hasSize(1);
assertThat(vince.getTitles().get(0)).isEqualTo(Title.MR);
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method nestedFilteringMustThrowExceptionWithOrInThePipelineForRelationshipEntities.
@Test
public void nestedFilteringMustThrowExceptionWithOrInThePipelineForRelationshipEntities() {
Filter userNameFilter = new Filter("name", ComparisonOperator.EQUALS, "Michal");
userNameFilter.setBooleanOperator(BooleanOperator.OR);
Filter ratingFilter = new Filter("stars", ComparisonOperator.EQUALS, 5);
userNameFilter.setNestedPath(new Filter.NestedPathSegment("user", User.class));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> session.loadAll(Rating.class, userNameFilter.and(ratingFilter))).withMessage("Filters containing nested paths cannot be combined via the logical OR operator.");
}
use of org.neo4j.ogm.domain.cineasts.annotated.User 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);
}
Aggregations