Search in sources :

Example 1 with ThingResult2

use of org.neo4j.ogm.domain.gh551.ThingResult2 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();
}
Also used : ThingResult2(org.neo4j.ogm.domain.gh551.ThingResult2) HashMap(java.util.HashMap) Map(java.util.Map) ReflectionEntityInstantiator(org.neo4j.ogm.metadata.reflect.ReflectionEntityInstantiator) Test(org.junit.Test)

Example 2 with ThingResult2

use of org.neo4j.ogm.domain.gh551.ThingResult2 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");
}
Also used : ThingResult2(org.neo4j.ogm.domain.gh551.ThingResult2) HashMap(java.util.HashMap) Map(java.util.Map) ReflectionEntityInstantiator(org.neo4j.ogm.metadata.reflect.ReflectionEntityInstantiator) Test(org.junit.Test)

Example 3 with ThingResult2

use of org.neo4j.ogm.domain.gh551.ThingResult2 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");
}
Also used : ThingResult2(org.neo4j.ogm.domain.gh551.ThingResult2) HashMap(java.util.HashMap) Map(java.util.Map) ReflectionEntityInstantiator(org.neo4j.ogm.metadata.reflect.ReflectionEntityInstantiator) Test(org.junit.Test)

Aggregations

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