@Test
public void batchesWithOlderItemsGoFirst() {

    final long groupInBucketsOfMs = 1;
    final Instant now = Instant.ofEpochMilli(testScheduler.now());
    final Stream<Batch<BatchableOperationMock, String>> batches = Stream.of(
            Batch.of("first",
                    new BatchableOperationMock(LOW, now, "first", "sub1", "foo"),
                    new BatchableOperationMock(LOW, now.minus(ofSeconds(1)), "first", "sub2", "foo")
            ),
            Batch.of("second",
                    new BatchableOperationMock(HIGH, now.minus(ofSeconds(2)), "second", "sub1", "foo"),
                    new BatchableOperationMock(LOW, now, "second", "sub2", "foo")
            ),
            Batch.of("third",
                    new BatchableOperationMock(LOW, now.minus(ofMillis(2_001)), "third", "sub1", "foo"),
                    new BatchableOperationMock(LOW, now, "third", "sub2", "foo")
            ),
            Batch.of("fourth",
                    new BatchableOperationMock(LOW, now.minus(ofMinutes(1)), "fourth", "sub1", "foo"),
                    new BatchableOperationMock(HIGH, now, "third", "sub2", "foo")
            ),
            Batch.of("fifth",
                    new BatchableOperationMock(LOW, now.minus(ofMillis(1)), "fifth", "sub1", "foo"),
                    new BatchableOperationMock(LOW, now, "third", "sub2", "foo")
            )
    );
    EmissionStrategy strategy = new LargestPerTimeBucket(0, groupInBucketsOfMs, testScheduler);
    Queue<Batch<BatchableOperationMock, String>> toEmit = strategy.compute(batches);
    Assertions.assertThat(toEmit).hasSize(5);
    assertThat(toEmit.poll().getIndex()).isEqualTo("fourth");
    assertThat(toEmit.poll().getIndex()).isEqualTo("third");
    assertThat(toEmit.poll().getIndex()).isEqualTo("second");
    assertThat(toEmit.poll().getIndex()).isEqualTo("first");
    assertThat(toEmit.poll().getIndex()).isEqualTo("fifth");
}