Refactor PriorityBlockingQueue examples
This commit is contained in:
parent
f69deeca2d
commit
02245b75a8
@ -1,12 +1,10 @@
|
|||||||
package com.baeldung.concurrent.priorityblockingqueue;
|
package com.baeldung.concurrent.priorityblockingqueue;
|
||||||
|
|
||||||
import org.assertj.core.api.Assertions;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.util.Lists.newArrayList;
|
import static org.assertj.core.util.Lists.newArrayList;
|
||||||
@ -24,11 +22,7 @@ public class PriorityBlockingQueueUnitTest {
|
|||||||
queue.add(3);
|
queue.add(3);
|
||||||
queue.add(4);
|
queue.add(4);
|
||||||
|
|
||||||
polledElements.add(queue.poll());
|
queue.drainTo(polledElements);
|
||||||
polledElements.add(queue.poll());
|
|
||||||
polledElements.add(queue.poll());
|
|
||||||
polledElements.add(queue.poll());
|
|
||||||
polledElements.add(queue.poll());
|
|
||||||
|
|
||||||
assertThat(polledElements).containsExactly(1, 2, 3, 4, 5);
|
assertThat(polledElements).containsExactly(1, 2, 3, 4, 5);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user