use of org.neo4j.ogm.domain.cineasts.minimum.Actor in project neo4j-ogm by neo4j.
the class RelationshipEntityPartialMappingTest method testCreateActorRoleAndMovie.
@Test
public void testCreateActorRoleAndMovie() {
Actor keanu = new Actor("Keanu Reeves");
Movie matrix = new Movie("The Matrix");
// note: this does not establish a role relationship on the matrix
keanu.addRole("Neo", matrix);
session.save(keanu);
session.clear();
assertThat(session.query("MATCH (a:Actor {name:'Keanu Reeves'}), " + "(m:Movie {name:'The Matrix'}) " + "WHERE (a)-[:ACTS_IN {played:'Neo'}]->(m) return a, m", emptyMap()).queryResults()).hasSize(1);
}
use of org.neo4j.ogm.domain.cineasts.minimum.Actor in project neo4j-ogm by neo4j.
the class RelationshipEntityPartialMappingTest method testCreateAndDeleteActorMultipleRolesAndMovies.
@Test
public void testCreateAndDeleteActorMultipleRolesAndMovies() {
Actor keanu = new Actor("Keanu Reeves");
Movie matrix = new Movie("The Matrix");
Movie hp = new Movie("Harry Potter");
keanu.addRole("Neo", matrix);
keanu.addRole("Dumbledore", hp);
session.save(keanu);
Actor keanu2 = session.load(Actor.class, keanu.getId());
assertThat(keanu2.roles()).hasSize(2);
keanu2.removeRole("Dumbledore");
session.save(keanu2);
Actor keanu3 = session.load(Actor.class, keanu2.getId());
assertThat(keanu3.roles()).hasSize(1);
}
use of org.neo4j.ogm.domain.cineasts.minimum.Actor in project neo4j-ogm by neo4j.
the class SingleUseEntityMapperTest method oneTimeSetUp.
@BeforeClass
public static void oneTimeSetUp() {
sessionFactory = new SessionFactory(getDriver(), "org.neo4j.ogm.domain.gh551", "org.neo4j.ogm.domain.gh391", "org.neo4j.ogm.domain.gh750", "org.neo4j.ogm.domain.gh777", "org.neo4j.ogm.domain.cineasts.minimum", "org.neo4j.ogm.domain.gh813", "org.neo4j.ogm.domain.gh873");
// Prepare test data
Session session = sessionFactory.openSession();
session.query("MATCH (n) DETACH DELETE n", EMPTY_MAP);
session.query("unwind range(1,10) as x with x create (n:ThingEntity {name: 'Thing ' + x}) return n", EMPTY_MAP);
Actor actor = new Actor("A1");
Movie movie = new Movie("M1");
Role role = new Role("R1", actor, movie);
session.save(role);
movie = new Movie("M2");
role = new Role("R2", actor, movie);
session.save(role);
session.save(new UserInfo("Foo", "Bar", "i@do.com"));
MyNode myNode = new MyNode();
myNode.setId("the-id");
myNode.setType("the-type");
myNode.getAttributes().put("a1", "v1");
myNode.getAttributes().put("a2", "v2");
session.save(myNode);
}
use of org.neo4j.ogm.domain.cineasts.minimum.Actor in project neo4j-ogm by neo4j.
the class RelationshipEntityPartialMappingTest method testCreateAndReloadActorMultipleRolesAndMovies.
@Test
public void testCreateAndReloadActorMultipleRolesAndMovies() {
Actor keanu = new Actor("Keanu Reeves");
Movie matrix = new Movie("The Matrix");
Movie speed = new Movie("Speed");
keanu.addRole("Neo", matrix);
keanu.addRole("Jack Traven", speed);
session.save(keanu);
Actor keanu2 = session.load(Actor.class, keanu.getId());
assertThat(keanu2.roles()).hasSize(2);
keanu2.addRole("John Constantine", new Movie("Constantine"));
session.save(keanu2);
Actor keanu3 = session.load(Actor.class, keanu2.getId());
assertThat(keanu3.roles()).hasSize(3);
}
use of org.neo4j.ogm.domain.cineasts.minimum.Actor in project neo4j-ogm by neo4j.
the class RelationshipEntityPartialMappingTest method testCreateAndReloadActorRoleAndMovie.
@Test
public void testCreateAndReloadActorRoleAndMovie() {
Actor keanu = new Actor("Keanu Reeves");
Movie matrix = new Movie("The Matrix");
keanu.addRole("Neo", matrix);
session.save(keanu);
Actor keanu2 = session.load(Actor.class, keanu.getId());
assertThat(keanu2.roles()).hasSize(1);
}
Aggregations