use of org.neo4j.ogm.domain.cineasts.minimum.Movie in project neo4j-ogm by neo4j.
the class MinimalRelationshipEntityMappingTest method verifyChangeOfRelationshipEnd.
// GH-607
@Test
public void verifyChangeOfRelationshipEnd() {
session = sessionFactory.openSession();
Actor actor = new Actor("A1");
Movie movie = new Movie("M1");
Role role = new Role("R1", actor, movie);
session.save(role);
session = sessionFactory.openSession();
Iterable<Map<String, Object>> results = session.query("MATCH (m:Movie) <- [:ACTS_IN] - (:Actor {name: 'A1'}) RETURN COUNT(m) as cnt", Collections.emptyMap()).queryResults();
assertThat(results).hasSize(1);
assertThat(results).first().satisfies(m -> assertThat(m).containsEntry("cnt", 1L));
// New session / TX
session = sessionFactory.openSession();
movie = new Movie("M2");
role = session.load(Role.class, role.getId());
role.setMovie(new Movie("M2"));
session.save(role);
session = sessionFactory.openSession();
results = session.query("MATCH (m:Movie) <- [:ACTS_IN] - (:Actor {name: 'A1'}) RETURN COUNT(m) as cnt", Collections.emptyMap()).queryResults();
assertThat(results).hasSize(1);
assertThat(results).first().satisfies(m -> assertThat(m).containsEntry("cnt", 1L));
}
use of org.neo4j.ogm.domain.cineasts.minimum.Movie in project neo4j-ogm by neo4j.
the class RelationshipEntityPartialMappingTest method shouldNotDropUnmappedRelationshipModels.
// GH-727
@Test
public void shouldNotDropUnmappedRelationshipModels() {
Session session = sessionFactory.openSession();
Actor actor = new Actor("A1");
Movie movie = new Movie("M1");
Role role = new Role("R1", actor, movie);
session.save(role);
session = sessionFactory.openSession();
Iterable<Map<String, Object>> results = session.query("MATCH (m) - [r] - (a) WHERE id(a) = $id RETURN r", Collections.singletonMap("id", actor.getId())).queryResults();
assertThat(results).hasSize(1);
Map<String, Object> row = results.iterator().next();
assertThat(row).containsKeys("r");
assertThat(row.get("r")).isNotNull().isInstanceOf(RelationshipModel.class);
}
use of org.neo4j.ogm.domain.cineasts.minimum.Movie in project neo4j-ogm by neo4j.
the class RelationshipEntityPartialMappingTest method shouldMapSingleRelationshipModel.
// GH-727
@Test
public void shouldMapSingleRelationshipModel() {
Session session = sessionFactory.openSession();
Actor actor = new Actor("A1");
Movie movie = new Movie("M1");
Role role = new Role("R1", actor, movie);
session.save(role);
session = sessionFactory.openSession();
Iterable<Map<String, Object>> results = session.query("MATCH (m) - [r] - (a) WHERE id(a) = $id RETURN m, r, a", Collections.singletonMap("id", actor.getId())).queryResults();
assertThat(results).hasSize(1);
Map<String, Object> row = results.iterator().next();
assertThat(row).containsKeys("r");
assertThat(row.get("r")).isNotNull().isInstanceOf(Role.class);
}
Aggregations