use of org.neo4j.ogm.domain.cineasts.annotated.Role in project neo4j-ogm by neo4j.
the class CineastsRelationshipEntityTest method updateRoleToSameValueResultsInTwoRelationshipBetweenSameObjects.
@Test
public void updateRoleToSameValueResultsInTwoRelationshipBetweenSameObjects() throws Exception {
Movie movie = new Movie("The big John Travolta Party", 2016);
Actor actor = new Actor("John Travolta");
Role role1 = actor.playedIn(movie, "He danced mostly");
Role role2 = actor.playedIn(movie, "He was dancing mostly");
assertThat(actor.getRoles()).hasSize(2);
session.save(actor);
session.clear();
Actor loaded = session.load(Actor.class, actor.getUuid());
assertThat(loaded.getRoles()).hasSize(2);
// set to identical role - this should behave consistently to previous test case
role2.setRole("He danced mostly");
session.save(actor);
session.clear();
loaded = session.load(Actor.class, actor.getUuid());
assertThat(loaded.getRoles()).hasSize(2);
}
use of org.neo4j.ogm.domain.cineasts.annotated.Role in project neo4j-ogm by neo4j.
the class RelationshipEntityMappingTest method shouldBeAbleToSaveAndLoadRelationshipEntityWithNullProperties.
@Test
public void shouldBeAbleToSaveAndLoadRelationshipEntityWithNullProperties() {
Actor keanu = new Actor("Keanu Reeves");
Movie matrix = new Movie("The Matrix", 1999);
HashSet<Role> roles = new HashSet<>();
Role role = new Role(matrix, keanu, null);
roles.add(role);
keanu.setRoles(roles);
session.save(keanu);
Map<String, Object> params = new HashMap<>();
params.put("actorId", keanu.getUuid());
Result result = session.query("MATCH (a:Actor)-[r:ACTS_IN]-(m:Movie) WHERE a.uuid = $actorId RETURN r as rel", params, true);
Iterator<Map<String, Object>> iterator = result.iterator();
Map<String, Object> first = iterator.next();
assertThat(role).isSameAs(first.get("rel"));
}
Aggregations