Improve test and add timeout
@@ -16,6 +16,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
@@ -894,19 +895,15 @@ public class MultiGroupTest {
.subscribe()
.withSubscriber(AssertSubscriber.create(10));
- await().until(() -> subscriber.getItems().size() >= 9);
+ await().timeout(Duration.ofSeconds(2)).until(() -> subscriber.getItems().size() >= 9);
subscriber.cancel();
- List<List<Long>> items = subscriber.getItems();
+ List<List<Long>> batches = subscriber.getItems();
+ assertThat(batches.size()).isGreaterThanOrEqualTo(9);
- assertThat(items.get(0).size()).isEqualTo(3);
- assertThat(items.get(1).size()).isEqualTo(3);
- assertThat(items.get(2).size()).isEqualTo(3);
- assertThat(items.get(3).size()).isEqualTo(1);
-
- assertThat(items.get(4).size()).isEqualTo(3);
- assertThat(items.get(5).size()).isEqualTo(3);
- assertThat(items.get(6).size()).isEqualTo(3);
- assertThat(items.get(7).size()).isEqualTo(1);
+ for (List<Long> batch : batches) {
+ assertThat(batch.size()).isGreaterThan(0);
+ assertThat(batch.size()).isLessThanOrEqualTo(3);
+ }
}
}
