Search in sources :

Example 11 with User

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);
}
Also used : Movie(org.neo4j.ogm.domain.cineasts.annotated.Movie) User(org.neo4j.ogm.domain.cineasts.annotated.User) Filter(org.neo4j.ogm.cypher.Filter) Rating(org.neo4j.ogm.domain.cineasts.annotated.Rating) Pet(org.neo4j.ogm.domain.cineasts.annotated.Pet) Test(org.junit.Test)

Example 12 with User

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();
    }
}
Also used : User(org.neo4j.ogm.domain.cineasts.annotated.User) Filter(org.neo4j.ogm.cypher.Filter) Rating(org.neo4j.ogm.domain.cineasts.annotated.Rating) Test(org.junit.Test)

Example 13 with User

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);
}
Also used : User(org.neo4j.ogm.domain.cineasts.annotated.User) Test(org.junit.Test)

Example 14 with User

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.");
}
Also used : User(org.neo4j.ogm.domain.cineasts.annotated.User) Filter(org.neo4j.ogm.cypher.Filter) Test(org.junit.Test)

Example 15 with User

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);
}
Also used : Movie(org.neo4j.ogm.domain.cineasts.annotated.Movie) User(org.neo4j.ogm.domain.cineasts.annotated.User) Filter(org.neo4j.ogm.cypher.Filter) Plays(org.neo4j.ogm.domain.cineasts.annotated.Plays) Rating(org.neo4j.ogm.domain.cineasts.annotated.Rating) Test(org.junit.Test)

Aggregations

User (org.neo4j.ogm.domain.cineasts.annotated.User)46 Test (org.junit.Test)45 Movie (org.neo4j.ogm.domain.cineasts.annotated.Movie)25 Rating (org.neo4j.ogm.domain.cineasts.annotated.Rating)24 Filter (org.neo4j.ogm.cypher.Filter)19 ExtendedUser (org.neo4j.ogm.domain.cineasts.annotated.ExtendedUser)17 Map (java.util.Map)12 HashMap (java.util.HashMap)11 HashSet (java.util.HashSet)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Filters (org.neo4j.ogm.cypher.Filters)3 Pet (org.neo4j.ogm.domain.cineasts.annotated.Pet)3 Pagination (org.neo4j.ogm.cypher.query.Pagination)2 SortOrder (org.neo4j.ogm.cypher.query.SortOrder)2 Plays (org.neo4j.ogm.domain.cineasts.annotated.Plays)2 Result (org.neo4j.ogm.model.Result)2 Session (org.neo4j.ogm.session.Session)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URL (java.net.URL)1