use of org.neo4j.ogm.domain.cineasts.minimum.SomeQueryResult in project neo4j-ogm by neo4j.
the class SingleUseEntityMapperTest method queryResultShouldHandleNodeAndRelationshipEntities.
// GH-718
@Test
public void queryResultShouldHandleNodeAndRelationshipEntities() {
SingleUseEntityMapper entityMapper = new SingleUseEntityMapper(sessionFactory.metaData(), new ReflectionEntityInstantiator(sessionFactory.metaData()));
// so that it works the same way as the org.neo4j.ogm.result.adapter.GraphModelAdapter.adapt
for (String query : new String[] { "MATCH (a:Actor {name: 'A1'})-[r:ACTS_IN]->(m:Movie) RETURN a AS actor,COLLECT(r) AS roles, COLLECT(m) as movies", "MATCH (a:Actor {name: 'A1'})-[r:ACTS_IN*]->(m:Movie) RETURN a AS actor,COLLECT(r) AS roles, COLLECT(m) as movies" }) {
Iterable<Map<String, Object>> results = sessionFactory.openSession().query(query, EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
SomeQueryResult thingResult = entityMapper.map(SomeQueryResult.class, results.iterator().next());
assertThat(thingResult.getActor().getName()).isEqualTo("A1");
assertThat(thingResult.getRoles()).hasSize(2).extracting(Role::getPlayed).containsExactlyInAnyOrder("R1", "R2");
}
}
Aggregations