diff --git a/src/main/java/org/springframework/data/aerospike/query/model/IndexKey.java b/src/main/java/org/springframework/data/aerospike/query/model/IndexKey.java index 4ab6dee44..dd1f50899 100644 --- a/src/main/java/org/springframework/data/aerospike/query/model/IndexKey.java +++ b/src/main/java/org/springframework/data/aerospike/query/model/IndexKey.java @@ -67,4 +67,14 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(namespace, set, field, type); } + + @Override + public String toString() { + return "IndexKey{" + + "namespace='" + namespace + '\'' + + ", set='" + set + '\'' + + ", field='" + field + '\'' + + ", type=" + type + + '}'; + } } diff --git a/src/test/java/org/springframework/data/aerospike/query/BaseQueryEngineTests.java b/src/test/java/org/springframework/data/aerospike/query/BaseQueryEngineTests.java index 259400011..29b3e8b0e 100644 --- a/src/test/java/org/springframework/data/aerospike/query/BaseQueryEngineTests.java +++ b/src/test/java/org/springframework/data/aerospike/query/BaseQueryEngineTests.java @@ -4,8 +4,15 @@ import com.aerospike.client.query.IndexType; import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.aerospike.AwaitilityUtils; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.IndexUtils; +import org.springframework.data.aerospike.query.model.Index; +import org.springframework.data.aerospike.query.model.IndexKey; + +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; public abstract class BaseQueryEngineTests extends BaseBlockingIntegrationTests { @@ -32,8 +39,13 @@ protected void tryDropIndex(String namespace, String setName, String indexName) } protected void tryCreateIndex(String namespace, String setName, String indexName, String binName, IndexType indexType) { - IndexUtils.createIndex(client, namespace, setName, indexName, binName, indexType); - indexRefresher.refreshIndexes(); + AwaitilityUtils.awaitTenSecondsUntil(() -> { + IndexUtils.createIndex(client, namespace, setName, indexName, binName, indexType); + indexRefresher.refreshIndexes(); + IndexKey indexKey = new IndexKey(namespace, setName, binName, indexType); + Optional index = indexesCache.getIndex(indexKey); + assertThat(index).as("Index for: " + indexKey + " not created").isPresent(); + }); } protected void tryCreateIndex(String namespace, String setName, String indexName, String binName, IndexType indexType,