Skip to content

Commit

Permalink
Fix count and save tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roimenashe committed Oct 26, 2023
1 parent df16458 commit 713ab75
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void beforeAll() {
public void setUp() {
super.setUp();
additionalAerospikeTestOperations.deleteAllAndVerify(Person.class);
additionalAerospikeTestOperations.deleteAllAndVerify(Person.class, OVERRIDE_SET_NAME);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> void createIndex(Class<T> entityClass, String indexName, String binName,
IndexType indexType) {
createIndex(entityClass, indexName, binName, indexType, null, (CTX[]) null);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 713ab75

Please sign in to comment.