use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method loadRatingByUserNameAndStars.
@Test
public void loadRatingByUserNameAndStars() {
Filter userNameFilter = new Filter("name", ComparisonOperator.EQUALS, "Michal");
userNameFilter.setNestedPath(new Filter.NestedPathSegment("user", User.class));
Collection<Rating> ratings = session.loadAll(Rating.class, userNameFilter);
assertThat(ratings).hasSize(2);
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method loadFilmByUserAndRatingUserPlays.
@Test
public void loadFilmByUserAndRatingUserPlays() {
Filter userFilter = new Filter("name", ComparisonOperator.EQUALS, "Michal");
userFilter.setNestedPath(new Filter.NestedPathSegment("ratings", Rating.class), new Filter.NestedPathSegment("user", User.class));
Filter playsFilter = new Filter("level", ComparisonOperator.EQUALS, "ok");
playsFilter.setOwnerEntityType(Movie.class);
playsFilter.setNestedPath(new Filter.NestedPathSegment("ratings", Rating.class), new Filter.NestedPathSegment("user", User.class), new Filter.NestedPathSegment("plays", Plays.class));
Filters filters = userFilter.and(playsFilter);
Collection<Movie> films = session.loadAll(Movie.class, filters);
assertThat(films).hasSize(2);
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method nestedFilteringMustThrowExceptionWithOrInThePipeline.
@Test
public void nestedFilteringMustThrowExceptionWithOrInThePipeline() {
// rated by the user who doesn't own Catty or by the user who owns Catty
Filter filterA = new Filter("name", ComparisonOperator.EQUALS, "Catty");
filterA.setNestedPath(new Filter.NestedPathSegment("ratings", Rating.class), new Filter.NestedPathSegment("user", User.class), new Filter.NestedPathSegment("pets", Pet.class));
filterA.setNegated(true);
Filter alwaysTrueFilter = new Filter(new FilterFunction() {
private Filter theFilter;
@Override
public Object getValue() {
return null;
}
@Override
public Map<String, Object> parameters(UnaryOperator createUniqueParameterName, PropertyValueTransformer valueTransformer) {
return Collections.emptyMap();
}
@Override
public String expression(String nodeIdentifier, String filteredProperty, UnaryOperator createUniqueParameterName) {
return "1 = 1 ";
}
});
alwaysTrueFilter.setBooleanOperator(BooleanOperator.OR);
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.AND);
Filters filters = new Filters(filterA, alwaysTrueFilter, filterB);
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> session.loadAll(Movie.class, filters)).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 shouldModifyStringArraysCorrectly.
// GH-125
@Test
public void shouldModifyStringArraysCorrectly() throws MalformedURLException {
User user = new User("joker", "Joker", "password");
URL[] urls = new URL[3];
urls[0] = new URL("http://www.apple.com");
urls[1] = new URL("http://www.google.com");
urls[2] = new URL("http://www.neo4j.com");
user.setUrls(urls);
String[] nicknames = new String[2];
nicknames[0] = "batman";
nicknames[1] = "robin";
user.setNicknames(nicknames);
session.save(user);
user.getUrls()[0] = new URL("http://www.graphaware.com");
user.getNicknames()[0] = "batgirl";
session.save(user);
// Test that arrays with and without custom converters are saved and loaded correctly when their content is updated
user = session.load(User.class, user.getLogin());
assertThat(user.getUrls().length).isEqualTo(3);
assertThat(user.getUrls()[0].toString()).isEqualTo("http://www.graphaware.com");
assertThat(user.getUrls()[1].toString()).isEqualTo("http://www.google.com");
assertThat(user.getUrls()[2].toString()).isEqualTo("http://www.neo4j.com");
assertThat(user.getNicknames().length).isEqualTo(2);
assertThat(user.getNicknames()[0]).isEqualTo("batgirl");
assertThat(user.getNicknames()[1]).isEqualTo("robin");
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method loadRatingByUserName.
@Test
public void loadRatingByUserName() {
Filter userNameFilter = new Filter("name", ComparisonOperator.EQUALS, "Michal");
Filter ratingFilter = new Filter("stars", ComparisonOperator.EQUALS, 5);
userNameFilter.setNestedPath(new Filter.NestedPathSegment("user", User.class));
Collection<Rating> ratings = session.loadAll(Rating.class, userNameFilter.and(ratingFilter));
assertThat(ratings).hasSize(1);
}
Aggregations