@Test @DisplayName("read one by ID") void readById() { DishAdded event = addDish(); MenuId id = event.getId(); Query query = queries.byIds(Menu.class, ImmutableSet.of(id)); ImmutableCollection<EntityStateWithVersion> records = processor.process(query); assertThat(records).hasSize(1); EntityStateWithVersion record = records.asList().get(0); Menu menu = state(record); assertThat(menu.getId()).isEqualTo(id); assertThat(menu.getDishList()).containsExactly(event.getDish()); }
@Override public ImmutableCollection<EntityStateWithVersion> process(Query query) { Iterator<EntityRecord> entities = query.all() ? loadAll(query.responseFormat()) : loadByQuery(query); ImmutableList<EntityStateWithVersion> result = stream(entities) .map(EntityQueryProcessor::toEntityState) .collect(toImmutableList()); return result; }
EntityQueryProcessor implements QueryProcessor { @Override public ImmutableCollection<EntityStateWithVersion> process(Query query) { Iterator<EntityRecord> entities = query.all() ? loadAll(query.responseFormat()) : loadByQuery(query); ImmutableList<EntityStateWithVersion> result = stream(entities) .map(EntityQueryProcessor::toEntityState) .collect(toImmutableList()); return result; } }
EntityQueryProcessor implements QueryProcessor { @Override public ImmutableCollection<EntityStateWithVersion> process(Query query) { Iterator<EntityRecord> entities = query.all() ? loadAll(query.responseFormat()) : loadByQuery(query); ImmutableList<EntityStateWithVersion> result = stream(entities) .map(EntityQueryProcessor::toEntityState) .collect(toImmutableList()); return result; } EntityQueryProcessor(
            RecordBasedRepository<?, ? extends Entity, ? extends EntityState> repository); }
EntityQueryProcessor implements QueryProcessor { @Override public ImmutableCollection<EntityStateWithVersion> process(Query query) { Iterator<EntityRecord> entities = query.all() ? loadAll(query.responseFormat()) : loadByQuery(query); ImmutableList<EntityStateWithVersion> result = stream(entities) .map(EntityQueryProcessor::toEntityState) .collect(toImmutableList()); return result; } EntityQueryProcessor(
            RecordBasedRepository<?, ? extends Entity, ? extends EntityState> repository); @Override ImmutableCollection<EntityStateWithVersion> process(Query query); }
EntityQueryProcessor implements QueryProcessor { @Override public ImmutableCollection<EntityStateWithVersion> process(Query query) { Iterator<EntityRecord> entities = query.all() ? loadAll(query.responseFormat()) : loadByQuery(query); ImmutableList<EntityStateWithVersion> result = stream(entities) .map(EntityQueryProcessor::toEntityState) .collect(toImmutableList()); return result; } EntityQueryProcessor(
            RecordBasedRepository<?, ? extends Entity, ? extends EntityState> repository); @Override ImmutableCollection<EntityStateWithVersion> process(Query query);  }