Search in sources :

Example 1 with AnotherThing

use of org.neo4j.ogm.domain.gh551.AnotherThing in project neo4j-ogm by neo4j.

the class SingleUseEntityMapperTest method singleUseEntityMapperShouldWorkWithNestedObjects.

// GH-551
@Test
public void singleUseEntityMapperShouldWorkWithNestedObjects() {
    SingleUseEntityMapper entityMapper = new SingleUseEntityMapper(sessionFactory.metaData(), new ReflectionEntityInstantiator(sessionFactory.metaData()));
    Iterable<Map<String, Object>> results = sessionFactory.openSession().query("MATCH (t:ThingEntity) RETURN 'a name' as something, collect({name: t.name}) as things", EMPTY_MAP).queryResults();
    assertThat(results).hasSize(1);
    ThingResult thingResult = entityMapper.map(ThingResult.class, results.iterator().next());
    assertThat(thingResult.getSomething()).isEqualTo("a name");
    assertThat(thingResult.getThings()).hasSize(10).extracting(AnotherThing::getName).allSatisfy(s -> s.startsWith("Thing"));
}
Also used : ThingResult(org.neo4j.ogm.domain.gh551.ThingResult) HashMap(java.util.HashMap) Map(java.util.Map) ReflectionEntityInstantiator(org.neo4j.ogm.metadata.reflect.ReflectionEntityInstantiator) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 ThingResult (org.neo4j.ogm.domain.gh551.ThingResult)1 ReflectionEntityInstantiator (org.neo4j.ogm.metadata.reflect.ReflectionEntityInstantiator)1