use of org.neo4j.ogm.domain.cineasts.annotated.Actor in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method shouldQueryForActorByIdUsingBespokeParameterisedCypherQuery.
@Test
public void shouldQueryForActorByIdUsingBespokeParameterisedCypherQuery() {
session.save(new Actor("Keanu Reeves"));
Actor carrie = new Actor("Carrie-Ann Moss");
session.save(carrie);
session.save(new Actor("Laurence Fishbourne"));
Actor loadedActor = session.queryForObject(Actor.class, "MATCH (a:Actor) WHERE a.uuid=$param RETURN a", Collections.<String, Object>singletonMap("param", carrie.getUuid()));
assertThat(loadedActor).as("The entity wasn't loaded").isNotNull();
assertThat(loadedActor.getName()).isEqualTo("Carrie-Ann Moss");
}
use of org.neo4j.ogm.domain.cineasts.annotated.Actor in project neo4j-ogm by neo4j.
the class CineastsIntegrationTest method shouldQueryForCollectionOfActorsUsingBespokeCypherQuery.
@Test
public void shouldQueryForCollectionOfActorsUsingBespokeCypherQuery() {
session.save(new Actor("Jeff"));
session.save(new Actor("John"));
session.save(new Actor("Colin"));
Iterable<Actor> actors = session.query(Actor.class, "MATCH (a:Actor) WHERE a.name=~'J.*' RETURN a", Collections.<String, Object>emptyMap());
assertThat(actors).as("The entities weren't loaded").isNotNull();
assertThat(actors.iterator().hasNext()).as("The entity wasn't loaded").isTrue();
assertThat(actors).extracting(Actor::getName).containsOnly("John", "Jeff");
}
use of org.neo4j.ogm.domain.cineasts.annotated.Actor in project neo4j-ogm by neo4j.
the class CineastsRelationshipEntityTest method shouldSaveRelationshipEntityWithCamelCaseStartEndNodes.
// DATAGRAPH-567
@Test
public void shouldSaveRelationshipEntityWithCamelCaseStartEndNodes() {
Actor bruce = new Actor("Bruce");
Actor jim = new Actor("Jim");
Knows knows = new Knows();
knows.setFirstActor(bruce);
knows.setSecondActor(jim);
knows.setSince(new Date());
bruce.getKnows().add(knows);
session.save(bruce);
Actor actor = TestUtils.firstOrNull(session.loadAll(Actor.class, new Filter("name", ComparisonOperator.EQUALS, "Bruce")));
assertThat(actor).isNotNull();
assertThat(actor.getKnows()).hasSize(1);
assertThat(actor.getKnows().iterator().next().getSecondActor().getName()).isEqualTo("Jim");
}
use of org.neo4j.ogm.domain.cineasts.annotated.Actor in project neo4j-ogm by neo4j.
the class CineastsRelationshipEntityTest method shouldSaveSameRoleTwiceRelationshipBetweenTheSameTwoObjects.
@Test
public void shouldSaveSameRoleTwiceRelationshipBetweenTheSameTwoObjects() {
Movie movie = new Movie("The big John Travolta Party", 2016);
Actor actor = new Actor("John Travolta");
actor.playedIn(movie, "He danced mostly");
assertThat(actor.getRoles()).hasSize(1);
session.save(actor);
session.clear();
Actor loadedActor = session.load(Actor.class, actor.getUuid());
assertThat(loadedActor.getRoles()).hasSize(1);
// Add an identical role
actor.playedIn(movie, "He danced mostly");
assertThat(actor.getRoles()).hasSize(2);
session.save(actor);
session.clear();
loadedActor = session.load(Actor.class, actor.getUuid());
assertThat(loadedActor.getRoles()).hasSize(2);
}
use of org.neo4j.ogm.domain.cineasts.annotated.Actor in project neo4j-ogm by neo4j.
the class CineastsRelationshipEntityTest method shouldSaveRelationshipEntityWithNullProperty.
// DATAGRAPH-610
@Test
public void shouldSaveRelationshipEntityWithNullProperty() {
Actor bruce = new Actor("Bruce");
Actor jim = new Actor("Jim");
// since = null
Knows knows = new Knows();
knows.setFirstActor(bruce);
knows.setSecondActor(jim);
bruce.getKnows().add(knows);
session.save(bruce);
Actor actor = TestUtils.firstOrNull(session.loadAll(Actor.class, new Filter("name", ComparisonOperator.EQUALS, "Bruce")));
assertThat(actor).isNotNull();
assertThat(actor.getKnows()).hasSize(1);
assertThat(actor.getKnows().iterator().next().getSecondActor().getName()).isEqualTo("Jim");
bruce.getKnows().iterator().next().setSince(new Date());
session.save(bruce);
actor = TestUtils.firstOrNull(session.loadAll(Actor.class, new Filter("name", ComparisonOperator.EQUALS, "Bruce")));
assertThat(actor.getKnows()).hasSize(1);
assertThat(actor.getKnows().iterator().next().getSince()).isNotNull();
bruce.getKnows().iterator().next().setSince(null);
session.save(bruce);
actor = TestUtils.firstOrNull(session.loadAll(Actor.class, new Filter("name", ComparisonOperator.EQUALS, "Bruce")));
assertThat(actor.getKnows()).hasSize(1);
assertThat(actor.getKnows().iterator().next().getSince()).isNull();
}
Aggregations