From a5349444e300010dae358551cd21778a1d0f8299 Mon Sep 17 00:00:00 2001 From: agrgr Date: Tue, 23 Jan 2024 12:21:24 +0200 Subject: [PATCH 1/2] align sendKey fields in ClientPolicy configuration, cleanup --- src/main/asciidoc/index.adoc | 2 +- .../reference/aerospike-object-mapping.adoc | 29 +++------ .../reference/installation-and-usage.adoc | 2 +- .../AerospikeDataConfigurationSupport.java | 10 +++- .../aerospike/core/BaseAerospikeTemplate.java | 2 +- .../query/cache/InternalIndexOperations.java | 2 +- .../server/version/ServerVersionSupport.java | 6 +- ...activeBlockingAerospikeTestOperations.java | 4 +- .../core/AerospikeTemplateDeleteTests.java | 18 +++--- ...ikeTemplateFindByQueryProjectionTests.java | 4 +- .../AerospikeTemplateFindByQueryTests.java | 4 +- .../core/AerospikeTemplateInsertTests.java | 8 +-- .../core/AerospikeTemplateSaveTests.java | 34 ++++++++--- .../core/AerospikeTemplateUpdateTests.java | 60 +++++++++++++++---- ...veAerospikeTemplateDeleteRelatedTests.java | 18 +++--- .../ReactiveAerospikeTemplateInsertTests.java | 8 +-- ...tiveAerospikeTemplateSaveRelatedTests.java | 8 +-- .../ReactiveAerospikeTemplateUpdateTests.java | 6 +- .../PersonRepositoryQueryTests.java | 44 +++++++------- .../AdditionalAerospikeTestOperations.java | 4 +- 20 files changed, 162 insertions(+), 111 deletions(-) diff --git a/src/main/asciidoc/index.adoc b/src/main/asciidoc/index.adoc index 223357471..1a31d4b5f 100644 --- a/src/main/asciidoc/index.adoc +++ b/src/main/asciidoc/index.adoc @@ -7,7 +7,7 @@ :toclevels: 1 :spring-data-commons-docs-online: https://docs.spring.io/spring-data/commons/docs/current/reference/html -(C) 2018-2023 The original authors. +(C) 2018-2024 The original authors. NOTE: Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically. diff --git a/src/main/asciidoc/reference/aerospike-object-mapping.adoc b/src/main/asciidoc/reference/aerospike-object-mapping.adoc index f0cf95473..6405b67f1 100644 --- a/src/main/asciidoc/reference/aerospike-object-mapping.adoc +++ b/src/main/asciidoc/reference/aerospike-object-mapping.adoc @@ -13,43 +13,32 @@ For more details refer to SpringData documentation: `AerospikeMappingConverter` has a few conventions for mapping objects to documents when no additional mapping metadata is provided. The conventions are: - [[mapping-conventions-id-field]] -=== How the '_id' Field Is Handled in the Mapping Layer - -AerospikeDB requires that you have an '_id' field for all objects. If you don't provide one the driver will assign a ObjectId with a generated value. The "_id" field can be of any type, other than arrays, so long as it is unique. The driver naturally supports all primitive types and Dates. When using the `AerospikeMappingConverter` there are certain rules that govern how properties from the Java class are mapped to this '_id' field. +=== How the 'id' Field Is Handled in the Mapping Layer -The following outlines what field will be mapped to the '_id' document field: +Aerospike DB requires that you have an `id` field for all objects. The `id` field can be of any primitive type as well as `String` or `byte[]`. -* A field annotated with `@Id` (`org.springframework.data.annotation.Id`) will be mapped to the '_id' field. -* A field without an annotation but named 'id' will be mapped to the '_id' field. -* The default field name for identifiers is '_id' and can be customized via the `@Field` annotation. +The following table outlines the requirements for an `id` field: [cols="1,2", options="header"] .Examples for the translation of '_id'-field definitions |=== | Field definition -| Resulting Id-Fieldname in AerospikeDB +| Description | `String` id -| `_id` +| A field named 'id' without an annotation | `@Field` `String` id -| `_id` - -| `@Field('x')` `String` id -| `x` +| A field annotated with `@Id` (`org.springframework.data.annotation.Id`) -| `@Id` `String` x -| `_id` +| `@Id` `String` customNamedIdField -| `@Field('x')` `@Id` `String` x -| `_id` |=== -The following outlines what type of conversion, if any, will be done on the property mapped to the _id document field. +The following outlines what type of conversion, if any, will be done on the property mapped to the `id` document field: -* By default, the type of the field annotated with `@id` is turned into a `String` to be stored in Aerospike database. If the original type cannot be persisted (see xref:#configuration.keep-original-key-types[keepOriginalKeyTypes] for details), it must be convertible to `String` and will be stored in the database as such, then converted back to the original type when the object is read. This is transparent to the application but needs to be considered if using external tools like `AQL` to view the data. +* By default, the type of the `id` field is turned into a `String` to be stored in Aerospike database. If xref:#configuration.keep-original-key-types[keepOriginalKeyTypes] parameter is set to `true`, IDs of type `long` (`int` will also be stored as `long`) and `byte[]` will be persisted as is. If the original type cannot be persisted, it must be convertible to `String` and will be stored in the database as such, then converted back to the original type when the object is read. This is transparent to the application but needs to be considered if using external tools like `AQL` to view the data. * If no field named "id" is present in the Java class then an implicit '_id' file will be generated by the driver but not mapped to a property or field of the Java class. When querying and updating `AerospikeTemplate` will use the converter to handle conversions of the `Query` and `Update` objects that correspond to the above rules for saving documents so field names and types used in your queries will be able to match what is in your domain classes. diff --git a/src/main/asciidoc/reference/installation-and-usage.adoc b/src/main/asciidoc/reference/installation-and-usage.adoc index c703f0d23..670188e5f 100644 --- a/src/main/asciidoc/reference/installation-and-usage.adoc +++ b/src/main/asciidoc/reference/installation-and-usage.adoc @@ -178,6 +178,6 @@ aql> select * from test.Person where pk = "1" NOTE: The fully qualified path of the class is listed in each record. This is needed to instantiate the class correctly, especially in cases when the compile-time type and runtime type of the object differ. For example, where a field is declared as a super class but the instantiated class is a subclass. -NOTE: By default, the type of the field annotated with `@id` is turned into a `String` to be stored in Aerospike database. If the original type cannot be persisted (see xref:#configuration.keep-original-key-types[keepOriginalKeyTypes] for details), it must be convertible to `String` and will be stored in the database as such, then converted back to the original type when the object is read. This is transparent to the application but needs to be considered if using external tools like `AQL` to view the data. +NOTE: By default, the type of the `id` field is turned into a `String` to be stored in Aerospike database. If xref:#configuration.keep-original-key-types[keepOriginalKeyTypes] parameter is set to `true`, IDs of type `long` (`int` will also be stored as `long`) and `byte[]` will be persisted as is. If the original type cannot be persisted, it must be convertible to `String` and will be stored in the database as such, then converted back to the original type when the object is read. This is transparent to the application but needs to be considered if using external tools like `AQL` to view the data. diff --git a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java index 6a89cded1..346ba3694 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java +++ b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java @@ -214,9 +214,13 @@ protected ClientPolicy getClientPolicy() { ClientPolicy clientPolicy = new ClientPolicy(); clientPolicy.failIfNotConnected = true; clientPolicy.timeout = 10_000; - clientPolicy.readPolicyDefault.sendKey = true; - clientPolicy.writePolicyDefault.sendKey = true; - clientPolicy.batchPolicyDefault.sendKey = true; + boolean sendKey = true; + clientPolicy.readPolicyDefault.sendKey = sendKey; + clientPolicy.writePolicyDefault.sendKey = sendKey; + clientPolicy.batchPolicyDefault.sendKey = sendKey; + clientPolicy.batchWritePolicyDefault.sendKey = sendKey; + clientPolicy.queryPolicyDefault.sendKey = sendKey; + clientPolicy.scanPolicyDefault.sendKey = sendKey; return clientPolicy; } diff --git a/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java b/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java index bc609c440..9a89f8a84 100644 --- a/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java @@ -533,7 +533,7 @@ protected boolean batchRecordFailed(BatchRecord batchRecord) { } protected boolean batchWriteSupported() { - return serverVersionSupport.batchWrite(); + return serverVersionSupport.isBatchWriteSupported(); } protected enum OperationType { diff --git a/src/main/java/org/springframework/data/aerospike/query/cache/InternalIndexOperations.java b/src/main/java/org/springframework/data/aerospike/query/cache/InternalIndexOperations.java index c128bd312..42d0ca7ea 100644 --- a/src/main/java/org/springframework/data/aerospike/query/cache/InternalIndexOperations.java +++ b/src/main/java/org/springframework/data/aerospike/query/cache/InternalIndexOperations.java @@ -79,7 +79,7 @@ public void enrichIndexesWithCardinality(IAerospikeClient client, Map= 0; } - public boolean batchWrite() { + public boolean isBatchWriteSupported() { return ModuleDescriptor.Version.parse(getServerVersion()) .compareTo(SERVER_VERSION_6_0_0_0) >= 0; } - public boolean sIndexCardinality() { + public boolean isSIndexCardinalitySupported() { return ModuleDescriptor.Version.parse(getServerVersion()) .compareTo(SERVER_VERSION_6_1_0_0) >= 0; } diff --git a/src/test/java/org/springframework/data/aerospike/ReactiveBlockingAerospikeTestOperations.java b/src/test/java/org/springframework/data/aerospike/ReactiveBlockingAerospikeTestOperations.java index c623b2851..4bca80c61 100644 --- a/src/test/java/org/springframework/data/aerospike/ReactiveBlockingAerospikeTestOperations.java +++ b/src/test/java/org/springframework/data/aerospike/ReactiveBlockingAerospikeTestOperations.java @@ -84,7 +84,7 @@ public List saveGeneratedPersons(int count) { public void deleteAll(ReactiveAerospikeRepository repository, Collection entities) { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { try { repository.deleteAll(entities).block(); } catch (AerospikeException.BatchRecordArray ignored) { @@ -97,7 +97,7 @@ public void deleteAll(ReactiveAerospikeRepository repository, Collecti public void saveAll(ReactiveAerospikeRepository repository, Collection entities) { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { repository.saveAll(entities).blockLast(); } else { entities.forEach(entity -> repository.save(entity).block()); diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateDeleteTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateDeleteTests.java index d16a2fca7..3a04a0519 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateDeleteTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateDeleteTests.java @@ -166,7 +166,7 @@ public void deleteById_returnsFalseIfValueIsAbsent() { @Test public void deleteByGroupedKeys() { - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { List persons = additionalAerospikeTestOperations.saveGeneratedPersons(5); List personsIds = persons.stream().map(Person::getId).toList(); List customers = additionalAerospikeTestOperations.saveGeneratedCustomers(3); @@ -245,7 +245,7 @@ public void deleteByType_NullTypeThrowsException() { @Test public void deleteByIds_rejectsDuplicateIds() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); DocumentWithExpiration document1 = new DocumentWithExpiration(id1); DocumentWithExpiration document2 = new DocumentWithExpiration(id1); @@ -262,7 +262,7 @@ public void deleteByIds_rejectsDuplicateIds() { @Test public void deleteByIds_ShouldDeleteAllDocuments() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); String id2 = nextId(); template.save(new DocumentWithExpiration(id1)); @@ -287,7 +287,7 @@ public void deleteByIds_ShouldDeleteAllDocuments() { @Test public void deleteByIds_ShouldDeleteAllDocumentsWithSetName() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); String id2 = nextId(); template.save(new DocumentWithExpiration(id1), OVERRIDE_SET_NAME); @@ -303,7 +303,7 @@ public void deleteByIds_ShouldDeleteAllDocumentsWithSetName() { @Test public void deleteAll_rejectsDuplicateIds() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); DocumentWithExpiration document1 = new DocumentWithExpiration(id1); DocumentWithExpiration document2 = new DocumentWithExpiration(id1); @@ -319,7 +319,7 @@ public void deleteAll_rejectsDuplicateIds() { @Test public void deleteAll_ShouldDeleteAllDocuments() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); String id2 = nextId(); DocumentWithExpiration document1 = new DocumentWithExpiration(id1); @@ -345,7 +345,7 @@ public void deleteAll_ShouldDeleteAllDocuments() { @Test public void deleteAll_ShouldDeleteAllDocumentsWithSetName() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); String id2 = nextId(); DocumentWithExpiration document1 = new DocumentWithExpiration(id1); @@ -361,7 +361,7 @@ public void deleteAll_ShouldDeleteAllDocumentsWithSetName() { @Test public void deleteAll_ShouldDeleteAllDocumentsBeforeGivenLastUpdateTime() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); String id2 = nextId(); CollectionOfObjects document1 = new CollectionOfObjects(id1, List.of("test1")); @@ -413,7 +413,7 @@ public void deleteAll_ShouldDeleteAllDocumentsBeforeGivenLastUpdateTime() { @Test public void deleteAll_VersionsMismatch() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = "id1"; VersionedClass document1 = new VersionedClass(id1, "test1"); String id2 = "id2"; diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryProjectionTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryProjectionTests.java index 066349c61..03014018f 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryProjectionTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryProjectionTests.java @@ -53,7 +53,7 @@ public void beforeAllSetUp() { deleteOneByOne(allPersons, OVERRIDE_SET_NAME); // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { template.insertAll(allPersons); template.insertAll(allPersons, OVERRIDE_SET_NAME); } else { @@ -83,7 +83,7 @@ public void setUp() { super.setUp(); template.deleteAll(Person.class); template.deleteAll(OVERRIDE_SET_NAME); - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { template.insertAll(allPersons); template.insertAll(allPersons, OVERRIDE_SET_NAME); } else { diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryTests.java index 9f174c271..9b44cf801 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryTests.java @@ -84,7 +84,7 @@ public void beforeAllSetUp() { deleteOneByOne(allPersons); // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { template.insertAll(allPersons); template.insertAll(allPersons, OVERRIDE_SET_NAME); } else { @@ -295,7 +295,7 @@ public void findAll_findNothing() { assertThat(result).isEmpty(); // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { template.insertAll(allPersons); } else { allPersons.forEach(person -> template.insert(person)); diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateInsertTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateInsertTests.java index 5ca3f4ffc..757286443 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateInsertTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateInsertTests.java @@ -202,7 +202,7 @@ public void insertsOnlyFirstDocumentAndNextAttemptsShouldFailWithDuplicateKeyExc @Test public void insertAll_insertsAllDocuments() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { List persons = IntStream.range(1, 10) .mapToObj(age -> Person.builder().id(nextId()) .firstName("Gregor") @@ -239,7 +239,7 @@ public void insertAllWithSetName_insertsAllDocuments() { .collect(Collectors.toList()); // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { template.insertAll(persons, OVERRIDE_SET_NAME); } else { persons.forEach(person -> template.insert(person, OVERRIDE_SET_NAME)); @@ -254,7 +254,7 @@ public void insertAllWithSetName_insertsAllDocuments() { @Test public void insertAll_rejectsDuplicateIds() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { VersionedClass second = new VersionedClass("as-5440", "foo"); assertThatThrownBy(() -> template.insertAll(List.of(second, second))) .isInstanceOf(OptimisticLockingFailureException.class) @@ -266,7 +266,7 @@ public void insertAll_rejectsDuplicateIds() { @Test public void shouldInsertAllVersionedDocuments() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { VersionedClass first = new VersionedClass(id, "foo"); VersionedClass second = new VersionedClass(nextId(), "foo", 1L); VersionedClass third = new VersionedClass(nextId(), "foo", 2L); 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 20bb26140..957e8a007 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateSaveTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateSaveTests.java @@ -334,7 +334,7 @@ public void shouldSaveAllAndSetVersion() { second.setVersion(second.getVersion()); // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { template.saveAll(List.of(first, second)); } else { List.of(first, second).forEach(document -> template.save(document)); @@ -352,7 +352,7 @@ public void shouldSaveAllAndSetVersionWithSetName() { VersionedClass first = new VersionedClass(id, "foo"); VersionedClass second = new VersionedClass(nextId(), "foo"); // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { template.saveAll(List.of(first, second), OVERRIDE_SET_NAME); } else { List.of(first, second).forEach(person -> template.save(person, OVERRIDE_SET_NAME)); @@ -366,31 +366,51 @@ public void shouldSaveAllAndSetVersionWithSetName() { } @Test - public void shouldSaveAllVersionedDocumentsAndSetVersionAndThrowExceptionIfAlreadyExist() { + public void shouldSaveAllVersionedDocumentsAndSetVersionAndThrowExceptionIfDuplicatesWithinOneBatch() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { - VersionedClass first = new VersionedClass("as-5279", "foo"); - VersionedClass second = new VersionedClass("as-5277", "foo"); + if (serverVersionSupport.isBatchWriteSupported()) { + VersionedClass first = new VersionedClass("newId1", "foo"); + VersionedClass second = new VersionedClass("newId2", "foo"); + // The documents’ versions are equal to zero, meaning the documents have not been saved to the database yet assertThat(first.getVersion() == 0).isTrue(); assertThat(second.getVersion() == 0).isTrue(); + // An attempt to save the same versioned documents in one batch results in getting an exception assertThatThrownBy(() -> template.saveAll(List.of(first, first, second, second))) .isInstanceOf(OptimisticLockingFailureException.class) .hasMessageFindingMatch("Failed to save the record with ID .* due to versions mismatch"); + // The documents' versions get updated after they are read from the corresponding database records assertThat(first.getVersion() == 1).isTrue(); assertThat(second.getVersion() == 1).isTrue(); template.delete(first); // cleanup template.delete(second); // cleanup + + // The same versioned documents can be saved if they are not in the same batch. + // This way, the generation counts of the corresponding database records can be used + // to update the documents’ versions each time. + VersionedClass newFirst = new VersionedClass("newId1", "foo"); + VersionedClass newSecond = new VersionedClass("newId2", "bar"); + + assertThat(newFirst.getVersion() == 0).isTrue(); + assertThat(newSecond.getVersion() == 0).isTrue(); + + template.saveAll(List.of(newFirst, newSecond)); + assertThat(newFirst.getVersion() == 1).isTrue(); + assertThat(newSecond.getVersion() == 1).isTrue(); + + template.saveAll(List.of(newFirst, newSecond)); + assertThat(newFirst.getVersion() == 2).isTrue(); + assertThat(newSecond.getVersion() == 2).isTrue(); } } @Test public void shouldSaveAllNotVersionedDocumentsIfAlreadyExist() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { Person john = new Person("id1", "John"); Person jack = new Person("id2", "Jack"); template.save(jack); // saving non-versioned document to create a new DB record diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateUpdateTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateUpdateTests.java index 14be19942..74ae284bd 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateUpdateTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateUpdateTests.java @@ -401,16 +401,19 @@ public void TestAddToMapSpecifyingMapFieldOnly() { @Test public void updateAllShouldThrowExceptionOnUpdateForNonExistingKey() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { - VersionedClass first = new VersionedClass("newId1", "foo"); // This class has a version field (class - // field annotated with @Version). The constructor does not receive the version, so it stays equal to zero - VersionedClass second = new VersionedClass("newId2", "bar"); // - assertThat(first.getVersion() == 0).isTrue(); // The document's version is zero meaning there is no - // corresponding DB record + if (serverVersionSupport.isBatchWriteSupported()) { + // This class has a version field (class field annotated with @Version). + // The constructor does not receive the version, so it stays equal to zero + VersionedClass first = new VersionedClass("newId1", "foo"); + VersionedClass second = new VersionedClass("newId2", "bar"); + // The documents’ versions are equal to zero, meaning the documents have not been saved to the database yet + assertThat(first.getVersion() == 0).isTrue(); assertThat(second.getVersion() == 0).isTrue(); template.insert(first); - assertThat(first.getVersion() == 1).isTrue(); // The document's version is equal to one meaning there is - // a corresponding DB record + + // The document's version is equal to one meaning there is a corresponding DB record + assertThat(first.getVersion() == 1).isTrue(); + // RecordExistsAction.UPDATE_ONLY assertThatThrownBy(() -> template.updateAll(List.of(first, second))) // An attempt to update versioned // documents without already existing DB records results in getting BatchRecordArray exception @@ -440,7 +443,7 @@ public void updateAllShouldThrowExceptionOnUpdateForNonExistingKey() { @Test public void updateAllIfDocumentsNotChanged() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { int age1 = 140335200; int age2 = 177652800; Person person1 = new Person(id, "Wolfgang M", age1); @@ -460,7 +463,7 @@ public void updateAllIfDocumentsNotChanged() { @Test public void updateAllIfDocumentsChanged() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { int age1 = 140335200; int age2 = 177652800; Person person1 = new Person(id, "Wolfgang", age1); @@ -487,13 +490,48 @@ public void updateAllIfDocumentsChanged() { personsWithUpdate.forEach(person -> assertThat(template.findById(person.getId(), Person.class).getFirstName() .equals(person.getFirstName())).isTrue()); + + // This document has a version (class field annotated with @Version). + // The constructor does not receive the version parameter, so it stays equal to zero + VersionedClass first = new VersionedClass("id1", "foo"); + + // In this case non-zero versions get explicitly passed to the constructor + VersionedClass second = new VersionedClass("id2", "foo", 1L); + VersionedClass third = new VersionedClass("id3", "foo", 2L); + + // Insert multiple versioned documents to create new DB records + template.insertAll(List.of(first, second, third)); + + assertThat(first.getVersion() == 1).isTrue(); + // initial documents' versions are overridden by the versions from the created DB records + assertThat(second.getVersion() == 1).isTrue(); + assertThat(third.getVersion() == 1).isTrue(); + + first = new VersionedClass(first.getId(), "foobar1", first.getVersion()); + second = new VersionedClass(second.getId(), "foobar2", second.getVersion()); + third = new VersionedClass(third.getId(), "foobar3", third.getVersion()); + template.updateAll(List.of(first, second, third)); + + assertThat(template.findById(first.getId(), VersionedClass.class)).satisfies(doc -> { + assertThat(doc.getField()).isEqualTo("foobar1"); + assertThat(doc.getVersion()).isEqualTo(2); + }); + assertThat(template.findById(second.getId(), VersionedClass.class)).satisfies(doc -> { + assertThat(doc.getField()).isEqualTo("foobar2"); + assertThat(doc.getVersion()).isEqualTo(2); + }); + assertThat(template.findById(third.getId(), VersionedClass.class)).satisfies(doc -> { + assertThat(doc.getField()).isEqualTo("foobar3"); + assertThat(doc.getVersion()).isEqualTo(2); + }); + } } @Test public void updateAllIfDocumentsNotChangedWithSetName() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { int age1 = 140335200; int age2 = 177652800; Person person1 = new Person(id, "Wolfgang", age1); diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateDeleteRelatedTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateDeleteRelatedTests.java index 4b38c1c9b..b9fddb2d8 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateDeleteRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateDeleteRelatedTests.java @@ -158,7 +158,7 @@ public void deleteByObject_shouldReturnFalseIfValueIsAbsent() { @Test public void deleteByIds_ShouldDeleteAllDocuments() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); String id2 = nextId(); reactiveTemplate.save(new SampleClasses.VersionedClass(id1, "test1")).block(); @@ -186,7 +186,7 @@ public void deleteByIds_ShouldDeleteAllDocuments() { @Test public void deleteByIdsWithSetName_ShouldDeleteAllDocuments() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); String id2 = nextId(); reactiveTemplate.save(new SampleClasses.DocumentWithExpiration(id1), OVERRIDE_SET_NAME).block(); @@ -205,7 +205,7 @@ public void deleteByIdsWithSetName_ShouldDeleteAllDocuments() { @Test public void deleteByIdsFromDifferentSets_ShouldDeleteAllDocuments() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { SampleClasses.DocumentWithExpiration entity1_1 = new SampleClasses.DocumentWithExpiration(id); SampleClasses.DocumentWithExpiration entity1_2 = new SampleClasses.DocumentWithExpiration(nextId()); SampleClasses.VersionedClass entity2_1 = new SampleClasses.VersionedClass(nextId(), "test1"); @@ -248,7 +248,7 @@ public void deleteByIdsFromDifferentSets_ShouldDeleteAllDocuments() { @Test public void deleteByIds_rejectsDuplicateIds() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); SampleClasses.DocumentWithExpiration document1 = new SampleClasses.DocumentWithExpiration(id1); SampleClasses.DocumentWithExpiration document2 = new SampleClasses.DocumentWithExpiration(id1); @@ -265,7 +265,7 @@ public void deleteByIds_rejectsDuplicateIds() { @Test public void deleteAll_ShouldDeleteAllDocuments() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); String id2 = nextId(); SampleClasses.DocumentWithExpiration document1 = new SampleClasses.DocumentWithExpiration(id1); @@ -294,7 +294,7 @@ public void deleteAll_ShouldDeleteAllDocuments() { @Test public void deleteAllWithSetName_ShouldDeleteAllDocuments() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); String id2 = nextId(); SampleClasses.DocumentWithExpiration document1 = new SampleClasses.DocumentWithExpiration(id1); @@ -313,7 +313,7 @@ public void deleteAllWithSetName_ShouldDeleteAllDocuments() { @Test public void deleteAll_ShouldDeleteAllDocumentsBeforeGivenLastUpdateTime() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); String id2 = nextId(); SampleClasses.CollectionOfObjects document1 = new SampleClasses.CollectionOfObjects(id1, List.of("test1")); @@ -370,7 +370,7 @@ public void deleteAll_ShouldDeleteAllDocumentsBeforeGivenLastUpdateTime() { @Test public void deleteAll_rejectsDuplicateIds() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = nextId(); SampleClasses.DocumentWithExpiration document1 = new SampleClasses.DocumentWithExpiration(id1); SampleClasses.DocumentWithExpiration document2 = new SampleClasses.DocumentWithExpiration(id1); @@ -385,7 +385,7 @@ public void deleteAll_rejectsDuplicateIds() { @Test public void deleteAll_VersionsMismatch() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { String id1 = "id1"; VersionedClass document1 = new VersionedClass(id1, "test1"); String id2 = "id2"; diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateInsertTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateInsertTests.java index 66097ad28..ca7b8bdf6 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateInsertTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateInsertTests.java @@ -229,7 +229,7 @@ public void insertsOnlyFirstDocumentAndNextAttemptsShouldFailWithDuplicateKeyExc @Test public void insertAll_shouldInsertAllDocuments() { - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { Person customer1 = new Person(nextId(), "Dave"); Person customer2 = new Person(nextId(), "James"); reactiveTemplate.insertAll(List.of(customer1, customer2)).blockLast(); @@ -257,7 +257,7 @@ public void insertAll_shouldInsertAllDocuments() { @Test public void insertAllWithSetName_shouldInsertAllDocuments() { - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { Person customer1 = new Person(nextId(), "Dave"); Person customer2 = new Person(nextId(), "James"); reactiveTemplate.insertAll(List.of(customer1, customer2), OVERRIDE_SET_NAME).blockLast(); @@ -271,7 +271,7 @@ public void insertAllWithSetName_shouldInsertAllDocuments() { @Test public void insertAll_rejectsDuplicateId() { - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { Person person = new Person(id, "Amol"); person.setAge(28); @@ -283,7 +283,7 @@ public void insertAll_rejectsDuplicateId() { @Test public void insertAllWithSetName_rejectsDuplicateId() { - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { Person person = new Person(id, "Amol"); person.setAge(28); diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateSaveRelatedTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateSaveRelatedTests.java index 29734d571..63f3342c0 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateSaveRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateSaveRelatedTests.java @@ -253,7 +253,7 @@ public void save_rejectsNullObjectToBeSaved() { @Test public void saveAll_shouldSaveAllDocuments() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { Person customer1 = new Person(nextId(), "Dave"); Person customer2 = new Person(nextId(), "James"); reactiveTemplate.saveAll(List.of(customer1, customer2)).blockLast(); @@ -270,7 +270,7 @@ public void saveAll_shouldSaveAllDocuments() { @Test public void saveAllWithSetName_shouldSaveAllDocuments() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { Person customer1 = new Person(nextId(), "Dave"); Person customer2 = new Person(nextId(), "James"); reactiveTemplate.saveAll(List.of(customer1, customer2), OVERRIDE_SET_NAME).blockLast(); @@ -287,7 +287,7 @@ public void saveAllWithSetName_shouldSaveAllDocuments() { @Test public void saveAll_rejectsDuplicateId() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { VersionedClass first = new VersionedClass(id, "foo"); StepVerifier.create(reactiveTemplate.saveAll(List.of(first, first))) .expectError(OptimisticLockingFailureException.class) @@ -299,7 +299,7 @@ public void saveAll_rejectsDuplicateId() { @Test public void saveAllWithSetName_rejectsDuplicateId() { // batch delete operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { VersionedClass second = new VersionedClass(id, "foo"); StepVerifier.create(reactiveTemplate.saveAll(List.of(second, second), OVERRIDE_SET_NAME)) diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateUpdateTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateUpdateTests.java index bc5cc6c9a..b4f642702 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateUpdateTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateUpdateTests.java @@ -369,7 +369,7 @@ public void TestAddToMapSpecifyingMapFieldOnlyWithSetName() { @Test public void updateAllIfDocumentsChanged() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { int age1 = 140335200; int age2 = 177652800; Person person1 = new Person(id, "Wolfgang", age1); @@ -401,7 +401,7 @@ public void updateAllIfDocumentsChanged() { @Test public void updateAllShouldThrowExceptionOnUpdateForNonExistingKey() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { Person person1 = new Person(id, "svenfirstName", 11); Person person2 = new Person(nextId(), "svenfirstName", 11); Person person3 = new Person(nextId(), "svenfirstName", 11); @@ -419,7 +419,7 @@ public void updateAllShouldThrowExceptionOnUpdateForNonExistingKey() { @Test public void updateAllIfDocumentsNotChanged() { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { int age1 = 140335200; int age2 = 177652800; Person person1 = new Person(id, "Wolfgang", age1); diff --git a/src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java b/src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java index fca6687af..fd6a5741e 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java @@ -543,7 +543,7 @@ void findByMapOfListsKeyValueEquals() { @Test void findByAddressesMapKeyValueEquals() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Address address1 = new Address("Foo Street 1", 1, "C0123", "Bar"); Address address2 = new Address("Foo Street 2", 1, "C0123", "Bar"); Address address3 = new Address("Foo Street 2", 1, "C0124", "Bar"); @@ -756,7 +756,7 @@ void findByMapOfListsKeyValueNotEqual() { @Test void findByAddressesMapKeyValueNotEqual() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Address address1 = new Address("Foo Street 1", 1, "C0123", "Bar"); Address address2 = new Address("Foo Street 2", 1, "C0123", "Bar"); Address address3 = new Address("Foo Street 2", 1, "C0124", "Bar"); @@ -885,7 +885,7 @@ void findByMapKeyValueLessThanOrEqual() { @Test void findByMapKeyValueGreaterThanList() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Map> mapOfLists1 = Map.of("0", List.of(100), "1", List.of(200), "2", List.of(300), "3", List.of(400)); Map> mapOfLists2 = Map.of("0", List.of(101), "1", List.of(201), "2", List.of(301), @@ -920,7 +920,7 @@ void findByMapKeyValueGreaterThanList() { @Test void findByMapKeyValueLessThanAddress() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Map mapOfAddresses1 = Map.of("a", new Address("Foo Street 1", 1, "C0123", "Bar")); Map mapOfAddresses2 = Map.of("b", new Address("Foo Street 2", 1, "C0123", "Bar")); Map mapOfAddresses3 = Map.of("c", new Address("Foo Street 2", 1, "C0124", "Bar")); @@ -978,7 +978,7 @@ void findByIntMapKeyValueBetween() { @Test void findByIntMapBetween() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { assertThat(carter.getIntMap()).isEqualTo(Map.of("key1", 0, "key2", 1)); Map map1 = Map.of("key1", -1, "key2", 0); @@ -992,7 +992,7 @@ void findByIntMapBetween() { @Test void findByMapOfListsBetween() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Map> mapOfLists1 = Map.of("0", List.of(100), "1", List.of(200)); Map> mapOfLists2 = Map.of("2", List.of(301), "3", List.of(401)); Map> mapOfLists3 = Map.of("1", List.of(102), "2", List.of(202)); @@ -1207,7 +1207,7 @@ void deletePersonById() { @Test void deletePersonsByIds() { - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { // batch delete requires server ver. >= 6.0.0 repository.deleteAllById(List.of(dave.getId(), carter.getId())); @@ -1220,7 +1220,7 @@ void deletePersonsByIds() { @Test void deleteAllPersonsFromList() { - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { // batch delete requires server ver. >= 6.0.0 repository.deleteAll(List.of(dave, carter)); @@ -1999,7 +1999,7 @@ void findPersonInRangeCorrectly() { it = repository.findByFirstNameBetween("Dave", "David"); assertThat(it).hasSize(1).contains(dave); - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { assertThat(dave.getAddress()).isEqualTo(new Address("Foo Street 1", 1, "C0123", "Bar")); Address address1 = new Address("Foo Street 1", 0, "C0123", "Bar"); Address address2 = new Address("Foo Street 2", 2, "C0124", "Bar"); @@ -2047,7 +2047,7 @@ void findPersonsByFriendsInAgeRangeCorrectly() { @Test void findPersonsByStringsList() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { List listToCompareWith = List.of("str0", "str1", "str2"); assertThat(dave.getStrings()).isEqualTo(listToCompareWith); @@ -2062,7 +2062,7 @@ void findPersonsByStringsList() { @Test void findPersonsByStringsListNotEqual() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { List listToCompareWith = List.of("str0", "str1", "str2"); assertThat(dave.getStrings()).isEqualTo(listToCompareWith); assertThat(donny.getStrings()).isNotEmpty(); @@ -2075,7 +2075,7 @@ void findPersonsByStringsListNotEqual() { @Test void findPersonsByStringsListLessThan() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { List davesStrings = dave.getStrings(); List listToCompareWith = List.of("str1", "str2", "str3"); List listWithFewerElements = List.of("str1", "str2"); @@ -2095,7 +2095,7 @@ void findPersonsByStringsListLessThan() { @Test void findPersonsByStringsListGreaterThanOrEqual() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Set setToCompareWith = Set.of(0, 1, 2, 3, 4); dave.setIntSet(setToCompareWith); repository.save(dave); @@ -2108,7 +2108,7 @@ void findPersonsByStringsListGreaterThanOrEqual() { @Test void findPersonsByStringMap() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Map mapToCompareWith = Map.of("key1", "val1", "key2", "val2"); assertThat(boyd.getStringMap()).isEqualTo(mapToCompareWith); @@ -2123,7 +2123,7 @@ void findPersonsByStringMap() { @Test void findPersonsByAddress() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Address address = new Address("Foo Street 1", 1, "C0123", "Bar"); dave.setAddress(address); repository.save(dave); @@ -2135,7 +2135,7 @@ void findPersonsByAddress() { @Test void findPersonsByAddressNotEqual() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Address address = new Address("Foo Street 1", 1, "C0123", "Bar"); assertThat(dave.getAddress()).isEqualTo(address); assertThat(carter.getAddress()).isNotNull(); @@ -2150,7 +2150,7 @@ void findPersonsByAddressNotEqual() { @Test void findPersonsByIntMapNotEqual() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Map mapToCompareWith = Map.of("key1", 0, "key2", 1); assertThat(carter.getIntMap()).isEqualTo(mapToCompareWith); assertThat(boyd.getIntMap()).isNullOrEmpty(); @@ -2168,7 +2168,7 @@ void findPersonsByIntMapNotEqual() { @Test void findPersonsByAddressLessThan() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Address address = new Address("Foo Street 2", 2, "C0124", "C0123"); assertThat(dave.getAddress()).isNotEqualTo(address); assertThat(carter.getAddress()).isEqualTo(address); @@ -2180,7 +2180,7 @@ void findPersonsByAddressLessThan() { @Test void findPersonsByStringMapGreaterThan() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { assertThat(boyd.getStringMap()).isNotEmpty(); assertThat(donny.getStringMap()).isNotEmpty(); @@ -2192,7 +2192,7 @@ void findPersonsByStringMapGreaterThan() { @Test void findPersonsByFriend() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { alicia.setAddress(new Address("Foo Street 1", 1, "C0123", "Bar")); repository.save(alicia); oliver.setFriend(alicia); @@ -2208,7 +2208,7 @@ void findPersonsByFriend() { @Test void findPersonsByFriendAddress() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Address address = new Address("Foo Street 1", 1, "C0123", "Bar"); dave.setAddress(address); repository.save(dave); @@ -2347,7 +2347,7 @@ void findPersonsByFriendFriendFriendFriendFriendFriendFriendFriendBestFriendAddr @Test // find by deeply nested POJO void findPersonsByFriendFriendFriendFriendFriendFriendFriendFriendBestFriendBestFriendAddress() { - if (serverVersionSupport.findByPojo()) { + if (serverVersionSupport.isFindByPojoSupported()) { Address address = new Address("Foo Street 1", 1, "C0123", "Bar"); dave.setAddress(address); repository.save(dave); 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 cbe816998..4ecf1022b 100644 --- a/src/test/java/org/springframework/data/aerospike/utility/AdditionalAerospikeTestOperations.java +++ b/src/test/java/org/springframework/data/aerospike/utility/AdditionalAerospikeTestOperations.java @@ -178,7 +178,7 @@ public void dropIndexes(Collection indexesToBeDropped) { public void deleteAll(AerospikeRepository repository, Collection entities) { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { try { repository.deleteAll(entities); } catch (AerospikeException.BatchRecordArray ignored) { @@ -191,7 +191,7 @@ public void deleteAll(AerospikeRepository repository, Collection en public void saveAll(AerospikeRepository repository, Collection entities) { // batch write operations are supported starting with Server version 6.0+ - if (serverVersionSupport.batchWrite()) { + if (serverVersionSupport.isBatchWriteSupported()) { repository.saveAll(entities); } else { entities.forEach(repository::save); From 4fdcbdf6b4e71c996be1e0a6e60c0c918881d6df Mon Sep 17 00:00:00 2001 From: agrgr Date: Tue, 23 Jan 2024 13:43:40 +0200 Subject: [PATCH 2/2] code format --- .../data/aerospike/core/AerospikeTemplateUpdateTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateUpdateTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateUpdateTests.java index 74ae284bd..1ac059a68 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateUpdateTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateUpdateTests.java @@ -524,7 +524,6 @@ public void updateAllIfDocumentsChanged() { assertThat(doc.getField()).isEqualTo("foobar3"); assertThat(doc.getVersion()).isEqualTo(2); }); - } }