@Test @DisplayName("read all entities and sort") void readAllAndSort() { int limit = MENU_COUNT - 4; Query query = queries.select(Menu.class) .orderBy(UUID_COLUMN, DESCENDING) .limit(limit) .build(); ImmutableCollection<EntityStateWithVersion> records = processor.process(query); IterableSubject assertRecords = assertThat(records); assertRecords.hasSize(limit); Comparator<EntityStateWithVersion> uuidOrder = comparing( (EntityStateWithVersion record) -> state(record).getId().getUuid() ); assertRecords.isInOrder(uuidOrder.reversed()); }
@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);  }