@Test void findAllStream() { when(delegateRepository.getEntityType()).thenReturn(entityType); Object id0 = "id0"; Object id1 = "id1"; Entity entity0 = mock(Entity.class); Entity entity1 = mock(Entity.class); Entity entity0WithRefs = mock(Entity.class); Entity entity1WithRefs = mock(Entity.class); Stream<Object> entityIds = Stream.of(id0, id1); Stream<Entity> entities = Stream.of(entity0, entity1); when(delegateRepository.findAll(entityIds)).thenReturn(entities); when(entityManager.resolveReferences(entityType, entities, null)) .thenReturn(Stream.of(entity0WithRefs, entity1WithRefs)); Stream<Entity> expectedEntities = entityReferenceResolverDecorator.findAll(entityIds); assertEquals(asList(entity0WithRefs, entity1WithRefs), expectedEntities.collect(toList())); }
@Override public Stream<Entity> findAll(Query<Entity> q) { Stream<Entity> entities = delegate().findAll(q); return resolveEntityReferences(entities, q.getFetch()); }
EntityReferenceResolverDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Stream<Entity> findAll(Query<Entity> q) { Stream<Entity> entities = delegate().findAll(q); return resolveEntityReferences(entities, q.getFetch()); } }
EntityReferenceResolverDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Stream<Entity> findAll(Query<Entity> q) { Stream<Entity> entities = delegate().findAll(q); return resolveEntityReferences(entities, q.getFetch()); } EntityReferenceResolverDecorator(
      Repository<Entity> delegateRepository, EntityManager entityManager); }
EntityReferenceResolverDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Stream<Entity> findAll(Query<Entity> q) { Stream<Entity> entities = delegate().findAll(q); return resolveEntityReferences(entities, q.getFetch()); } EntityReferenceResolverDecorator(
      Repository<Entity> delegateRepository, EntityManager entityManager); @Override Stream<Entity> findAll(Query<Entity> q); @Override Entity findOne(Query<Entity> q); @Override Iterator<Entity> iterator(); @Override void forEachBatched(Fetch fetch, Consumer<List<Entity>> consumer, int batchSize); @Override Entity findOneById(Object id); @Override Entity findOneById(Object id, Fetch fetch); @Override Stream<Entity> findAll(Stream<Object> ids); @Override Stream<Entity> findAll(Stream<Object> ids, Fetch fetch); }
EntityReferenceResolverDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Stream<Entity> findAll(Query<Entity> q) { Stream<Entity> entities = delegate().findAll(q); return resolveEntityReferences(entities, q.getFetch()); } EntityReferenceResolverDecorator(
      Repository<Entity> delegateRepository, EntityManager entityManager); @Override Stream<Entity> findAll(Query<Entity> q); @Override Entity findOne(Query<Entity> q); @Override Iterator<Entity> iterator(); @Override void forEachBatched(Fetch fetch, Consumer<List<Entity>> consumer, int batchSize); @Override Entity findOneById(Object id); @Override Entity findOneById(Object id, Fetch fetch); @Override Stream<Entity> findAll(Stream<Object> ids); @Override Stream<Entity> findAll(Stream<Object> ids, Fetch fetch);  }