|
16 | 16 | package com.datastax.oss.driver.mapper;
|
17 | 17 |
|
18 | 18 | import static com.datastax.oss.driver.assertions.Assertions.assertThat;
|
| 19 | +import static org.awaitility.Awaitility.await; |
19 | 20 | import static org.junit.Assume.assumeFalse;
|
20 | 21 |
|
21 | 22 | import com.datastax.oss.driver.api.core.CqlIdentifier;
|
|
36 | 37 | import com.datastax.oss.driver.api.testinfra.session.SessionRule;
|
37 | 38 | import com.datastax.oss.driver.categories.ParallelizableTests;
|
38 | 39 | import com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures;
|
| 40 | +import java.time.Duration; |
39 | 41 | import java.util.concurrent.CompletionStage;
|
40 |
| -import org.junit.Before; |
41 | 42 | import org.junit.BeforeClass;
|
42 | 43 | import org.junit.ClassRule;
|
43 | 44 | import org.junit.Test;
|
@@ -73,29 +74,35 @@ public static void setup() {
|
73 | 74 | InventoryMapper inventoryMapper =
|
74 | 75 | new SelectCustomWhereClauseIT_InventoryMapperBuilder(session).build();
|
75 | 76 | dao = inventoryMapper.productDao(SESSION_RULE.keyspace());
|
76 |
| - } |
77 |
| - |
78 |
| - @Before |
79 |
| - public void insertData() { |
80 | 77 | dao.save(FLAMETHROWER);
|
81 | 78 | dao.save(MP3_DOWNLOAD);
|
82 | 79 | }
|
83 | 80 |
|
84 | 81 | @Test
|
85 | 82 | public void should_select_with_custom_clause() {
|
86 |
| - PagingIterable<Product> products = dao.findByDescription("%mp3%"); |
87 |
| - assertThat(products.one()).isEqualTo(MP3_DOWNLOAD); |
88 |
| - assertThat(products.iterator()).isExhausted(); |
| 83 | + await() |
| 84 | + .atMost(Duration.ofMinutes(1)) |
| 85 | + .untilAsserted( |
| 86 | + () -> { |
| 87 | + PagingIterable<Product> products = dao.findByDescription("%mp3%"); |
| 88 | + assertThat(products.one()).isEqualTo(MP3_DOWNLOAD); |
| 89 | + assertThat(products.iterator()).isExhausted(); |
| 90 | + }); |
89 | 91 | }
|
90 | 92 |
|
91 | 93 | @Test
|
92 | 94 | public void should_select_with_custom_clause_asynchronously() {
|
93 |
| - MappedAsyncPagingIterable<Product> iterable = |
94 |
| - CompletableFutures.getUninterruptibly( |
95 |
| - dao.findByDescriptionAsync("%mp3%").toCompletableFuture()); |
96 |
| - assertThat(iterable.one()).isEqualTo(MP3_DOWNLOAD); |
97 |
| - assertThat(iterable.currentPage().iterator()).isExhausted(); |
98 |
| - assertThat(iterable.hasMorePages()).isFalse(); |
| 95 | + await() |
| 96 | + .atMost(Duration.ofMinutes(1)) |
| 97 | + .untilAsserted( |
| 98 | + () -> { |
| 99 | + MappedAsyncPagingIterable<Product> iterable = |
| 100 | + CompletableFutures.getUninterruptibly( |
| 101 | + dao.findByDescriptionAsync("%mp3%").toCompletableFuture()); |
| 102 | + assertThat(iterable.one()).isEqualTo(MP3_DOWNLOAD); |
| 103 | + assertThat(iterable.currentPage().iterator()).isExhausted(); |
| 104 | + assertThat(iterable.hasMorePages()).isFalse(); |
| 105 | + }); |
99 | 106 | }
|
100 | 107 |
|
101 | 108 | @Mapper
|
|
0 commit comments