diff --git a/src/test/java/org/springframework/data/aerospike/BlockingAerospikeTestOperations.java b/src/test/java/org/springframework/data/aerospike/BlockingAerospikeTestOperations.java index 05cbe5a84..345e34262 100644 --- a/src/test/java/org/springframework/data/aerospike/BlockingAerospikeTestOperations.java +++ b/src/test/java/org/springframework/data/aerospike/BlockingAerospikeTestOperations.java @@ -36,6 +36,16 @@ protected void truncateSetOfEntityClass(Class clazz) { template.deleteAll(clazz); } + @Override + protected boolean isSetEmpty(Class clazz, String setName) { + return template.findAll(clazz, setName).findAny().isEmpty(); + } + + @Override + protected void truncateSet(String setName) { + template.deleteAll(setName); + } + @Override protected String getNamespace() { return template.getNamespace(); diff --git a/src/test/java/org/springframework/data/aerospike/ReactiveBlockingAerospikeTestOperations.java b/src/test/java/org/springframework/data/aerospike/ReactiveBlockingAerospikeTestOperations.java index 5c7ea2c0f..87905a093 100644 --- a/src/test/java/org/springframework/data/aerospike/ReactiveBlockingAerospikeTestOperations.java +++ b/src/test/java/org/springframework/data/aerospike/ReactiveBlockingAerospikeTestOperations.java @@ -39,6 +39,16 @@ protected void truncateSetOfEntityClass(Class clazz) { template.deleteAll(clazz).block(); } + @Override + protected boolean isSetEmpty(Class clazz, String setName) { + return Boolean.FALSE.equals(template.findAll(clazz, setName).hasElements().block()); + } + + @Override + protected void truncateSet(String setName) { + template.deleteAll(setName).block(); + } + @Override protected String getNamespace() { return template.getNamespace(); diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateCountTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateCountTests.java index dbaf51f42..616c8c314 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateCountTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateCountTests.java @@ -47,6 +47,7 @@ public void beforeAll() { public void setUp() { super.setUp(); additionalAerospikeTestOperations.deleteAllAndVerify(Person.class); + additionalAerospikeTestOperations.deleteAllAndVerify(Person.class, OVERRIDE_SET_NAME); } @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateSaveTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateSaveTests.java index 50a75652f..359f5a923 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateSaveTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateSaveTests.java @@ -48,12 +48,12 @@ public class AerospikeTemplateSaveTests extends BaseBlockingIntegrationTests { @AfterAll public void afterAll() { - template.delete(VersionedClass.class); - template.delete(SampleClasses.DocumentWithArray.class); - template.delete(SampleClasses.DocumentWithBigIntegerAndNestedArray.class); - template.delete(Person.class); - template.delete(CustomCollectionClass.class); - template.delete(DocumentWithTouchOnRead.class); + template.deleteAll(VersionedClass.class); + template.deleteAll(SampleClasses.DocumentWithArray.class); + template.deleteAll(SampleClasses.DocumentWithBigIntegerAndNestedArray.class); + template.deleteAll(Person.class); + template.deleteAll(CustomCollectionClass.class); + template.deleteAll(DocumentWithTouchOnRead.class); } // test for RecordExistsAction.REPLACE_ONLY policy diff --git a/src/test/java/org/springframework/data/aerospike/utility/AdditionalAerospikeTestOperations.java b/src/test/java/org/springframework/data/aerospike/utility/AdditionalAerospikeTestOperations.java index 61e699e20..53d73fa42 100644 --- a/src/test/java/org/springframework/data/aerospike/utility/AdditionalAerospikeTestOperations.java +++ b/src/test/java/org/springframework/data/aerospike/utility/AdditionalAerospikeTestOperations.java @@ -95,12 +95,23 @@ public void deleteAllAndVerify(Class... entityClasses) { Arrays.asList(entityClasses).forEach(this::awaitUntilSetIsEmpty); } + public void deleteAllAndVerify(Class entityClass, String setName) { + truncateSet(setName); + awaitUntilSetIsEmpty(entityClass, setName); + } + private void awaitUntilSetIsEmpty(Class entityClass) { Awaitility.await() .atMost(Duration.ofSeconds(10)) .until(() -> isEntityClassSetEmpty(entityClass)); } + private void awaitUntilSetIsEmpty(Class entityClass, String setName) { + Awaitility.await() + .atMost(Duration.ofSeconds(10)) + .until(() -> isSetEmpty(entityClass, setName)); + } + public void createIndex(Class entityClass, String indexName, String binName, IndexType indexType) { createIndex(entityClass, indexName, binName, indexType, null, (CTX[]) null); @@ -227,6 +238,10 @@ public void addNewFieldToSavedDataInAerospike(Key key) { protected abstract void truncateSetOfEntityClass(Class clazz); + protected abstract boolean isSetEmpty(Class clazz, String setName); + + protected abstract void truncateSet(String setName); + protected abstract String getNamespace(); protected abstract String getSetName(Class clazz);