use of org.neo4j.ogm.domain.gh551.GenericQueryResultWrapper in project neo4j-ogm by neo4j.
the class SingleUseEntityMapperTest method genericTargetTypesWithCollectionsOfUnkownThings.
@Test
public void genericTargetTypesWithCollectionsOfUnkownThings() {
SingleUseEntityMapper entityMapper = new SingleUseEntityMapper(sessionFactory.metaData(), new ReflectionEntityInstantiator(sessionFactory.metaData()));
Iterable<Map<String, Object>> results;
GenericQueryResultWrapper<List<Long>> genericQueryResultWrapper;
results = sessionFactory.openSession().query("unwind range (0,1) as x return collect(x) as result", EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
genericQueryResultWrapper = entityMapper.map(GenericQueryResultWrapper.class, results.iterator().next());
assertThat(genericQueryResultWrapper.getResult()).containsExactly(0L, 1L);
results = sessionFactory.openSession().query("unwind range (0,0) as x return collect(x) as result", EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
genericQueryResultWrapper = entityMapper.map(GenericQueryResultWrapper.class, results.iterator().next());
assertThat(genericQueryResultWrapper.getResult()).containsExactly(0L);
results = sessionFactory.openSession().query("unwind range (0,-1) as x return collect(x) as result", EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
genericQueryResultWrapper = entityMapper.map(GenericQueryResultWrapper.class, results.iterator().next());
assertThat(genericQueryResultWrapper.getResult()).isEmpty();
}
use of org.neo4j.ogm.domain.gh551.GenericQueryResultWrapper in project neo4j-ogm by neo4j.
the class SingleUseEntityMapperTest method genericTargetTypesWithCollectionsOfKownThings.
@Test
public void genericTargetTypesWithCollectionsOfKownThings() {
SingleUseEntityMapper entityMapper = new SingleUseEntityMapper(sessionFactory.metaData(), new ReflectionEntityInstantiator(sessionFactory.metaData()));
Iterable<Map<String, Object>> results;
GenericQueryResultWrapper<List<ThingEntity>> genericQueryResultWrapper;
results = sessionFactory.openSession().query("match (r:ThingEntity) return collect (r) as result", EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
genericQueryResultWrapper = entityMapper.map(GenericQueryResultWrapper.class, results.iterator().next());
assertThat(genericQueryResultWrapper.getResult()).hasSize(10).extracting(ThingEntity::getName).allSatisfy(s -> s.startsWith("Thing"));
results = sessionFactory.openSession().query("match (r:ThingEntity {name: 'Thing 1'}) return collect (r) as result", EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
genericQueryResultWrapper = entityMapper.map(GenericQueryResultWrapper.class, results.iterator().next());
assertThat(genericQueryResultWrapper.getResult()).hasSize(1).extracting(ThingEntity::getName).allSatisfy(s -> s.startsWith("Thing"));
results = sessionFactory.openSession().query("unwind range (0,-1) as x return collect(x) as result", EMPTY_MAP).queryResults();
assertThat(results).hasSize(1);
genericQueryResultWrapper = entityMapper.map(GenericQueryResultWrapper.class, results.iterator().next());
assertThat(genericQueryResultWrapper.getResult()).isEmpty();
}
Aggregations