@Test
public void biggerBatchesInTheSameBucketGoFirst() {

    final long groupInBucketsOfMs = 60_000 /* 1min */;
    final Instant now = Instant.ofEpochMilli(testScheduler.now());
    final Instant past = now.minus(ofMinutes(10));
    final Stream<Batch<BatchableOperationMock, String>> batches = Stream.of(
            // 1-3 are in the same minute
            Batch.of("smaller",
                    new BatchableOperationMock(LOW, now, "smaller", "sub1", "foo"),
                    new BatchableOperationMock(LOW, past.minus(ofSeconds(10)), "smaller", "sub2", "foo")
            ),
            Batch.of("bigger",
                    new BatchableOperationMock(LOW, past, "bigger", "sub1", "foo"),
                    new BatchableOperationMock(HIGH, now.minus(ofMinutes(5)), "bigger", "sub2", "foo"),
                    new BatchableOperationMock(LOW, now, "bigger", "sub3", "foo")
            ),
            Batch.of("slightlyOlder",
                    new BatchableOperationMock(LOW, now, "slightlyOlder", "sub1", "foo"),
                    new BatchableOperationMock(LOW, past.minus(ofSeconds(11)), "slightlyOlder", "sub2", "foo")
            ),
            Batch.of("older",
                    new BatchableOperationMock(LOW, past.minus(ofMinutes(5)), "older", "sub1", "foo")
            )
    );
    EmissionStrategy strategy = new LargestPerTimeBucket(0, groupInBucketsOfMs, testScheduler);
    Queue<Batch<BatchableOperationMock, String>> toEmit = strategy.compute(batches);
    Assertions.assertThat(toEmit).hasSize(4);
    assertThat(toEmit.poll().getIndex()).isEqualTo("older");
    // all following are in the same time bucket. Bigger go first, if same size, order by timestamp
    assertThat(toEmit.poll().getIndex()).isEqualTo("bigger");
    assertThat(toEmit.poll().getIndex()).isEqualTo("slightlyOlder");
    assertThat(toEmit.poll().getIndex()).isEqualTo("smaller");
}