@Test public void should_get_ascending_offer_log_compaction_in_range() throws Exception { CompactedOfferLog compactedOfferLog1 = new CompactedOfferLog( 40, 40, LocalDateUtil.now(), "containerName", Collections.singletonList(new OfferLog()) ); CompactedOfferLog compactedOfferLog2 = new CompactedOfferLog( 41, 42, LocalDateUtil.now(), "containerName", Arrays.asList(new OfferLog(), new OfferLog()) ); CompactedOfferLog compactedOfferLog3 = new CompactedOfferLog( 43, 45, LocalDateUtil.now(), "containerName", Arrays.asList(new OfferLog(), new OfferLog(), new OfferLog()) ); CompactedOfferLog compactedOfferLog4 = new CompactedOfferLog( 1, 5, LocalDateUtil.now(), "OTHER_containerName", Collections.singletonList(new OfferLog()) ); save(compactedOfferLog1); save(compactedOfferLog2); save(compactedOfferLog3); save(compactedOfferLog4); Iterable<CompactedOfferLog> compactionLogs = service.getAscendingOfferLogCompactionBy("containerName", 42L); assertThat(compactionLogs).hasSize(1); assertThat(compactionLogs).extracting(CompactedOfferLog::getSequenceStart).containsExactly(43L); assertThat(compactionLogs).extracting(CompactedOfferLog::getSequenceEnd).containsExactly(45L); assertThat(compactionLogs).extracting(o -> o.getLogs().size()).containsExactly(3); }
public CloseableIterable<CompactedOfferLog> getAscendingOfferLogCompactionBy(String containerName, Long offset) { Bson searchFilterCompaction = offset != null ? and(eq(CONTAINER, containerName), gte(SEQUENCE_START, offset)) : eq(CONTAINER, containerName); Bson sequenceSort = Sorts.orderBy(Sorts.ascending(SEQUENCE_START)); return toCloseableIterable( offerLogCompactionCollection.find(searchFilterCompaction) .sort(sequenceSort) .map(this::transformDocumentToOfferLogCompaction) ); }
OfferLogCompactionDatabaseService { public CloseableIterable<CompactedOfferLog> getAscendingOfferLogCompactionBy(String containerName, Long offset) { Bson searchFilterCompaction = offset != null ? and(eq(CONTAINER, containerName), gte(SEQUENCE_START, offset)) : eq(CONTAINER, containerName); Bson sequenceSort = Sorts.orderBy(Sorts.ascending(SEQUENCE_START)); return toCloseableIterable( offerLogCompactionCollection.find(searchFilterCompaction) .sort(sequenceSort) .map(this::transformDocumentToOfferLogCompaction) ); } }
OfferLogCompactionDatabaseService { public CloseableIterable<CompactedOfferLog> getAscendingOfferLogCompactionBy(String containerName, Long offset) { Bson searchFilterCompaction = offset != null ? and(eq(CONTAINER, containerName), gte(SEQUENCE_START, offset)) : eq(CONTAINER, containerName); Bson sequenceSort = Sorts.orderBy(Sorts.ascending(SEQUENCE_START)); return toCloseableIterable( offerLogCompactionCollection.find(searchFilterCompaction) .sort(sequenceSort) .map(this::transformDocumentToOfferLogCompaction) ); } OfferLogCompactionDatabaseService(MongoCollection<Document> offerLogCompactionCollection); }
OfferLogCompactionDatabaseService { public CloseableIterable<CompactedOfferLog> getAscendingOfferLogCompactionBy(String containerName, Long offset) { Bson searchFilterCompaction = offset != null ? and(eq(CONTAINER, containerName), gte(SEQUENCE_START, offset)) : eq(CONTAINER, containerName); Bson sequenceSort = Sorts.orderBy(Sorts.ascending(SEQUENCE_START)); return toCloseableIterable( offerLogCompactionCollection.find(searchFilterCompaction) .sort(sequenceSort) .map(this::transformDocumentToOfferLogCompaction) ); } OfferLogCompactionDatabaseService(MongoCollection<Document> offerLogCompactionCollection); CloseableIterable<CompactedOfferLog> getDescendingOfferLogCompactionBy(String containerName, Long offset); CloseableIterable<CompactedOfferLog> getAscendingOfferLogCompactionBy(String containerName, Long offset); }
OfferLogCompactionDatabaseService { public CloseableIterable<CompactedOfferLog> getAscendingOfferLogCompactionBy(String containerName, Long offset) { Bson searchFilterCompaction = offset != null ? and(eq(CONTAINER, containerName), gte(SEQUENCE_START, offset)) : eq(CONTAINER, containerName); Bson sequenceSort = Sorts.orderBy(Sorts.ascending(SEQUENCE_START)); return toCloseableIterable( offerLogCompactionCollection.find(searchFilterCompaction) .sort(sequenceSort) .map(this::transformDocumentToOfferLogCompaction) ); } OfferLogCompactionDatabaseService(MongoCollection<Document> offerLogCompactionCollection); CloseableIterable<CompactedOfferLog> getDescendingOfferLogCompactionBy(String containerName, Long offset); CloseableIterable<CompactedOfferLog> getAscendingOfferLogCompactionBy(String containerName, Long offset);  }