use of org.neo4j.ogm.domain.gh551.ThingResult 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"));
}
use of org.neo4j.ogm.domain.gh551.ThingResult in project neo4j-ogm by neo4j.
the class SingleUseEntityMapperTest method shouldUseIdFields.
/**
* ID fields are treated differently in different versions of OGM. This tests assures that they work correctly.
*/
// GH-551
@Test
public void shouldUseIdFields() {
SingleUseEntityMapper entityMapper = new SingleUseEntityMapper(sessionFactory.metaData(), new ReflectionEntityInstantiator(sessionFactory.metaData()));
Iterable<Map<String, Object>> results = sessionFactory.openSession().query("MATCH (t:ThingEntity) RETURN 4711 as id, 'a name' as name LIMIT 1", EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
ThingWIthId thingResult = entityMapper.map(ThingWIthId.class, results.iterator().next());
assertThat(thingResult.getName()).isEqualTo("a name");
assertThat(thingResult.getId()).isEqualTo(4711);
}
use of org.neo4j.ogm.domain.gh551.ThingResult in project neo4j-ogm by neo4j.
the class SingleUseEntityMapperTest method singleUseEntityMapperShouldWorkWithNullableNestedNodeEntities.
// GH-748
@Test
public void singleUseEntityMapperShouldWorkWithNullableNestedNodeEntities() {
SingleUseEntityMapper entityMapper = new SingleUseEntityMapper(sessionFactory.metaData(), new ReflectionEntityInstantiator(sessionFactory.metaData()));
Iterable<Map<String, Object>> results = sessionFactory.openSession().query("WITH 'a name' AS something OPTIONAL MATCH (t:ThingEntity {na:false}) RETURN something, t as entity", EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
ThingResult2 thingResult = entityMapper.map(ThingResult2.class, results.iterator().next());
assertThat(thingResult.getSomething()).isEqualTo("a name");
assertThat(thingResult.getEntity()).isNull();
}
use of org.neo4j.ogm.domain.gh551.ThingResult in project neo4j-ogm by neo4j.
the class SingleUseEntityMapperTest method singleUseEntityMapperShouldWorkWithNonNullNestedNodeEntities.
// GH-748
@Test
public void singleUseEntityMapperShouldWorkWithNonNullNestedNodeEntities() {
SingleUseEntityMapper entityMapper = new SingleUseEntityMapper(sessionFactory.metaData(), new ReflectionEntityInstantiator(sessionFactory.metaData()));
Iterable<Map<String, Object>> results = sessionFactory.openSession().query("WITH 'a name' AS something OPTIONAL MATCH (t:ThingEntity {name: 'Thing 7'}) RETURN something, t as entity", EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
ThingResult2 thingResult = entityMapper.map(ThingResult2.class, results.iterator().next());
assertThat(thingResult.getSomething()).isEqualTo("a name");
assertThat(thingResult.getEntity()).isNotNull().extracting(ThingEntity::getName).isEqualTo("Thing 7");
}
use of org.neo4j.ogm.domain.gh551.ThingResult in project neo4j-ogm by neo4j.
the class SingleUseEntityMapperTest method shouldBeLenientWithSingleValuedCollectionsForSkalarPropertiesMode.
// GH-748
@Test
public void shouldBeLenientWithSingleValuedCollectionsForSkalarPropertiesMode() {
SingleUseEntityMapper entityMapper = new SingleUseEntityMapper(sessionFactory.metaData(), new ReflectionEntityInstantiator(sessionFactory.metaData()));
Iterable<Map<String, Object>> results = sessionFactory.openSession().query("WITH 'a name' AS something OPTIONAL MATCH (t:ThingEntity {name: 'Thing 7'}) RETURN something, COLLECT(t) as entity", EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
ThingResult2 thingResult = entityMapper.map(ThingResult2.class, results.iterator().next());
assertThat(thingResult.getSomething()).isEqualTo("a name");
assertThat(thingResult.getEntity()).isNotNull().extracting(ThingEntity::getName).isEqualTo("Thing 7");
}
Aggregations