Skip to content

Commit 8b77ec2

Browse files
committed
Wait until index is built
1 parent 29d11d9 commit 8b77ec2

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

integration-tests/src/test/java/com/datastax/oss/driver/mapper/SelectCustomWhereClauseIT.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.datastax.oss.driver.mapper;
1717

1818
import static com.datastax.oss.driver.assertions.Assertions.assertThat;
19+
import static org.awaitility.Awaitility.await;
1920
import static org.junit.Assume.assumeFalse;
2021

2122
import com.datastax.oss.driver.api.core.CqlIdentifier;
@@ -36,8 +37,8 @@
3637
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
3738
import com.datastax.oss.driver.categories.ParallelizableTests;
3839
import com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures;
40+
import java.time.Duration;
3941
import java.util.concurrent.CompletionStage;
40-
import org.junit.Before;
4142
import org.junit.BeforeClass;
4243
import org.junit.ClassRule;
4344
import org.junit.Test;
@@ -73,29 +74,35 @@ public static void setup() {
7374
InventoryMapper inventoryMapper =
7475
new SelectCustomWhereClauseIT_InventoryMapperBuilder(session).build();
7576
dao = inventoryMapper.productDao(SESSION_RULE.keyspace());
76-
}
77-
78-
@Before
79-
public void insertData() {
8077
dao.save(FLAMETHROWER);
8178
dao.save(MP3_DOWNLOAD);
8279
}
8380

8481
@Test
8582
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+
});
8991
}
9092

9193
@Test
9294
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+
});
99106
}
100107

101108
@Mapper

0 commit comments

Comments
 (0)