diff --git a/README.adoc b/README.adoc index 9b6e8cb76..86b7321de 100644 --- a/README.adoc +++ b/README.adoc @@ -140,12 +140,16 @@ For non-blocking reactive API use `ReactiveAerospikeRepository`. === 3. Configuration In order to configure Spring Data Aerospike you will need to create a configuration class that extends -`AbstractAerospikeDataConfiguration`, defines the relevant Spring Data Repositories via `@EnableAerospikeRepositories` -annotation and overrides `getHosts()` and `nameSpace()` methods with the required connection details. +`AbstractAerospikeDataConfiguration` and defines the relevant Spring Data Repositories via `@EnableAerospikeRepositories` +annotation. -NOTE: You can optionally override xref:#configure-data-settings[`configureDataSettings`] method of `AbstractAerospikeDataConfiguration` to further customize your configuration. +To set the connection details you can either override `getHosts()` and `nameSpace()` methods +of the `AbstractAerospikeDataConfiguration` class or define `spring-data-aerospike.connection.hosts` and +`spring-data-aerospike.connection.namespace` in `application.properties` file. -Here is a simple example of a configuration class that sets up a connection to a local Aerospike instance: +NOTE: You can further customize your configuration by changing other xref:#configuration[`settings`]. + +Here is a simple example of a configuration class that sets up a connection to a local Aerospike DB instance: [source,java] ---- diff --git a/pom.xml b/pom.xml index 9f5a425f1..9be433e02 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,7 @@ UTF-8 3.2.1 3.2.1 + 3.2.1 3.2.0 4.1.0 3.3.0 @@ -183,6 +184,12 @@ spring-data-keyvalue ${springdata.keyvalue} + + org.springframework.boot + spring-boot + ${springdata.spring-boot} + compile + com.aerospike aerospike-client diff --git a/src/main/asciidoc/index.adoc b/src/main/asciidoc/index.adoc index 3243869d8..223357471 100644 --- a/src/main/asciidoc/index.adoc +++ b/src/main/asciidoc/index.adoc @@ -39,7 +39,7 @@ include::reference/template.adoc[] include::reference/secondary-indexes.adoc[] include::reference/indexed-annotation.adoc[] include::reference/caching.adoc[] -include::reference/configure-data-settings.adoc[] +include::reference/configuration.adoc[] include::spring-data-commons-docs/dependencies.adoc[] include::spring-data-commons-docs/auditing.adoc[] diff --git a/src/main/asciidoc/reference/aerospike-object-mapping.adoc b/src/main/asciidoc/reference/aerospike-object-mapping.adoc index 213ef580b..f0cf95473 100644 --- a/src/main/asciidoc/reference/aerospike-object-mapping.adoc +++ b/src/main/asciidoc/reference/aerospike-object-mapping.adoc @@ -49,7 +49,7 @@ The following outlines what field will be 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:#configure-data-settings.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 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. * 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/caching.adoc b/src/main/asciidoc/reference/caching.adoc index 7f1d965d1..bf76b03b6 100644 --- a/src/main/asciidoc/reference/caching.adoc +++ b/src/main/asciidoc/reference/caching.adoc @@ -206,7 +206,7 @@ public class UserController { === Add @EnableCaching -==== SimpleSpringbootAerospikeCacheApplication +==== SimpleSpringBootAerospikeCacheApplication Add `@EnableCaching` to the class that contains the main method. @@ -214,9 +214,9 @@ Add `@EnableCaching` to the class that contains the main method. ---- @EnableCaching @SpringBootApplication -public class SimpleSpringbootAerospikeCacheApplication { +public class SimpleSpringBootAerospikeCacheApplication { public static void main(String[] args) { - SpringApplication.run(SimpleSpringbootAerospikeCacheApplication.class, args); + SpringApplication.run(SimpleSpringBootAerospikeCacheApplication.class, args); } } ---- @@ -252,7 +252,7 @@ aql> select * from test +-----+-----------+----------+-------------+-------------------------------------+ | @user_key | name | @_class | email | age | +-----+-----------+----------+-------------+-------------------------------------+ -| "1" | "guthrie" | "com.aerospike.cache.simplespringbootaerospikecache.objects.User" | "guthriegovan@gmail.com" | 35 | +| "1" | "guthrie" | "com.aerospike.cache.simpleSpringBootAerospikeCache.objects.User" | "guthriegovan@gmail.com" | 35 | +-----+-----------+----------+-------------+-------------------------------------+ ---- @@ -315,6 +315,6 @@ aql> select * from test +-----+-----------+----------+-------------+-------------------------------------+ | @user_key | name | @_class | email | age | +-----+-----------+----------+-------------+-------------------------------------+ -| "1" | "jimmy page" | "com.aerospike.cache.simplespringbootaerospikecache.objects.User" | "jimmy@gmail.com" | 77 | +| "1" | "jimmy page" | "com.aerospike.cache.simpleSpringBootAerospikeCache.objects.User" | "jimmy@gmail.com" | 77 | +-----+-----------+----------+-------------+-------------------------------------+ ---- diff --git a/src/main/asciidoc/reference/configuration.adoc b/src/main/asciidoc/reference/configuration.adoc new file mode 100644 index 000000000..18be5b007 --- /dev/null +++ b/src/main/asciidoc/reference/configuration.adoc @@ -0,0 +1,398 @@ +[[configuration]] += Configuration + +Configuration parameters can be set in a standard `application.properties` file using `spring-data-aerospike.*` prefix +or by overriding configuration from `AbstractAerospikeDataConfiguration` class. + +[[configuration.application-properties]] +== Application.properties + +Here is an example: + +[source,properties] +---- +# application.properties +spring-data-aerospike.connection.hosts=localhost:3000 +spring-data-aerospike.connection.namespace=test +spring-data-aerospike.data.scans-enabled=false +spring-data-aerospike.data.send-key=true +spring-data-aerospike.data.create-indexes-on-startup=true +spring-data-aerospike.data.index-cache-refresh-seconds=3600 +spring-data-aerospike.data.server-version-refresh-seconds=3600 +spring-data-aerospike.data.query-max-records=10000 +spring-data-aerospike.data.batch-write-size=100 +spring-data-aerospike.data.keep-original-key-types=false +---- + +Configuration class: + +[source, java] +---- +@Configuration +@EnableAerospikeRepositories(basePackageClasses = {TestRepository.class}) +public class AerospikeConfiguration extends AbstractAerospikeDataConfiguration { + +} +---- + +In this case extending `AbstractAerospikeDataConfiguration` class is required to enable repositories. + +[[configuration.overriding-configuration]] +== Overriding configuration + +Configuration can also be set by overriding `getHosts()`, `nameSpace()` and `configureDataSettings()` methods of the `AbstractAerospikeDataConfiguration` class. + +Here is an example: + +[source,java] +---- +@EnableAerospikeRepositories(basePackageClasses = TestRepository.class) +class ApplicationConfig extends AbstractAerospikeDataConfiguration { + + @Override + protected Collection getHosts() { + return Collections.singleton(new Host("localhost", 3000)); + } + + @Override + protected String nameSpace() { + return "test"; + } + + @Override + public void configureDataSettings(AerospikeDataSettings aerospikeDataSettings) { + aerospikeDataSettings.setScansEnabled(false); + aerospikeDataSettings.setCreateIndexesOnStartup(true); + aerospikeDataSettings.setIndexCacheRefreshSeconds(3600); + aerospikeDataSettings.setServerVersionRefreshSeconds(3600); + aerospikeDataSettings.setQueryMaxRecords(10000L); + aerospikeDataSettings.setBatchWriteSize(100); + aerospikeDataSettings.setKeepOriginalKeyTypes(false); + } +} +---- + +NOTE: Return values of `getHosts()`, `nameSpace()` and `configureDataSettings()` methods +of the `AbstractAerospikeDataConfiguration` class have precedence over the parameters +set via application.properties. + +[[configuration.parameters]] +== Configuration Parameters + +[[configuration.hosts]] +=== hosts + +[source,properties] +---- +# application.properties +spring-data-aerospike.connection.hosts=hostname1:3001, hostname2:tlsName2:3002 +---- + +A String of hosts separated by `,` in form of `hostname1[:tlsName1][:port1],...` + +IP addresses must be given in one of the following formats: + +[source,text] +---- +IPv4: xxx.xxx.xxx.xxx +IPv6: [xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx] +IPv6: [xxxx::xxxx] +---- + +IPv6 addresses must be enclosed by brackets. tlsName is optional. + +NOTE: Another way of defining hosts is overriding the `getHosts()` method. +It has precedence over `hosts` parameter from application.properties. Here is an example: + +[source,java] +---- +// overriding method +@EnableAerospikeRepositories(basePackageClasses = TestRepository.class) +class ApplicationConfig extends AbstractAerospikeDataConfiguration { + + @Override + protected Collection getHosts() { + return Collections.singleton(new Host("hostname1", 3001)); + } +} +---- + +*Default:* `null`. + +[[configuration.namespace]] +=== namespace + +[source,properties] +---- +# application.properties +spring-data-aerospike.connection.namespace=test +---- + +Aerospike DB namespace. + +NOTE: Another way of defining hosts is overriding the `nameSpace()` method. +It has precedence over `namespace` parameter from application.properties. +Here is an example: + +[source,java] +---- +// overriding method +@EnableAerospikeRepositories(basePackageClasses = TestRepository.class) +class ApplicationConfig extends AbstractAerospikeDataConfiguration { + + @Override + protected String nameSpace() { + return "test"; + } +} +---- + +NOTE: To use multiple namespaces it is required to override `nameSpace()` and `AerospikeTemplate` for each +configuration class per namespace. +See https://github.com/aerospike-examples/spring-data-multiple-namespaces-example[multiple namespaces example] +for implementation details. + +*Default:* `null`. + +[[configuration.scans-enabled]] +=== scansEnabled + +[source,properties] +---- +# application.properties +spring-data-aerospike.data.scans-enabled=false +---- + +A scan can be an expensive operation as all records in the set must be read by the Aerospike server, +and then the condition is applied to see if they match. + +Due to the cost of performing this operation, scans from Spring Data Aerospike are disabled by default. + +NOTE: Another way of defining the parameter is overriding the `configureDataSettings()` method. +It has precedence over reading from application.properties. Here is an example: + +[source,java] +---- +// overriding method +@EnableAerospikeRepositories(basePackageClasses = TestRepository.class) +class ApplicationConfig extends AbstractAerospikeDataConfiguration { + + + @Override + public void configureDataSettings(AerospikeDataSettings aerospikeDataSettings) { + aerospikeDataSettings.setScansEnabled(false); + } +} +---- + +NOTE: Once this flag is enabled, scans run whenever needed with no warnings. This may or may not be optimal +in a particular use case. + +*Default:* `false`. + +[[configuration.create-indexes-on-startup]] +=== createIndexesOnStartup + +[source,properties] +---- +# application.properties +spring-data-aerospike.data.create-indexes-on-startup=true +---- + +Create secondary indexes specified using `@Indexed` annotation on startup. + +NOTE: Another way of defining the parameter is overriding the `configureDataSettings()` method. +It has precedence over reading from application.properties. Here is an example: + +[source,java] +---- +// overriding method +@EnableAerospikeRepositories(basePackageClasses = TestRepository.class) +class ApplicationConfig extends AbstractAerospikeDataConfiguration { + + + @Override + public void configureDataSettings(AerospikeDataSettings aerospikeDataSettings) { + aerospikeDataSettings.setCreateIndexesOnStartup(true); + } +} +---- + +*Default*: `true`. + +[[configuration.index-cache-refresh-frequency-seconds]] +=== indexCacheRefreshSeconds + +[source,properties] +---- +# application.properties +spring-data-aerospike.data.index-cache-refresh-seconds=3600 +---- + +Automatically refresh indexes cache every seconds. + +NOTE: Another way of defining the parameter is overriding the `configureDataSettings()` method. +It has precedence over reading from application.properties. Here is an example: + +[source,java] +---- +// overriding method +@EnableAerospikeRepositories(basePackageClasses = TestRepository.class) +class ApplicationConfig extends AbstractAerospikeDataConfiguration { + + + @Override + public void configureDataSettings(AerospikeDataSettings aerospikeDataSettings) { + aerospikeDataSettings.setIndexCacheRefreshSeconds(3600); + } +} +---- + +*Default*: `3600`. + +[[configuration.server-version-refresh-frequency-seconds]] +=== serverVersionRefreshSeconds + +[source,properties] +---- +# application.properties +spring-data-aerospike.data.server-version-refresh-seconds=3600 +---- + +Automatically refresh cached server version every seconds. + +NOTE: Another way of defining the parameter is overriding the `configureDataSettings()` method. +It has precedence over reading from application.properties. Here is an example: + +[source,java] +---- +// overriding method +@EnableAerospikeRepositories(basePackageClasses = TestRepository.class) +class ApplicationConfig extends AbstractAerospikeDataConfiguration { + + + @Override + public void configureDataSettings(AerospikeDataSettings aerospikeDataSettings) { + aerospikeDataSettings.setServerVersionRefreshSeconds(3600); + } +} +---- + +*Default*: `3600`. + +[[configuration.query-max-records]] +=== queryMaxRecords + +[source,properties] +---- +# application.properties +spring-data-aerospike.data.query-max-records=10000 +---- + +Limit amount of results returned by server. Non-positive value means no limit. + +NOTE: Another way of defining the parameter is overriding the `configureDataSettings()` method. +It has precedence over reading from application.properties. Here is an example: + +[source,java] +---- +// overriding method +@EnableAerospikeRepositories(basePackageClasses = TestRepository.class) +class ApplicationConfig extends AbstractAerospikeDataConfiguration { + + + @Override + public void configureDataSettings(AerospikeDataSettings aerospikeDataSettings) { + aerospikeDataSettings.setQueryMaxRecords(10000L); + } +} +---- + +*Default*: `10 000`. + +[[configuration.batch-write-size]] +=== batchWriteSize + +[source,properties] +---- +# application.properties +spring-data-aerospike.data.batch-write-size=100 +---- + +Maximum batch size for batch write operations. Non-positive value means no limit. + +NOTE: Another way of defining the parameter is overriding the `configureDataSettings()` method. +It has precedence over reading from application.properties. Here is an example: + +[source,java] +---- +// overriding method +@EnableAerospikeRepositories(basePackageClasses = TestRepository.class) +class ApplicationConfig extends AbstractAerospikeDataConfiguration { + + + @Override + public void configureDataSettings(AerospikeDataSettings aerospikeDataSettings) { + aerospikeDataSettings.setBatchWriteSize(100); + } +} +---- + +*Default*: `100`. + +[[configuration.keep-original-key-types]] +=== keepOriginalKeyTypes + +[source,properties] +---- +# application.properties +spring-data-aerospike.data.keep-original-key-types=false +---- + +Define how `@Id` fields (primary keys) and `Map` keys are stored in the Aerospike database: +`false` - always as `String`, `true` - preserve original type if supported. + +[width="100%",cols="<20%,<30%,<30%",options="header",] +|=== +|`@Id` field type |keepOriginalKeyTypes = `false` |keepOriginalKeyTypes = `true` +|`long` |`String` | `long` +|`int` |`String` | `long` +|`String` |`String` | `String` +|`byte[]` |`String` | `byte[]` +|other types |`String` | `String` +|=== + +NOTE: If `@Id` field's type cannot be persisted as is, 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. + +[width="100%",cols="<20%,<30%,<30%",options="header",] +|=== +|`Map` key type |keepOriginalKeyTypes = `false` |keepOriginalKeyTypes = `true` +|`long` |`String` | `long` +|`int` |`String` | `long` +|`double` |`String` | `double` +|`String` |`String` | `String` +|`byte[]` |`String` | `byte[]` +|other types |`String` | `String` +|=== + +NOTE: Another way of defining the parameter is overriding the `configureDataSettings()` method. +It has precedence over reading from application.properties. Here is an example: + +[source,java] +---- +// overriding method +@EnableAerospikeRepositories(basePackageClasses = TestRepository.class) +class ApplicationConfig extends AbstractAerospikeDataConfiguration { + + + @Override + public void configureDataSettings(AerospikeDataSettings aerospikeDataSettings) { + aerospikeDataSettings.setKeepOriginalKeyTypes(false); + } +} +---- + +*Default*: `false` (store keys only as `String`). + diff --git a/src/main/asciidoc/reference/configure-data-settings.adoc b/src/main/asciidoc/reference/configure-data-settings.adoc deleted file mode 100644 index 0122b2e2b..000000000 --- a/src/main/asciidoc/reference/configure-data-settings.adoc +++ /dev/null @@ -1,117 +0,0 @@ -[[configure-data-settings]] -= Configure Data Settings - -The `AbstractAerospikeDataConfiguration` class exposes a number of beans that Spring Data Aerospike uses internally. User can optionally override `configureDataSettings` method to customize configuration. - -Here is an example: - -[source,java] ----- -@EnableAerospikeRepositories(basePackageClasses = PersonRepository.class) -class ApplicationConfig extends AbstractAerospikeDataConfiguration { - - @Override - protected Collection getHosts() { - return Collections.singleton(new Host("localhost", 3000)); - } - - @Override - protected String nameSpace() { - return "test"; - } - - @Override - protected void configureDataSettings(AerospikeDataSettings.AerospikeDataSettingsBuilder builder) { - builder.createIndexesOnStartup(true); - builder.indexCacheRefreshSeconds(3600); - builder.queryMaxRecords(10000L); - } -} ----- - -[[configure-data-settings.parameters]] -== Configuration Parameters - -[[configure-data-settings.scans-enabled]] -=== scansEnabled - -A scan can be an expensive operation as all records in the set must be read by the Aerospike server, and then the condition is applied to see if they match. - -Due to the cost of performing this operation, scans from Spring Data Aerospike are disabled by default. - -NOTE: Once this flag is enabled, scans run whenever needed with no warnings. This may or may not be optimal in a particular use case. - -*Default:* `false`. - -[[configure-data-settings.send-key]] -=== sendKey - -Send user defined key in addition to hash digest on both reads and writes. If the key is sent on write, it will be stored with the record on the server. - -Default: `false` (do not send the user defined key). - -[[configure-data-settings.create-indexes-on-startup]] -=== createIndexesOnStartup - -Create secondary indexes specified using `@Indexed` annotation on startup. - -*Default*: `true`. - -[[configure-data-settings.index-cache-refresh-frequency-seconds]] -=== indexCacheRefreshSeconds - -Automatically refresh indexes cache every seconds. - -*Default*: `3600`. - -[[configure-data-settings.server-version-refresh-frequency-seconds]] -=== serverVersionRefreshSeconds - -Automatically refresh cached server version every seconds. - -*Default*: `3600`. - -[[configure-data-settings.query-max-records]] -=== queryMaxRecords - -Limit amount of results returned by server. Non-positive value means no limit. - -*Default*: `10 000`. - -[[configure-data-settings.batch-write-size]] -=== batchWriteSize - -Maximum batch size for batch write operations. Non-positive value means no limit. - -*Default*: `100`. - -[[configure-data-settings.keep-original-key-types]] -=== keepOriginalKeyTypes - -Define how `@Id` fields (primary keys) and `Map` keys are stored in the Aerospike database: `false` - always as `String`, `true` - preserve original type if supported. - -[width="100%",cols="<20%,<30%,<30%",options="header",] -|=== -|`@Id` field type |keepOriginalKeyTypes = `false` |keepOriginalKeyTypes = `true` -|`long` |`String` | `long` -|`int` |`String` | `long` -|`String` |`String` | `String` -|`byte[]` |`String` | `byte[]` -|other types |`String` | `String` -|=== - -NOTE: If `@Id` field's type cannot be persisted as is, 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. - -[width="100%",cols="<20%,<30%,<30%",options="header",] -|=== -|`Map` key type |keepOriginalKeyTypes = `false` |keepOriginalKeyTypes = `true` -|`long` |`String` | `long` -|`int` |`String` | `long` -|`double` |`String` | `double` -|`String` |`String` | `String` -|`byte[]` |`String` | `byte[]` -|other types |`String` | `String` -|=== - -*Default*: `false` (store keys only as `String`). - diff --git a/src/main/asciidoc/reference/indexed-annotation.adoc b/src/main/asciidoc/reference/indexed-annotation.adoc index 838883a96..934185b08 100644 --- a/src/main/asciidoc/reference/indexed-annotation.adoc +++ b/src/main/asciidoc/reference/indexed-annotation.adoc @@ -148,5 +148,6 @@ So the following will be true: |a.dd.[1].{#0} |[mapKey("a"), mapKey("dd"),listIndex(1), mapRank(0)] |y |=== -NOTE: There are relevant configuration parameters in AerospikeDataSettings: -xref:#configure-data-settings.create-indexes-on-startup[create indexes on startup] and xref:#configure-data-settings.index-cache-refresh-frequency-seconds[indexes cache refresh frequency]. +NOTE: There are relevant configuration parameters: +xref:#configuration.create-indexes-on-startup[create indexes on startup] and +xref:#configuration.index-cache-refresh-frequency-seconds[indexes cache refresh frequency]. diff --git a/src/main/asciidoc/reference/installation-and-usage.adoc b/src/main/asciidoc/reference/installation-and-usage.adoc index 0af6ef3cd..c703f0d23 100644 --- a/src/main/asciidoc/reference/installation-and-usage.adoc +++ b/src/main/asciidoc/reference/installation-and-usage.adoc @@ -50,7 +50,9 @@ implementation group: 'com.aerospike', name: 'spring-data-aerospike', version: ' == Connecting to Aerospike DB -Configuring Spring Data Aerospike is easy with the help of the `AbstractAerospikeDataConfiguration` class. +There are two ways of configuring a basic connection to Aerospike DB. + +* Overriding `getHosts()` and `nameSpace()` methods of the `AbstractAerospikeDataConfiguration` class: [source, java] ---- @@ -61,7 +63,6 @@ public class AerospikeConfiguration extends AbstractAerospikeDataConfiguration { protected Collection getHosts() { return Collections.singleton(new Host("localhost", 3000)); } - @Override protected String nameSpace() { return "test"; @@ -69,11 +70,32 @@ public class AerospikeConfiguration extends AbstractAerospikeDataConfiguration { } ---- -`@Configuration` tells Spring that this class contains configuration data, and `@EnableAerospikeRepositories` activates Aerospike repositories that can be used for data access. The parameter to this annotation tells Spring Data Aerospike where to look for the repositories. This can be a list of package names as strings using the `basePackages` value, or a list of classes through the `basePackageClass` value. If the latter is used (as in this example), the class is used to determine which package to scan, and all repositories in that package will be available for use. More details on repositories are below. +* Using `application.properties`: + +Basic configuration in this case requires enabling repositories and then setting `hosts` and `namespace` in the `application.properties` file. + +[source, java] +---- +@Configuration +@EnableAerospikeRepositories(basePackageClasses = { PersonRepository.class}) +public class AerospikeConfiguration extends AbstractAerospikeDataConfiguration { + +} +---- + +In `application.properties`: + +[source, properties] +---- +# application.properties +spring-data-aerospike.hosts=localhost:3000 +spring-data-aerospike.namespace=test +---- -The primary information required by this configuration is how to connect to the cluster, provided through the `getHosts` and `nameSpace` calls. +NOTE: Return values of `getHosts()` and `nameSpace()` methods of the `AbstractAerospikeDataConfiguration` class +have precedence over `hosts` and `namespace` parameters set via application.properties. -NOTE: You can optionally override xref:#configure-data-settings[`configureDataSettings`] method of `AbstractAerospikeDataConfiguration` to customize your configuration. +For more detailed information see xref:#configuration[Configuration]. == Creating Functionality @@ -156,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:#configure-data-settings.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 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. diff --git a/src/main/asciidoc/reference/scan-operation.adoc b/src/main/asciidoc/reference/scan-operation.adoc index 22371ae53..1e2681621 100644 --- a/src/main/asciidoc/reference/scan-operation.adoc +++ b/src/main/asciidoc/reference/scan-operation.adoc @@ -1,36 +1,20 @@ [[scan-operation]] = Scan Operation -A scan can be an expensive operation as all records in the set must be read by the Aerospike server, and then the condition is applied to see if they match. +A scan can be an expensive operation as all records in the set must be read by the Aerospike server, +and then the condition is applied to see if they match. Due to the cost of performing this operation, scans from Spring Data Aerospike are disabled by default. == Enabling Scan -If the cost of the scans is acceptable to an organization, they can be enabled by setting xref:#configure-data-settings.scans-enabled[`scansEnabled`] to `true` in `AerospikeDataSettings`. +If the cost of the scans is acceptable to an organization, they can be enabled by setting +xref:#configuration.scans-enabled[`scansEnabled`] parameter to `true`. -One way to do this is to create a custom bean which overrides the default settings: - -[source,java] +[source,properties] ---- -@Configuration -@EnableAerospikeRepositories(basePackageClasses = { PersonRepository.class}) -public class AerospikeConfiguration extends AbstractAerospikeDataConfiguration { - @Override - protected Collection getHosts() { - return Collections.singleton(new Host("localhost", 3000)); - } - - @Override - protected String nameSpace() { - return "test"; - } - - @Bean - public AerospikeDataSettings aerospikeDataSettings() { - return AerospikeDataSettings.builder().scansEnabled(true).build(); - } -} +spring-data-aerospike.scans-enabled=true ---- -NOTE: Once this flag is enabled, scans run whenever needed with no warnings. This may or may not be optimal in a particular use case. +NOTE: Once this flag is enabled, scans run whenever needed with no warnings. +This may or may not be optimal in a particular use case. diff --git a/src/main/asciidoc/reference/secondary-indexes.adoc b/src/main/asciidoc/reference/secondary-indexes.adoc index bba594078..3fb93b767 100644 --- a/src/main/asciidoc/reference/secondary-indexes.adoc +++ b/src/main/asciidoc/reference/secondary-indexes.adoc @@ -125,6 +125,7 @@ public List findByFirstName(String firstName); In this case `firstName` is not marked as `@Indexed`, so SpringData Aerospike is not instructed to create an index on it. Hence, it will scan the repository (a costly operation that could be avoided by using an index). -NOTE: There are relevant configuration parameters in AerospikeDataSettings: -xref:#configure-data-settings.create-indexes-on-startup[create indexes on startup] and xref:#configure-data-settings.index-cache-refresh-frequency-seconds[indexes cache refresh frequency]. +NOTE: There are relevant configuration parameters: +xref:#configuration.create-indexes-on-startup[create indexes on startup] and +xref:#configuration.index-cache-refresh-frequency-seconds[indexes cache refresh frequency]. diff --git a/src/main/java/org/springframework/data/aerospike/config/AbstractAerospikeDataConfiguration.java b/src/main/java/org/springframework/data/aerospike/config/AbstractAerospikeDataConfiguration.java index f16b35393..1f69fee27 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AbstractAerospikeDataConfiguration.java +++ b/src/main/java/org/springframework/data/aerospike/config/AbstractAerospikeDataConfiguration.java @@ -45,20 +45,22 @@ public AerospikeTemplate aerospikeTemplate(IAerospikeClient aerospikeClient, AerospikeMappingContext aerospikeMappingContext, AerospikeExceptionTranslator aerospikeExceptionTranslator, QueryEngine queryEngine, IndexRefresher indexRefresher, - ServerVersionSupport serverVersionSupport) { - return new AerospikeTemplate(aerospikeClient, nameSpace(), mappingAerospikeConverter, - aerospikeMappingContext, aerospikeExceptionTranslator, queryEngine, indexRefresher, serverVersionSupport); + ServerVersionSupport serverVersionSupport, + AerospikeSettings settings) { + return new AerospikeTemplate(aerospikeClient, settings.getConnectionSettings().getNamespace(), + mappingAerospikeConverter, aerospikeMappingContext, aerospikeExceptionTranslator, queryEngine, + indexRefresher, serverVersionSupport); } @Bean(name = "aerospikeQueryEngine") public QueryEngine queryEngine(IAerospikeClient aerospikeClient, StatementBuilder statementBuilder, - FilterExpressionsBuilder filterExpressionsBuilder) { + FilterExpressionsBuilder filterExpressionsBuilder, AerospikeSettings settings) { QueryEngine queryEngine = new QueryEngine(aerospikeClient, statementBuilder, filterExpressionsBuilder); - boolean scansEnabled = aerospikeDataSettings().isScansEnabled(); + boolean scansEnabled = settings.getDataSettings().isScansEnabled(); log.debug("AerospikeDataSettings.scansEnabled: {}", scansEnabled); queryEngine.setScansEnabled(scansEnabled); - long queryMaxRecords = aerospikeDataSettings().getQueryMaxRecords(); + long queryMaxRecords = settings.getDataSettings().getQueryMaxRecords(); log.debug("AerospikeDataSettings.queryMaxRecords: {}", queryMaxRecords); queryEngine.setQueryMaxRecords(queryMaxRecords); return queryEngine; @@ -68,9 +70,8 @@ public QueryEngine queryEngine(IAerospikeClient aerospikeClient, public AerospikePersistenceEntityIndexCreator aerospikePersistenceEntityIndexCreator( ObjectProvider aerospikeMappingContext, AerospikeIndexResolver aerospikeIndexResolver, - ObjectProvider template) - { - boolean indexesOnStartup = aerospikeDataSettings().isCreateIndexesOnStartup(); + ObjectProvider template, AerospikeSettings settings) { + boolean indexesOnStartup = settings.getDataSettings().isCreateIndexesOnStartup(); log.debug("AerospikeDataSettings.indexesOnStartup: {}", indexesOnStartup); return new AerospikePersistenceEntityIndexCreator(aerospikeMappingContext, indexesOnStartup, aerospikeIndexResolver, template); @@ -78,11 +79,11 @@ public AerospikePersistenceEntityIndexCreator aerospikePersistenceEntityIndexCre @Bean(name = "aerospikeIndexRefresher") public IndexRefresher indexRefresher(IAerospikeClient aerospikeClient, IndexesCacheUpdater indexesCacheUpdater, - ServerVersionSupport serverVersionSupport) { + ServerVersionSupport serverVersionSupport, AerospikeSettings settings) { IndexRefresher refresher = new IndexRefresher(aerospikeClient, aerospikeClient.getInfoPolicyDefault(), new InternalIndexOperations(new IndexInfoParser()), indexesCacheUpdater, serverVersionSupport); refresher.refreshIndexes(); - int refreshFrequency = aerospikeDataSettings().getIndexCacheRefreshSeconds(); + int refreshFrequency = settings.getDataSettings().getIndexCacheRefreshSeconds(); processCacheRefreshFrequency(refreshFrequency, refresher); log.debug("AerospikeDataSettings.indexCacheRefreshSeconds: {}", refreshFrequency); return refresher; diff --git a/src/main/java/org/springframework/data/aerospike/config/AbstractReactiveAerospikeDataConfiguration.java b/src/main/java/org/springframework/data/aerospike/config/AbstractReactiveAerospikeDataConfiguration.java index 2a0a85df9..733312447 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AbstractReactiveAerospikeDataConfiguration.java +++ b/src/main/java/org/springframework/data/aerospike/config/AbstractReactiveAerospikeDataConfiguration.java @@ -40,7 +40,7 @@ import org.springframework.data.aerospike.server.version.ServerVersionSupport; /** - * Configuration with beans needed for reactive stuff + * Configuration with beans needed for reactive flow * * @author Igor Ermolenko */ @@ -55,22 +55,24 @@ public ReactiveAerospikeTemplate reactiveAerospikeTemplate(MappingAerospikeConve IAerospikeReactorClient aerospikeReactorClient, ReactorQueryEngine reactorQueryEngine, ReactorIndexRefresher reactorIndexRefresher, - ServerVersionSupport serverVersionSupport) { - return new ReactiveAerospikeTemplate(aerospikeReactorClient, nameSpace(), mappingAerospikeConverter, - aerospikeMappingContext, aerospikeExceptionTranslator, reactorQueryEngine, reactorIndexRefresher, - serverVersionSupport); + ServerVersionSupport serverVersionSupport, + AerospikeSettings settings) { + return new ReactiveAerospikeTemplate(aerospikeReactorClient, settings.getConnectionSettings().getNamespace(), + mappingAerospikeConverter, aerospikeMappingContext, aerospikeExceptionTranslator, + reactorQueryEngine, reactorIndexRefresher, serverVersionSupport); } @Bean(name = "reactiveAerospikeQueryEngine") public ReactorQueryEngine reactorQueryEngine(IAerospikeReactorClient aerospikeReactorClient, StatementBuilder statementBuilder, - FilterExpressionsBuilder filterExpressionsBuilder) { + FilterExpressionsBuilder filterExpressionsBuilder, + AerospikeSettings settings) { ReactorQueryEngine queryEngine = new ReactorQueryEngine(aerospikeReactorClient, statementBuilder, filterExpressionsBuilder); - boolean scansEnabled = aerospikeDataSettings().isScansEnabled(); + boolean scansEnabled = settings.getDataSettings().isScansEnabled(); queryEngine.setScansEnabled(scansEnabled); log.debug("AerospikeDataSettings.scansEnabled: {}", scansEnabled); - long queryMaxRecords = aerospikeDataSettings().getQueryMaxRecords(); + long queryMaxRecords = settings.getDataSettings().getQueryMaxRecords(); log.debug("AerospikeDataSettings.queryMaxRecords: {}", queryMaxRecords); queryEngine.setQueryMaxRecords(queryMaxRecords); return queryEngine; @@ -106,8 +108,8 @@ protected ClientPolicy getClientPolicy() { public ReactiveAerospikePersistenceEntityIndexCreator aerospikePersistenceEntityIndexCreator( ObjectProvider aerospikeMappingContext, AerospikeIndexResolver aerospikeIndexResolver, - ObjectProvider template) { - boolean indexesOnStartup = aerospikeDataSettings().isCreateIndexesOnStartup(); + ObjectProvider template, AerospikeSettings settings) { + boolean indexesOnStartup = settings.getDataSettings().isCreateIndexesOnStartup(); log.debug("AerospikeDataSettings.indexesOnStartup: {}", indexesOnStartup); return new ReactiveAerospikePersistenceEntityIndexCreator(aerospikeMappingContext, indexesOnStartup, aerospikeIndexResolver, template); diff --git a/src/main/java/org/springframework/data/aerospike/config/AerospikeConnectionSettings.java b/src/main/java/org/springframework/data/aerospike/config/AerospikeConnectionSettings.java new file mode 100644 index 000000000..13b4d675b --- /dev/null +++ b/src/main/java/org/springframework/data/aerospike/config/AerospikeConnectionSettings.java @@ -0,0 +1,37 @@ +/* + * Copyright 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.aerospike.config; + +import com.aerospike.client.Host; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class AerospikeConnectionSettings { + + // String of hosts separated by ',' in form of hostname1[:tlsName1]:port1,... + // An IP address must be given in one of the following formats: + // IPv4: xxx.xxx.xxx.xxx + // IPv6: [xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx] + // IPv6: [xxxx::xxxx] + // IPv6 addresses must be enclosed by brackets. tlsName is optional. + String hosts; + // Namespace + String namespace; + // Storing hosts + Host[] hostsArray; +} 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 c2709a1ca..6a89cded1 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java +++ b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java @@ -21,6 +21,7 @@ import com.aerospike.client.policy.ClientPolicy; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; import org.springframework.context.annotation.Configuration; @@ -71,9 +72,10 @@ public IndexesCacheHolder indexCache() { @Bean(name = "mappingAerospikeConverter") public MappingAerospikeConverter mappingAerospikeConverter(AerospikeMappingContext aerospikeMappingContext, AerospikeTypeAliasAccessor aerospikeTypeAliasAccessor, - AerospikeCustomConversions customConversions) { + AerospikeCustomConversions customConversions, + AerospikeSettings settings) { return new MappingAerospikeConverter(aerospikeMappingContext, customConversions, aerospikeTypeAliasAccessor, - aerospikeDataSettings()); + settings.getDataSettings()); } @Bean(name = "aerospikeTypeAliasAccessor") @@ -105,9 +107,12 @@ public AerospikeExceptionTranslator aerospikeExceptionTranslator() { } @Bean(name = "aerospikeClient", destroyMethod = "close") - public AerospikeClient aerospikeClient() { - Collection hosts = getHosts(); - return new AerospikeClient(getClientPolicy(), hosts.toArray(new Host[0])); + public AerospikeClient aerospikeClient(AerospikeSettings settings) { + return new AerospikeClient(getClientPolicy(), settings.getConnectionSettings().getHostsArray()); + } + + protected int getDefaultPort() { + return 3000; } @Bean(name = "filterExpressionsBuilder") @@ -122,9 +127,9 @@ public AerospikeIndexResolver aerospikeIndexResolver() { } @Bean(name = "aerospikeServerVersionSupport") - public ServerVersionSupport serverVersionSupport(IAerospikeClient aerospikeClient) { + public ServerVersionSupport serverVersionSupport(IAerospikeClient aerospikeClient, AerospikeSettings settings) { ServerVersionSupport serverVersionSupport = new ServerVersionSupport(aerospikeClient); - int serverVersionRefreshFrequency = aerospikeDataSettings().getServerVersionRefreshSeconds(); + int serverVersionRefreshFrequency = settings.getDataSettings().getServerVersionRefreshSeconds(); processServerVersionRefreshFrequency(serverVersionRefreshFrequency, serverVersionSupport); return serverVersionSupport; } @@ -168,20 +173,33 @@ protected FieldNamingStrategy fieldNamingStrategy() { return PropertyNameFieldNamingStrategy.INSTANCE; } - protected abstract Collection getHosts(); - - protected abstract String nameSpace(); + /** + * Override this method to define the hosts to be used. + *

The return value of this method overrides the value of the 'hosts' parameter from application.properties. + * + * @return Collection of Host objects for Aerospike client to connect + */ + protected Collection getHosts() { + return null; + } - protected AerospikeDataSettings aerospikeDataSettings() { - AerospikeDataSettings.AerospikeDataSettingsBuilder builder = AerospikeDataSettings.builder(); - configureDataSettings(builder); - return builder.build(); + /** + * Override this method to define the namespace to be used. + *

The return value of this method overrides the value of the 'namespace' parameter from application.properties. + * + * @return Collection of Host objects for Aerospike client to connect + */ + protected String nameSpace() { + return null; } - protected void configureDataSettings(AerospikeDataSettings.AerospikeDataSettingsBuilder builder) { - builder.scansEnabled(false); - builder.sendKey(true); - builder.createIndexesOnStartup(true); + /** + * Override this method to define data settings to be used. + * + *

The return value of this method overrides the values of 'spring-data-aerospike.data.*' parameters + * from application.properties. + */ + protected void configureDataSettings(AerospikeDataSettings aerospikeDataSettings) { } /** @@ -196,9 +214,44 @@ protected ClientPolicy getClientPolicy() { ClientPolicy clientPolicy = new ClientPolicy(); clientPolicy.failIfNotConnected = true; clientPolicy.timeout = 10_000; - clientPolicy.writePolicyDefault.sendKey = aerospikeDataSettings().isSendKey(); - clientPolicy.readPolicyDefault.sendKey = aerospikeDataSettings().isSendKey(); - log.debug("AerospikeDataSettings.sendKey: {}", clientPolicy.writePolicyDefault.sendKey); + clientPolicy.readPolicyDefault.sendKey = true; + clientPolicy.writePolicyDefault.sendKey = true; + clientPolicy.batchPolicyDefault.sendKey = true; return clientPolicy; } + + @Bean + @ConfigurationProperties(prefix = "spring-data-aerospike.data") + public AerospikeDataSettings readAerospikeDataSettings() { + return new AerospikeDataSettings(); + } + + @Bean + @ConfigurationProperties(prefix = "spring-data-aerospike.connection") + public AerospikeConnectionSettings readAerospikeSettings() { + return new AerospikeConnectionSettings(); + } + + @Bean + protected AerospikeSettings aerospikeSettings(AerospikeDataSettings dataSettings, + AerospikeConnectionSettings connectionSettings) { + // values set via configureDataSettings() have precedence over the parameters from application.properties + configureDataSettings(dataSettings); + + // getHosts() return value has precedence over hosts parameter from application.properties + Collection hosts; + if ((hosts = getHosts()) != null) { + connectionSettings.setHostsArray(hosts.toArray(new Host[0])); + } else if (!StringUtils.hasText(connectionSettings.getHosts())) { + throw new IllegalStateException("No hosts found, please set hosts parameter in application.properties or " + + "override getHosts() method"); + } + connectionSettings.setHostsArray(Host.parseHosts(connectionSettings.getHosts(), getDefaultPort())); + + // nameSpace() return value has precedence over namespace parameter from application.properties + String namespace; + if ((namespace = nameSpace()) != null) connectionSettings.setNamespace(namespace); + + return new AerospikeSettings(connectionSettings, dataSettings); + } } diff --git a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataSettings.java b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataSettings.java index 2fa76f6a7..7246a964e 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataSettings.java +++ b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 the original author or authors. + * Copyright 2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,47 +15,26 @@ */ package org.springframework.data.aerospike.config; -import lombok.Builder; -import lombok.Value; +import lombok.Getter; +import lombok.Setter; -@Builder -@Value +@Setter +@Getter public class AerospikeDataSettings { - @Builder.Default // Enable scan operation boolean scansEnabled = false; - @Builder.Default - // Send user defined key in addition to hash digest on both reads and writes - boolean sendKey = true; - @Builder.Default // Create secondary indexes specified using `@Indexed` annotation on startup boolean createIndexesOnStartup = true; - @Builder.Default // Automatically refresh indexes cache every seconds int indexCacheRefreshSeconds = 3600; - @Builder.Default // Automatically refresh cached server version every seconds int serverVersionRefreshSeconds = 3600; - @Builder.Default // Limit amount of results returned by server. Non-positive value means no limit long queryMaxRecords = 10_000L; - @Builder.Default // Maximum batch size for batch write operations int batchWriteSize = 100; // Define how @Id fields (primary keys) and Map keys are stored: false - always as String, // true - preserve original type if supported - @Builder.Default boolean keepOriginalKeyTypes = false; - - /* - * (non-Javadoc) - * Javadoc is not aware of the code modifications made by Lombok. - * You can fix it with either delombok or by adding a static inner class inside the class that uses the @Builder - * annotation, - * it will satisfy javadoc and won't interfere with the @Builder annotation's normal behaviour. - */ - public static class AerospikeDataSettingsBuilder { - - } } diff --git a/src/main/java/org/springframework/data/aerospike/config/AerospikeSettings.java b/src/main/java/org/springframework/data/aerospike/config/AerospikeSettings.java new file mode 100644 index 000000000..1882f955b --- /dev/null +++ b/src/main/java/org/springframework/data/aerospike/config/AerospikeSettings.java @@ -0,0 +1,28 @@ +/* + * Copyright 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.aerospike.config; + +import lombok.Data; + +/** + * Class that holds configuration settings + */ +@Data +public class AerospikeSettings { + + final AerospikeConnectionSettings connectionSettings; + final AerospikeDataSettings dataSettings; +} diff --git a/src/main/java/org/springframework/data/aerospike/convert/AerospikeConverter.java b/src/main/java/org/springframework/data/aerospike/convert/AerospikeConverter.java index 8365f75ba..f50f67419 100644 --- a/src/main/java/org/springframework/data/aerospike/convert/AerospikeConverter.java +++ b/src/main/java/org/springframework/data/aerospike/convert/AerospikeConverter.java @@ -38,5 +38,5 @@ public interface AerospikeConverter extends AerospikeReader, AerospikeWr * * @return the underlying {@link AerospikeDataSettings} used by the converter */ - AerospikeDataSettings getAerospikeDataSettings(); + AerospikeDataSettings getAerospikeSettings(); } diff --git a/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeConverter.java b/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeConverter.java index e8417bc01..575135cbb 100644 --- a/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeConverter.java +++ b/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeConverter.java @@ -43,7 +43,7 @@ public class MappingAerospikeConverter implements InitializingBean, AerospikeCon @Getter private final GenericConversionService conversionService; @Getter - private final AerospikeDataSettings aerospikeDataSettings; + private final AerospikeDataSettings aerospikeSettings; private final MappingAerospikeReadConverter readConverter; private final MappingAerospikeWriteConverter writeConverter; @@ -52,10 +52,10 @@ public class MappingAerospikeConverter implements InitializingBean, AerospikeCon */ public MappingAerospikeConverter(AerospikeMappingContext mappingContext, CustomConversions conversions, AerospikeTypeAliasAccessor aerospikeTypeAliasAccessor, - AerospikeDataSettings aerospikeDataSettings) { + AerospikeDataSettings settings) { this.conversions = conversions; this.conversionService = new DefaultConversionService(); - this.aerospikeDataSettings = aerospikeDataSettings; + this.aerospikeSettings = settings; EntityInstantiators entityInstantiators = new EntityInstantiators(); TypeMapper> typeMapper = new DefaultTypeMapper<>(aerospikeTypeAliasAccessor, @@ -63,7 +63,7 @@ public MappingAerospikeConverter(AerospikeMappingContext mappingContext, CustomC this.writeConverter = new MappingAerospikeWriteConverter(typeMapper, mappingContext, conversions, conversionService, - aerospikeDataSettings); + settings); this.readConverter = new MappingAerospikeReadConverter(entityInstantiators, aerospikeTypeAliasAccessor, typeMapper, mappingContext, conversions, conversionService); } diff --git a/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeWriteConverter.java b/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeWriteConverter.java index 34e63dae3..e865fb119 100644 --- a/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeWriteConverter.java +++ b/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeWriteConverter.java @@ -53,17 +53,17 @@ public class MappingAerospikeWriteConverter implements EntityWriter> typeMapper, AerospikeMappingContext mappingContext, CustomConversions conversions, GenericConversionService conversionService, - AerospikeDataSettings aerospikeDataSettings) { + AerospikeDataSettings settings) { this.typeMapper = typeMapper; this.mappingContext = mappingContext; this.conversions = conversions; this.conversionService = conversionService; - this.aerospikeDataSettings = aerospikeDataSettings; + this.settings = settings; } private static Collection asCollection(final Object source) { @@ -124,7 +124,7 @@ public Optional getNewKey(AerospikeWriteData data, String setName = Optional.ofNullable(data.getSetName()).orElse(entity.getSetName()); // Store record key as it is (if Aerospike supports it natively and configured) - if (aerospikeDataSettings.isKeepOriginalKeyTypes() + if (settings.isKeepOriginalKeyTypes() && isValidAerospikeRecordKeyType(idProperty.getType())) { log.debug("Attempt to construct record key with original key type"); Object nativeTypeId = accessor.getProperty(idProperty, idProperty.getType()); @@ -247,7 +247,7 @@ protected Map convertMap(final Map source, final Object simpleKey; - if (aerospikeDataSettings.isKeepOriginalKeyTypes() && + if (settings.isKeepOriginalKeyTypes() && isValidAerospikeMapKeyType(key.getClass())) { simpleKey = key; } else { diff --git a/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java b/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java index a1bd30b88..48f41724f 100644 --- a/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java @@ -173,7 +173,7 @@ public void saveAll(Iterable documents, String setName) { } private void applyBufferedBatchWrite(Iterable documents, String setName, OperationType operationType) { - int batchSize = converter.getAerospikeDataSettings().getBatchWriteSize(); + int batchSize = converter.getAerospikeSettings().getBatchWriteSize(); List docsList = new ArrayList<>(); for (T doc : documents) { @@ -456,7 +456,7 @@ public boolean deleteById(Object id, String setName) { public void deleteAll(Iterable documents) { String setName = getSetName(documents.iterator().next()); - int batchSize = converter.getAerospikeDataSettings().getBatchWriteSize(); + int batchSize = converter.getAerospikeSettings().getBatchWriteSize(); List documentsList = new ArrayList<>(); for (Object document : documents) { if (batchWriteSizeMatch(batchSize, documentsList.size())) { @@ -491,7 +491,7 @@ public void deleteByIds(Iterable ids, Class entityClass) { Assert.notNull(setName, "Set name must not be null!"); validateForBatchWrite(ids, "IDs"); - int batchSize = converter.getAerospikeDataSettings().getBatchWriteSize(); + int batchSize = converter.getAerospikeSettings().getBatchWriteSize(); List idsList = new ArrayList<>(); for (Object id : ids) { if (batchWriteSizeMatch(batchSize, idsList.size())) { @@ -885,7 +885,7 @@ public List findByIds(Iterable ids, Class entityClass, Class Assert.notNull(entityClass, "Entity class must not be null!"); Assert.notNull(setName, "Set name must not be null!"); - int batchSize = converter.getAerospikeDataSettings().getBatchWriteSize(); + int batchSize = converter.getAerospikeSettings().getBatchWriteSize(); List idsList = new ArrayList<>(); List result = new ArrayList<>(); 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 8d2d83e61..bc609c440 100644 --- a/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java @@ -314,7 +314,7 @@ Key getKey(Object id, String setName) { Assert.notNull(setName, "Set name must not be null!"); Key key; // choosing whether tp preserve id type based on the configuration - if (converter.getAerospikeDataSettings().isKeepOriginalKeyTypes()) { + if (converter.getAerospikeSettings().isKeepOriginalKeyTypes()) { if (id instanceof Byte || id instanceof Short || id instanceof Integer || id instanceof Long) { key = new Key(this.namespace, setName, convertIfNecessary(((Number) id).longValue(), Long.class)); } else if (id instanceof Character) { diff --git a/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java b/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java index 86b278348..092da22e7 100644 --- a/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java @@ -160,7 +160,7 @@ public Flux saveAll(Iterable documents, String setName) { private Flux applyBufferedBatchWrite(Iterable documents, String setName, OperationType operationType) { - int batchSize = converter.getAerospikeDataSettings().getBatchWriteSize(); + int batchSize = converter.getAerospikeSettings().getBatchWriteSize(); List docsList = new ArrayList<>(); Flux result = Flux.empty(); @@ -477,7 +477,7 @@ public Mono deleteByIds(Iterable ids, String setName) { Assert.notNull(setName, "Set name must not be null!"); validateForBatchWrite(ids, "IDs"); - int batchSize = converter.getAerospikeDataSettings().getBatchWriteSize(); + int batchSize = converter.getAerospikeSettings().getBatchWriteSize(); List idsList = new ArrayList<>(); Flux result = Flux.empty(); for (Object id : ids) { @@ -786,7 +786,7 @@ public Flux findByIds(Iterable ids, Class targetClass, String setNa Assert.notNull(targetClass, "Class must not be null!"); Assert.notNull(setName, "Set name must not be null!"); - int batchSize = converter.getAerospikeDataSettings().getBatchWriteSize(); + int batchSize = converter.getAerospikeSettings().getBatchWriteSize(); List idsList = new ArrayList<>(); Flux result = Flux.empty(); diff --git a/src/main/java/org/springframework/data/aerospike/query/FilterOperation.java b/src/main/java/org/springframework/data/aerospike/query/FilterOperation.java index 0ef8fc2a9..0dffa7d7a 100644 --- a/src/main/java/org/springframework/data/aerospike/query/FilterOperation.java +++ b/src/main/java/org/springframework/data/aerospike/query/FilterOperation.java @@ -1490,7 +1490,7 @@ private static Exp getMapKeyExp(Object mapKey, boolean keepOriginalKeyTypes) { private static boolean keepOriginalKeyTypes(Map qualifierMap) { return ((MappingAerospikeConverter) qualifierMap.get(CONVERTER)) - .getAerospikeDataSettings().isKeepOriginalKeyTypes(); + .getAerospikeSettings().isKeepOriginalKeyTypes(); } private static Exp getFilterExpMapValEqOrFail(Map qualifierMap, BinaryOperator operator) { diff --git a/src/main/java/org/springframework/data/aerospike/query/QueryEngine.java b/src/main/java/org/springframework/data/aerospike/query/QueryEngine.java index 1be9fe7e4..8dfcf7d52 100644 --- a/src/main/java/org/springframework/data/aerospike/query/QueryEngine.java +++ b/src/main/java/org/springframework/data/aerospike/query/QueryEngine.java @@ -42,8 +42,7 @@ public class QueryEngine { public static final String SCANS_DISABLED_MESSAGE = "Query without a filter will initiate a scan. Since scans are potentially dangerous operations, they are " + "disabled by default in spring-data-aerospike. " + - "If you still need to use them, enable them via `scansEnabled` property in `org.springframework.data" + - ".aerospike.config.AerospikeDataSettings`."; + "If you still need to use them, enable them via `scans-enabled` property."; private final IAerospikeClient client; private final StatementBuilder statementBuilder; @Getter diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 000000000..810ce0dcf --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,9 @@ +spring-data-aerospike.connection.hosts=localhost:3000 +spring-data-aerospike.connection.namespace=test +spring-data-aerospike.data.scans-enabled=false +spring-data-aerospike.data.create-indexes-on-startup=true +spring-data-aerospike.data.index-cache-refresh-seconds=3600 +spring-data-aerospike.data.server-version-refresh-seconds=3600 +spring-data-aerospike.data.query-max-records=10000 +spring-data-aerospike.data.batch-write-size=100 +spring-data-aerospike.data.keep-original-key-types=false \ No newline at end of file diff --git a/src/test/java/org/springframework/data/aerospike/BaseBlockingIntegrationTests.java b/src/test/java/org/springframework/data/aerospike/BaseBlockingIntegrationTests.java index 13e8d514a..9563f98bc 100644 --- a/src/test/java/org/springframework/data/aerospike/BaseBlockingIntegrationTests.java +++ b/src/test/java/org/springframework/data/aerospike/BaseBlockingIntegrationTests.java @@ -3,6 +3,7 @@ import com.aerospike.client.IAerospikeClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.env.Environment; import org.springframework.data.aerospike.config.BlockingTestConfig; import org.springframework.data.aerospike.config.CommonTestConfig; import org.springframework.data.aerospike.core.AerospikeTemplate; @@ -41,6 +42,8 @@ public abstract class BaseBlockingIntegrationTests extends BaseIntegrationTests protected IndexesCache indexesCache; @Autowired protected IndexRefresher indexRefresher; + @Autowired + protected Environment env; protected void deleteOneByOne(Collection collection) { collection.forEach(item -> template.delete(item)); diff --git a/src/test/java/org/springframework/data/aerospike/BaseIntegrationTests.java b/src/test/java/org/springframework/data/aerospike/BaseIntegrationTests.java index b7436a64a..f7f72c2e2 100644 --- a/src/test/java/org/springframework/data/aerospike/BaseIntegrationTests.java +++ b/src/test/java/org/springframework/data/aerospike/BaseIntegrationTests.java @@ -13,7 +13,7 @@ public abstract class BaseIntegrationTests { public static final String OVERRIDE_SET_NAME = "testSet1"; protected static final int MILLIS_TO_NANO = 1_000_000; - @Value("${embedded.aerospike.namespace}") + @Value("${spring-data-aerospike.connection.namespace}") protected String namespace; protected String id; diff --git a/src/test/java/org/springframework/data/aerospike/PoliciesVerificationTests.java b/src/test/java/org/springframework/data/aerospike/PoliciesVerificationTests.java index 3419fbc81..292c730e1 100644 --- a/src/test/java/org/springframework/data/aerospike/PoliciesVerificationTests.java +++ b/src/test/java/org/springframework/data/aerospike/PoliciesVerificationTests.java @@ -1,13 +1,9 @@ package org.springframework.data.aerospike; import org.junit.jupiter.api.Test; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class PoliciesVerificationTests extends BaseBlockingIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/assertions/KeyAssert.java b/src/test/java/org/springframework/data/aerospike/assertions/KeyAssert.java index 7bdff2b80..5b200a956 100644 --- a/src/test/java/org/springframework/data/aerospike/assertions/KeyAssert.java +++ b/src/test/java/org/springframework/data/aerospike/assertions/KeyAssert.java @@ -17,7 +17,7 @@ public static KeyAssert assertThat(Key key) { } @SuppressWarnings("UnusedReturnValue") - public KeyAssert consistsOf(AerospikeDataSettings aerospikeDataSettings, String namespace, String setName, + public KeyAssert consistsOf(AerospikeDataSettings settings, String namespace, String setName, Object expectedUserKey) { if (!actual.namespace.equals(namespace)) { throw new IllegalArgumentException("Inconsistent namespace name"); @@ -26,7 +26,7 @@ public KeyAssert consistsOf(AerospikeDataSettings aerospikeDataSettings, String throw new IllegalArgumentException("Inconsistent setName"); } - if (aerospikeDataSettings != null && aerospikeDataSettings.isKeepOriginalKeyTypes()) { + if (settings != null && settings.isKeepOriginalKeyTypes()) { Assertions.assertThat(verifyActualUserKeyType(expectedUserKey)).isTrue(); } else { // String type is used for unsupported Aerospike key types and previously for all key types in older diff --git a/src/test/java/org/springframework/data/aerospike/cache/AerospikeCacheManagerIntegrationTests.java b/src/test/java/org/springframework/data/aerospike/cache/AerospikeCacheManagerIntegrationTests.java index 04e003c65..d556ab5fa 100644 --- a/src/test/java/org/springframework/data/aerospike/cache/AerospikeCacheManagerIntegrationTests.java +++ b/src/test/java/org/springframework/data/aerospike/cache/AerospikeCacheManagerIntegrationTests.java @@ -28,14 +28,10 @@ import org.springframework.data.aerospike.core.AerospikeOperations; import org.springframework.data.aerospike.utility.AwaitilityUtils; import org.springframework.data.annotation.Id; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.utility.AwaitilityUtils.awaitTenSecondsUntil; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeCacheManagerIntegrationTests extends BaseBlockingIntegrationTests { private static final String KEY = "foo"; diff --git a/src/test/java/org/springframework/data/aerospike/cache/AerospikeCacheManagerTests.java b/src/test/java/org/springframework/data/aerospike/cache/AerospikeCacheManagerTests.java index 3c7e86cb7..9181731bd 100644 --- a/src/test/java/org/springframework/data/aerospike/cache/AerospikeCacheManagerTests.java +++ b/src/test/java/org/springframework/data/aerospike/cache/AerospikeCacheManagerTests.java @@ -18,29 +18,21 @@ import com.aerospike.client.IAerospikeClient; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.Cache; import org.springframework.cache.transaction.TransactionAwareCacheDecorator; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.convert.MappingAerospikeConverter; -import org.springframework.test.context.TestPropertySource; import java.util.HashMap; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * @author Venil Noronha */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeCacheManagerTests extends BaseBlockingIntegrationTests { - @Value("${embedded.aerospike.namespace}") - public String namespace; - @Autowired IAerospikeClient client; @Autowired diff --git a/src/test/java/org/springframework/data/aerospike/config/BlockingTestConfig.java b/src/test/java/org/springframework/data/aerospike/config/BlockingTestConfig.java index 0dfd9ba4b..185d04cc3 100644 --- a/src/test/java/org/springframework/data/aerospike/config/BlockingTestConfig.java +++ b/src/test/java/org/springframework/data/aerospike/config/BlockingTestConfig.java @@ -1,10 +1,8 @@ package org.springframework.data.aerospike.config; -import com.aerospike.client.Host; import com.aerospike.client.IAerospikeClient; import com.aerospike.client.policy.ClientPolicy; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.core.env.Environment; import org.springframework.data.aerospike.BlockingAerospikeTestOperations; @@ -19,13 +17,7 @@ import org.testcontainers.containers.GenericContainer; import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; import java.util.List; -import java.util.Optional; - -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -import static org.springframework.data.aerospike.utility.Utils.getIntegerProperty; /** * @author Peter Milne @@ -34,13 +26,6 @@ @EnableAerospikeRepositories(basePackageClasses = {ContactRepository.class, CustomerRepository.class}) public class BlockingTestConfig extends AbstractAerospikeDataConfiguration { - @Value("${embedded.aerospike.namespace}") - protected String namespace; - @Value("${embedded.aerospike.host}") - protected String host; - @Value("${embedded.aerospike.port}") - protected int port; - @Autowired Environment env; @@ -52,26 +37,6 @@ protected List customConverters() { ); } - @Override - protected Collection getHosts() { - return Collections.singleton(new Host(host, port)); - } - - @Override - protected String nameSpace() { - return namespace; - } - - @Override - protected void configureDataSettings(AerospikeDataSettings.AerospikeDataSettingsBuilder builder) { - builder.scansEnabled(true); - boolean indexesOnStartup = Boolean.parseBoolean(env.getProperty("createIndexesOnStartup")); - builder.createIndexesOnStartup(indexesOnStartup); - Optional indexRefreshFrequency = getIntegerProperty(env.getProperty(INDEX_CACHE_REFRESH_SECONDS)); - indexRefreshFrequency.ifPresent(builder::indexCacheRefreshSeconds); - builder.queryMaxRecords(5000L); - } - @Override protected ClientPolicy getClientPolicy() { ClientPolicy clientPolicy = super.getClientPolicy(); // applying default values first diff --git a/src/test/java/org/springframework/data/aerospike/config/CommonTestConfig.java b/src/test/java/org/springframework/data/aerospike/config/CommonTestConfig.java index 98524d02c..615439412 100644 --- a/src/test/java/org/springframework/data/aerospike/config/CommonTestConfig.java +++ b/src/test/java/org/springframework/data/aerospike/config/CommonTestConfig.java @@ -42,7 +42,7 @@ @EnableAutoConfiguration public class CommonTestConfig { - @Value("${embedded.aerospike.namespace}") + @Value("${spring-data-aerospike.connection.namespace}") protected String namespace; @Bean diff --git a/src/test/java/org/springframework/data/aerospike/config/ReactiveTestConfig.java b/src/test/java/org/springframework/data/aerospike/config/ReactiveTestConfig.java index 991d94f73..14ecb8284 100644 --- a/src/test/java/org/springframework/data/aerospike/config/ReactiveTestConfig.java +++ b/src/test/java/org/springframework/data/aerospike/config/ReactiveTestConfig.java @@ -1,6 +1,5 @@ package org.springframework.data.aerospike.config; -import com.aerospike.client.Host; import com.aerospike.client.IAerospikeClient; import com.aerospike.client.async.EventLoops; import com.aerospike.client.async.EventPolicy; @@ -12,7 +11,6 @@ import io.netty.channel.kqueue.KQueueEventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.core.env.Environment; import org.springframework.data.aerospike.ReactiveBlockingAerospikeTestOperations; @@ -26,14 +24,8 @@ import org.testcontainers.containers.GenericContainer; import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Locale; -import java.util.Optional; - -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -import static org.springframework.data.aerospike.utility.Utils.getIntegerProperty; /** * @author Peter Milne @@ -42,13 +34,6 @@ @EnableReactiveAerospikeRepositories(basePackageClasses = {ReactiveCustomerRepository.class}) public class ReactiveTestConfig extends AbstractReactiveAerospikeDataConfiguration { - @Value("${embedded.aerospike.namespace}") - protected String namespace; - @Value("${embedded.aerospike.host}") - protected String host; - @Value("${embedded.aerospike.port}") - protected int port; - @Autowired Environment env; @@ -60,16 +45,6 @@ protected List customConverters() { ); } - @Override - protected Collection getHosts() { - return Collections.singleton(new Host(host, port)); - } - - @Override - protected String nameSpace() { - return namespace; - } - @Override protected EventLoops eventLoops() { int nThreads = Math.max(2, Runtime.getRuntime().availableProcessors() * 2); @@ -90,16 +65,6 @@ protected EventLoops eventLoops() { return new NettyEventLoops(eventPolicy, eventLoopGroup); } - @Override - protected void configureDataSettings(AerospikeDataSettings.AerospikeDataSettingsBuilder builder) { - builder.scansEnabled(true); - boolean indexesOnStartup = Boolean.parseBoolean(env.getProperty("createIndexesOnStartup")); - builder.createIndexesOnStartup(indexesOnStartup); - Optional indexRefreshFrequency = getIntegerProperty(env.getProperty(INDEX_CACHE_REFRESH_SECONDS)); - indexRefreshFrequency.ifPresent(builder::indexCacheRefreshSeconds); - builder.queryMaxRecords(5000L); - } - @Bean public AdditionalAerospikeTestOperations aerospikeOperations(ReactiveAerospikeTemplate template, IAerospikeClient client, diff --git a/src/test/java/org/springframework/data/aerospike/convert/AerospikeReadDataIntegrationTests.java b/src/test/java/org/springframework/data/aerospike/convert/AerospikeReadDataIntegrationTests.java index 2d89a81be..8e2b7bef3 100644 --- a/src/test/java/org/springframework/data/aerospike/convert/AerospikeReadDataIntegrationTests.java +++ b/src/test/java/org/springframework/data/aerospike/convert/AerospikeReadDataIntegrationTests.java @@ -51,7 +51,7 @@ void readDocumentWithLongId() { // we can read the record into a User document because its class is given List users = template.findAll(User.class).toList(); User user; - if (template.getAerospikeConverter().getAerospikeDataSettings().isKeepOriginalKeyTypes()) { + if (template.getAerospikeConverter().getAerospikeSettings().isKeepOriginalKeyTypes()) { // we need isKeepOriginalKeyTypes == true because id is of type long, otherwise findById() returns null // isKeepOriginalKeyTypes parameter would be unimportant if id were of type String user = template.findById(longId, User.class); @@ -85,7 +85,7 @@ void readLongIdAsString() { // we can read the record into a Document because its class is given List users = template.findAll(Document.class).toList(); Document document; - if (template.getAerospikeConverter().getAerospikeDataSettings().isKeepOriginalKeyTypes()) { + if (template.getAerospikeConverter().getAerospikeSettings().isKeepOriginalKeyTypes()) { // original id has type long document = template.findById(longId, Document.class); assertThat(users.get(0).getId()).isEqualTo(document.getId()); diff --git a/src/test/java/org/springframework/data/aerospike/convert/AerospikeReadDataTest.java b/src/test/java/org/springframework/data/aerospike/convert/AerospikeReadDataTest.java index 53f8d5963..7cfac8b36 100644 --- a/src/test/java/org/springframework/data/aerospike/convert/AerospikeReadDataTest.java +++ b/src/test/java/org/springframework/data/aerospike/convert/AerospikeReadDataTest.java @@ -6,15 +6,11 @@ import com.aerospike.client.Key; import com.aerospike.client.Record; import org.junit.jupiter.api.Test; -import org.springframework.test.context.TestPropertySource; import java.util.Collections; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeReadDataTest { @Test diff --git a/src/test/java/org/springframework/data/aerospike/convert/BaseMappingAerospikeConverterTest.java b/src/test/java/org/springframework/data/aerospike/convert/BaseMappingAerospikeConverterTest.java index 6df7af938..ba2f8d4c9 100644 --- a/src/test/java/org/springframework/data/aerospike/convert/BaseMappingAerospikeConverterTest.java +++ b/src/test/java/org/springframework/data/aerospike/convert/BaseMappingAerospikeConverterTest.java @@ -22,17 +22,23 @@ public abstract class BaseMappingAerospikeConverterTest { protected static final String NAMESPACE = "namespace"; - public final AerospikeDataSettings aerospikeDataSettings = AerospikeDataSettings.builder().build(); - public final AerospikeDataSettings aerospikeDataSettingsReversedKeyTypesOption = AerospikeDataSettings.builder() - .keepOriginalKeyTypes(!aerospikeDataSettings.isKeepOriginalKeyTypes()).build(); + public final AerospikeDataSettings settings = new AerospikeDataSettings(); + public final AerospikeDataSettings settingsReversedKeyTypesOption = + getAerospikeSettings(!settings.isKeepOriginalKeyTypes()); + + private AerospikeDataSettings getAerospikeSettings(boolean keepOriginalKeyTypes) { + AerospikeDataSettings settings = new AerospikeDataSettings(); + settings.setKeepOriginalKeyTypes(keepOriginalKeyTypes); + return settings; + } protected final MappingAerospikeConverter converter = getMappingAerospikeConverter( - aerospikeDataSettings, + settings, new SampleClasses.ComplexIdToStringConverter(), new SampleClasses.StringToComplexIdConverter()); protected final MappingAerospikeConverter converterReversedKeyTypes = getMappingAerospikeConverter( - aerospikeDataSettingsReversedKeyTypesOption, + settingsReversedKeyTypesOption, new SampleClasses.ComplexIdToStringConverter(), new SampleClasses.StringToComplexIdConverter()); @@ -53,20 +59,20 @@ protected MappingAerospikeConverter getAerospikeMappingConverterByOption(int con return converterReversedKeyTypes; } - protected MappingAerospikeConverter getMappingAerospikeConverter(AerospikeDataSettings aerospikeDataSettings, + protected MappingAerospikeConverter getMappingAerospikeConverter(AerospikeDataSettings settings, Converter... customConverters) { - return getMappingAerospikeConverter(aerospikeDataSettings, new AerospikeTypeAliasAccessor(), customConverters); + return getMappingAerospikeConverter(settings, new AerospikeTypeAliasAccessor(), customConverters); } - protected MappingAerospikeConverter getMappingAerospikeConverter(AerospikeDataSettings aerospikeDataSettings, - AerospikeTypeAliasAccessor typeAliasAccessor, - Converter... customConverters) { + protected MappingAerospikeConverter getMappingAerospikeConverter(AerospikeDataSettings settings, + AerospikeTypeAliasAccessor typeAliasAccessor, + Converter... customConverters) { AerospikeMappingContext mappingContext = new AerospikeMappingContext(); mappingContext.setApplicationContext(getApplicationContext()); CustomConversions customConversions = new AerospikeCustomConversions(asList(customConverters)); MappingAerospikeConverter converter = new MappingAerospikeConverter(mappingContext, customConversions, - typeAliasAccessor, aerospikeDataSettings); + typeAliasAccessor, settings); converter.afterPropertiesSet(); return converter; } diff --git a/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTests.java b/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTests.java index ac18dacfa..21d7f59dd 100644 --- a/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTests.java +++ b/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTests.java @@ -119,7 +119,7 @@ public void usesDocumentsStoredTypeIfSubtypeOfRequest(int converterOption) { @Test public void shouldWriteAndReadUsingCustomConverter() { MappingAerospikeConverter converter = - getMappingAerospikeConverter(aerospikeDataSettings, new UserToAerospikeWriteDataConverter(), + getMappingAerospikeConverter(settings, new UserToAerospikeWriteDataConverter(), new AerospikeReadDataToUserConverter()); AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); @@ -146,7 +146,7 @@ class TestName { } MappingAerospikeConverter converter = - getMappingAerospikeConverter(aerospikeDataSettings, new UserToAerospikeWriteDataConverter(), + getMappingAerospikeConverter(settings, new UserToAerospikeWriteDataConverter(), new AerospikeReadDataToUserConverter()); AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); @@ -159,7 +159,7 @@ class TestName { @Test public void shouldWriteAndReadUsingCustomConverterOnNestedMapKeyObject() { MappingAerospikeConverter converter = - getMappingAerospikeConverter(aerospikeDataSettings, new SampleClasses.SomeIdToStringConverter(), + getMappingAerospikeConverter(settings, new SampleClasses.SomeIdToStringConverter(), new SampleClasses.StringToSomeIdConverter()); AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); @@ -187,7 +187,7 @@ public void shouldWriteAndReadUsingCustomConverterOnNestedMapKeyObject() { entityMapExpectedAfterConversion.put(newSomeIdAsStringKey, newEntityMap); } - assertThat(forWrite.getKey()).consistsOf(aerospikeDataSettings, "namespace", + assertThat(forWrite.getKey()).consistsOf(settings, "namespace", "DocumentExample", "someKey1"); assertThat(forWrite.getBins().stream() .filter(x -> !x.name.equals("@_class"))).containsOnly(new Bin("entityMap", @@ -203,13 +203,13 @@ public void shouldWriteAndReadUsingCustomConverterOnNestedMapKeyObject() { @Test public void shouldWriteAndReadIfTypeKeyIsNull() { MappingAerospikeConverter converter = - getMappingAerospikeConverter(aerospikeDataSettings, new AerospikeTypeAliasAccessor(null)); + getMappingAerospikeConverter(settings, new AerospikeTypeAliasAccessor(null)); AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); User user = new User(678L, null, null); converter.write(user, forWrite); - assertThat(forWrite.getKey()).consistsOf(aerospikeDataSettings, NAMESPACE, SIMPLESET3, user.getId()); + assertThat(forWrite.getKey()).consistsOf(settings, NAMESPACE, SIMPLESET3, user.getId()); } @ParameterizedTest() @@ -409,7 +409,7 @@ public void shouldReadObjectWithByteArrayFieldWithOneValueInData(int converterOp @Test public void getConversionService() { MappingAerospikeConverter mappingAerospikeConverter = - getMappingAerospikeConverter(aerospikeDataSettings, new AerospikeTypeAliasAccessor()); + getMappingAerospikeConverter(settings, new AerospikeTypeAliasAccessor()); assertThat(mappingAerospikeConverter.getConversionService()).isNotNull() .isInstanceOf(DefaultConversionService.class); } diff --git a/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTypesTests.java b/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTypesTests.java index 95eb95eb8..619fab56f 100644 --- a/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTypesTests.java +++ b/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTypesTests.java @@ -716,7 +716,7 @@ void objectWithByteArrayFieldWithOneValueInData(int converterOption) { @Test void shouldWriteAsArrayListAndReadAsByteArray() { MappingAerospikeConverter converter = - getMappingAerospikeConverter(aerospikeDataSettings, new AerospikeTypeAliasAccessor(null)); + getMappingAerospikeConverter(settings, new AerospikeTypeAliasAccessor(null)); AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); DocumentWithByteArrayList docToWrite = new DocumentWithByteArrayList("user-id", Arrays.asList((byte) 1, @@ -736,7 +736,7 @@ void shouldWriteAsArrayListAndReadAsByteArray() { @Test void shouldWriteAsByteArrayAndReadAsArrayList() { MappingAerospikeConverter converter = - getMappingAerospikeConverter(aerospikeDataSettings, new AerospikeTypeAliasAccessor(null)); + getMappingAerospikeConverter(settings, new AerospikeTypeAliasAccessor(null)); AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); DocumentWithByteArray docToWrite = new DocumentWithByteArray("user-id", new byte[]{1, 2, 3}); @@ -763,14 +763,14 @@ private void assertWriteAndRead(int converterOption, aerospikeConverter.write(object, forWrite); - KeyAssert.assertThat(forWrite.getKey()).consistsOf(aerospikeConverter.getAerospikeDataSettings(), NAMESPACE, + KeyAssert.assertThat(forWrite.getKey()).consistsOf(aerospikeConverter.getAerospikeSettings(), NAMESPACE, expectedSet, expectedUserKey); for (Bin expectedBin : expectedBins) { if (expectedBin.value.getType() == ParticleType.MAP) { // Compare Maps assertThat( - compareMaps(aerospikeConverter.getAerospikeDataSettings(), expectedBin, + compareMaps(aerospikeConverter.getAerospikeSettings(), expectedBin, forWrite.getBins().stream().filter(bin -> bin.name.equals(expectedBin.name)) .findFirst().orElse(null))).isTrue(); } else { @@ -785,8 +785,8 @@ private void assertWriteAndRead(int converterOption, assertThat(actual).isEqualTo(object); } - private boolean compareMaps(AerospikeDataSettings aerospikeDataSettings, Bin expected, Bin actual) { - if (aerospikeDataSettings != null && aerospikeDataSettings.isKeepOriginalKeyTypes()) { + private boolean compareMaps(AerospikeDataSettings settings, Bin expected, Bin actual) { + if (settings != null && settings.isKeepOriginalKeyTypes()) { return expected.equals(actual); } else { // String type is used for unsupported Aerospike key types and previously for all key types in older @@ -807,7 +807,7 @@ private T readObjectAfterWriting(int converterOption, aerospikeConverter.write(object, forWrite); - KeyAssert.assertThat(forWrite.getKey()).consistsOf(aerospikeConverter.getAerospikeDataSettings(), NAMESPACE, + KeyAssert.assertThat(forWrite.getKey()).consistsOf(aerospikeConverter.getAerospikeSettings(), NAMESPACE, expectedSet, expectedUserKey); assertThat(forWrite.getBins()).containsOnly(expectedBins); diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeExpirationTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeExpirationTests.java index 288e6c1f2..d27361ece 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeExpirationTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeExpirationTests.java @@ -29,7 +29,6 @@ import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithExpirationAnnotation; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithExpirationOneDay; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithUnixTimeExpiration; -import org.springframework.test.context.TestPropertySource; import java.time.Duration; @@ -37,15 +36,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.data.Offset.offset; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.sample.SampleClasses.DocumentWithExpirationAnnotationAndPersistenceConstructor; import static org.springframework.data.aerospike.utility.AerospikeExpirationPolicy.DO_NOT_UPDATE_EXPIRATION; import static org.springframework.data.aerospike.utility.AerospikeExpirationPolicy.NEVER_EXPIRE; import static org.springframework.data.aerospike.utility.AwaitilityUtils.awaitTenSecondsUntil; import static org.springframework.data.aerospike.utility.AwaitilityUtils.awaitTwoSecondsUntil; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeExpirationTests extends BaseBlockingIntegrationTests { @AfterEach diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateAddTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateAddTests.java index 75063da28..771cb433b 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateAddTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateAddTests.java @@ -18,16 +18,12 @@ import org.junit.jupiter.api.Test; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import java.util.HashMap; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateAddTests extends BaseBlockingIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateAppendTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateAppendTests.java index ddb594b4e..3ecf134d6 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateAppendTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateAppendTests.java @@ -18,16 +18,12 @@ import org.junit.jupiter.api.Test; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import java.util.HashMap; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateAppendTests extends BaseBlockingIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateCompositeKeyTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateCompositeKeyTests.java index 1361ea735..92fc06250 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateCompositeKeyTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateCompositeKeyTests.java @@ -5,16 +5,12 @@ import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.sample.SampleClasses.CompositeKey; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithCompositeKey; -import org.springframework.test.context.TestPropertySource; import java.util.List; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateCompositeKeyTests extends BaseBlockingIntegrationTests { private DocumentWithCompositeKey document; 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 a6dd7dd08..00655cf14 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateCountTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateCountTests.java @@ -26,18 +26,14 @@ import org.springframework.data.aerospike.query.Qualifier; import org.springframework.data.aerospike.repository.query.Query; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import java.time.Duration; import java.util.Objects; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateCountTests extends BaseBlockingIntegrationTests { @BeforeAll 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 6f2916f89..d16a2fca7 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateDeleteTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateDeleteTests.java @@ -30,7 +30,6 @@ import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithExpiration; import org.springframework.data.aerospike.sample.SampleClasses.VersionedClass; import org.springframework.data.aerospike.utility.AwaitilityUtils; -import org.springframework.test.context.TestPropertySource; import java.time.Instant; import java.util.Arrays; @@ -44,10 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.awaitility.Awaitility.await; import static org.awaitility.Durations.TEN_SECONDS; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateDeleteTests extends BaseBlockingIntegrationTests { @BeforeEach diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateExecuteTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateExecuteTests.java index fedd7c71c..b5de868ee 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateExecuteTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateExecuteTests.java @@ -23,13 +23,9 @@ import org.junit.jupiter.api.Test; import org.springframework.dao.DuplicateKeyException; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateExecuteTests extends BaseBlockingIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateExistsTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateExistsTests.java index a17e737c0..5e773d3fc 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateExistsTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateExistsTests.java @@ -18,13 +18,9 @@ import org.junit.jupiter.api.Test; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateExistsTests extends BaseBlockingIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByIdProjectionTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByIdProjectionTests.java index e0796c0d9..d1e3cb275 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByIdProjectionTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByIdProjectionTests.java @@ -6,17 +6,13 @@ import org.springframework.data.aerospike.sample.PersonMissingAndRedundantFields; import org.springframework.data.aerospike.sample.PersonSomeFields; import org.springframework.data.aerospike.sample.PersonTouchOnRead; -import org.springframework.test.context.TestPropertySource; import java.util.Arrays; import java.util.Collections; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateFindByIdProjectionTests extends BaseBlockingIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByIdTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByIdTests.java index 1900bb3d3..c69902b13 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByIdTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByIdTests.java @@ -28,7 +28,6 @@ import org.springframework.data.aerospike.sample.SampleClasses.MapWithDoubleId; import org.springframework.data.aerospike.sample.SampleClasses.MapWithIntegerId; import org.springframework.data.aerospike.sample.SampleClasses.VersionedClassWithAllArgsConstructor; -import org.springframework.test.context.TestPropertySource; import java.util.Arrays; import java.util.Collections; @@ -37,12 +36,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.sample.SampleClasses.DocumentWithTouchOnReadAndExpirationProperty; import static org.springframework.data.aerospike.sample.SampleClasses.EXPIRATION_ONE_MINUTE; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateFindByIdTests extends BaseBlockingIntegrationTests { @Test @@ -164,7 +160,7 @@ public void findByKey() { // findByUserKey @Test public void findById_shouldReadClassWithNumericKeyMapWrittenByTemplate() { - if (template.getAerospikeConverter().getAerospikeDataSettings().isKeepOriginalKeyTypes()) { + if (template.getAerospikeConverter().getAerospikeSettings().isKeepOriginalKeyTypes()) { int intKey = 1; double doubleKey = 100.25; String value = "String value"; @@ -185,7 +181,7 @@ public void findById_shouldReadClassWithNumericKeyMapWrittenByTemplate() { @Test public void findById_shouldReadClassWithNumericKeyMap() { - if (template.getAerospikeConverter().getAerospikeDataSettings().isKeepOriginalKeyTypes()) { + if (template.getAerospikeConverter().getAerospikeSettings().isKeepOriginalKeyTypes()) { int intKey = 1; double doubleKey = 100.25; String value = "String value"; @@ -210,7 +206,7 @@ public void findById_shouldReadClassWithNumericKeyMap() { @Test public void findById_shouldReadClassWithByteArrayId() { - if (template.getAerospikeConverter().getAerospikeDataSettings().isKeepOriginalKeyTypes()) { + if (template.getAerospikeConverter().getAerospikeSettings().isKeepOriginalKeyTypes()) { long longId = 10L; SampleClasses.DocumentWithLongId document = SampleClasses.DocumentWithLongId.builder().id(longId).build(); template.save(document); 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 31a8eb5ab..066349c61 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryProjectionTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryProjectionTests.java @@ -12,7 +12,6 @@ import org.springframework.data.aerospike.sample.PersonSomeFields; import org.springframework.data.aerospike.utility.QueryUtils; import org.springframework.data.domain.Sort; -import org.springframework.test.context.TestPropertySource; import java.util.Arrays; import java.util.List; @@ -20,11 +19,8 @@ import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateFindByQueryProjectionTests extends BaseBlockingIntegrationTests { final Person jean = Person.builder() 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 bba6e7b76..9f174c271 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateFindByQueryTests.java @@ -36,7 +36,6 @@ import org.springframework.data.aerospike.utility.CollectionUtils; import org.springframework.data.aerospike.utility.QueryUtils; import org.springframework.data.domain.Sort; -import org.springframework.test.context.TestPropertySource; import java.util.Arrays; import java.util.Collections; @@ -47,12 +46,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.entry; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.domain.Sort.Order.asc; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateFindByQueryTests extends BaseBlockingIntegrationTests { final Person jean = Person.builder().id(nextId()).firstName("Jean").lastName("Matthews").age(21) diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateIndexTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateIndexTests.java index 7b5b729e1..2b46f8c9b 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateIndexTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateIndexTests.java @@ -20,10 +20,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.utility.AwaitilityUtils.awaitTenSecondsUntil; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = true"}) +@TestPropertySource(properties = {"spring-data-aerospike.data.create-indexes-on-startup=true"}) // this test class requires secondary indexes created on startup public class AerospikeTemplateIndexTests extends BaseBlockingIntegrationTests { @@ -96,7 +95,8 @@ public void createIndexWithSetName_createsIndex() { awaitTenSecondsUntil(() -> assertThat(additionalAerospikeTestOperations.getIndexes(OVERRIDE_SET_NAME)) - .contains(Index.builder().name(INDEX_TEST_1_WITH_SET).namespace(namespace).set(OVERRIDE_SET_NAME).bin("stringField") + .contains(Index.builder().name(INDEX_TEST_1_WITH_SET).namespace(namespace).set(OVERRIDE_SET_NAME) + .bin("stringField") .indexType(IndexType.STRING).build()) ); } @@ -134,7 +134,8 @@ public void createIndexWithSetName_createsListIndex() { awaitTenSecondsUntil(() -> assertThat(additionalAerospikeTestOperations.getIndexes(OVERRIDE_SET_NAME)) - .contains(Index.builder().name(INDEX_TEST_1_WITH_SET).namespace(namespace).set(OVERRIDE_SET_NAME).bin("listField") + .contains(Index.builder().name(INDEX_TEST_1_WITH_SET).namespace(namespace).set(OVERRIDE_SET_NAME) + .bin("listField") .indexType(IndexType.STRING).indexCollectionType(IndexCollectionType.LIST).build()) ); } 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 894ae5fdb..5ca3f4ffc 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateInsertTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateInsertTests.java @@ -28,7 +28,6 @@ import org.springframework.data.aerospike.sample.SampleClasses.CustomCollectionClass; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithByteArray; import org.springframework.data.aerospike.utility.AsyncUtils; -import org.springframework.test.context.TestPropertySource; import java.util.Arrays; import java.util.Collections; @@ -41,11 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNoException; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.sample.SampleClasses.VersionedClass; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateInsertTests extends BaseBlockingIntegrationTests { @BeforeEach @@ -169,9 +165,9 @@ public void throwsExceptionForDuplicateIdForVersionedDocument() { public void insertsOnlyFirstDocumentAndNextAttemptsShouldFailWithDuplicateKeyExceptionForVersionedDocument() { AtomicLong counter = new AtomicLong(); AtomicLong duplicateKeyCounter = new AtomicLong(); - int numberOfConcurrentSaves = 5; + int numberOfConcurrentInserts = 5; - AsyncUtils.executeConcurrently(numberOfConcurrentSaves, () -> { + AsyncUtils.executeConcurrently(numberOfConcurrentInserts, () -> { long counterValue = counter.incrementAndGet(); String data = "value-" + counterValue; try { @@ -181,16 +177,16 @@ public void insertsOnlyFirstDocumentAndNextAttemptsShouldFailWithDuplicateKeyExc } }); - assertThat(duplicateKeyCounter.intValue()).isEqualTo(numberOfConcurrentSaves - 1); + assertThat(duplicateKeyCounter.intValue()).isEqualTo(numberOfConcurrentInserts - 1); } @Test public void insertsOnlyFirstDocumentAndNextAttemptsShouldFailWithDuplicateKeyExceptionForNonVersionedDocument() { AtomicLong counter = new AtomicLong(); AtomicLong duplicateKeyCounter = new AtomicLong(); - int numberOfConcurrentSaves = 5; + int numberOfConcurrentInserts = 5; - AsyncUtils.executeConcurrently(numberOfConcurrentSaves, () -> { + AsyncUtils.executeConcurrently(numberOfConcurrentInserts, () -> { long counterValue = counter.incrementAndGet(); String data = "value-" + counterValue; try { @@ -200,7 +196,7 @@ public void insertsOnlyFirstDocumentAndNextAttemptsShouldFailWithDuplicateKeyExc } }); - assertThat(duplicateKeyCounter.intValue()).isEqualTo(numberOfConcurrentSaves - 1); + assertThat(duplicateKeyCounter.intValue()).isEqualTo(numberOfConcurrentInserts - 1); } @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplatePersistTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplatePersistTests.java index ffe18aea0..4f87cecc4 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplatePersistTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplatePersistTests.java @@ -20,15 +20,11 @@ import org.junit.jupiter.api.Test; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.sample.SampleClasses.CustomCollectionClass; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplatePersistTests extends BaseBlockingIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplatePrependTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplatePrependTests.java index c1212b0bf..dc3890e3e 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplatePrependTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplatePrependTests.java @@ -18,16 +18,12 @@ import org.junit.jupiter.api.Test; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import java.util.HashMap; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplatePrependTests extends BaseBlockingIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateQueryAggregationTests.java b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateQueryAggregationTests.java index fa2c8405e..eb06d3dc6 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateQueryAggregationTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateQueryAggregationTests.java @@ -13,18 +13,14 @@ import org.junit.jupiter.api.TestInstance; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import java.util.ArrayList; import java.util.List; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateQueryAggregationTests extends BaseBlockingIntegrationTests { Person firstPerson, secondPerson, thirdPerson; 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 560f21ef5..20bb26140 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateSaveTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateSaveTests.java @@ -27,7 +27,6 @@ import org.springframework.data.aerospike.sample.Person; import org.springframework.data.aerospike.sample.SampleClasses; import org.springframework.data.aerospike.utility.AsyncUtils; -import org.springframework.test.context.TestPropertySource; import java.math.BigInteger; import java.util.List; @@ -36,15 +35,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNoException; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.sample.SampleClasses.CustomCollectionClass; import static org.springframework.data.aerospike.sample.SampleClasses.DocumentWithByteArray; import static org.springframework.data.aerospike.sample.SampleClasses.DocumentWithTouchOnRead; import static org.springframework.data.aerospike.sample.SampleClasses.VersionedClass; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateSaveTests extends BaseBlockingIntegrationTests { @AfterAll 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 6700f4788..14be19942 100644 --- a/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateUpdateTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/AerospikeTemplateUpdateTests.java @@ -26,7 +26,6 @@ import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.sample.Person; import org.springframework.data.aerospike.utility.AsyncUtils; -import org.springframework.test.context.TestPropertySource; import java.util.ArrayList; import java.util.HashMap; @@ -36,11 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.sample.SampleClasses.VersionedClass; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeTemplateUpdateTests extends BaseBlockingIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/DefaultAerospikeExceptionTranslatorTest.java b/src/test/java/org/springframework/data/aerospike/core/DefaultAerospikeExceptionTranslatorTest.java index 4f83e04c4..cf6c7f77c 100644 --- a/src/test/java/org/springframework/data/aerospike/core/DefaultAerospikeExceptionTranslatorTest.java +++ b/src/test/java/org/springframework/data/aerospike/core/DefaultAerospikeExceptionTranslatorTest.java @@ -26,13 +26,9 @@ import org.springframework.dao.TransientDataAccessResourceException; import org.springframework.data.aerospike.exceptions.IndexAlreadyExistsException; import org.springframework.data.aerospike.exceptions.IndexNotFoundException; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class DefaultAerospikeExceptionTranslatorTest { private final DefaultAerospikeExceptionTranslator translator = new DefaultAerospikeExceptionTranslator(); diff --git a/src/test/java/org/springframework/data/aerospike/core/WritePolicyBuilderTest.java b/src/test/java/org/springframework/data/aerospike/core/WritePolicyBuilderTest.java index b6276c2fc..c296f6e80 100644 --- a/src/test/java/org/springframework/data/aerospike/core/WritePolicyBuilderTest.java +++ b/src/test/java/org/springframework/data/aerospike/core/WritePolicyBuilderTest.java @@ -4,14 +4,10 @@ import com.aerospike.client.policy.RecordExistsAction; import com.aerospike.client.policy.WritePolicy; import org.junit.jupiter.api.Test; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class WritePolicyBuilderTest { private static final GenerationPolicy GENERATION_POLICY = GenerationPolicy.EXPECT_GEN_EQUAL; diff --git a/src/test/java/org/springframework/data/aerospike/core/model/GroupedEntitiesTest.java b/src/test/java/org/springframework/data/aerospike/core/model/GroupedEntitiesTest.java index a4e21a768..86dbcbdc2 100644 --- a/src/test/java/org/springframework/data/aerospike/core/model/GroupedEntitiesTest.java +++ b/src/test/java/org/springframework/data/aerospike/core/model/GroupedEntitiesTest.java @@ -3,17 +3,13 @@ import org.junit.Test; import org.springframework.data.aerospike.sample.Customer; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import java.util.Collection; import java.util.List; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class GroupedEntitiesTest { private static final Map, Collection> entitiesMap = Map.of( diff --git a/src/test/java/org/springframework/data/aerospike/core/model/GroupedKeysTest.java b/src/test/java/org/springframework/data/aerospike/core/model/GroupedKeysTest.java index 594d6f2df..5c2cd6189 100644 --- a/src/test/java/org/springframework/data/aerospike/core/model/GroupedKeysTest.java +++ b/src/test/java/org/springframework/data/aerospike/core/model/GroupedKeysTest.java @@ -2,7 +2,6 @@ import org.junit.Test; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import java.util.Collection; import java.util.HashMap; @@ -11,10 +10,7 @@ import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class GroupedKeysTest { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateCompositeKeyTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateCompositeKeyTests.java index 0b648afac..1260c082e 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateCompositeKeyTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateCompositeKeyTests.java @@ -5,17 +5,13 @@ import org.springframework.data.aerospike.BaseReactiveIntegrationTests; import org.springframework.data.aerospike.sample.SampleClasses.CompositeKey; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithCompositeKey; -import org.springframework.test.context.TestPropertySource; import reactor.test.StepVerifier; import java.util.List; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateCompositeKeyTests extends BaseReactiveIntegrationTests { private DocumentWithCompositeKey document; 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 3db1a0ff7..4b38c1c9b 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 @@ -14,7 +14,6 @@ import org.springframework.data.aerospike.sample.Person; import org.springframework.data.aerospike.sample.SampleClasses; import org.springframework.data.aerospike.utility.AwaitilityUtils; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; @@ -27,7 +26,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.sample.SampleClasses.VersionedClass; /** @@ -35,8 +33,6 @@ * * @author Yevhen Tsyba */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateDeleteRelatedTests extends BaseReactiveIntegrationTests { @BeforeEach diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByEntitiesTest.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByEntitiesTest.java index 48b650540..e46715760 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByEntitiesTest.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByEntitiesTest.java @@ -4,13 +4,8 @@ import org.springframework.data.aerospike.core.AbstractFindByEntitiesTest; import org.springframework.data.aerospike.core.model.GroupedEntities; import org.springframework.data.aerospike.core.model.GroupedKeys; -import org.springframework.test.context.TestPropertySource; import reactor.core.scheduler.Schedulers; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; - -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateFindByEntitiesTest extends BaseReactiveIntegrationTests implements AbstractFindByEntitiesTest { diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByIdProjectionTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByIdProjectionTests.java index 7b306f6c6..dd483805a 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByIdProjectionTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByIdProjectionTests.java @@ -6,7 +6,6 @@ import org.springframework.data.aerospike.sample.PersonMissingAndRedundantFields; import org.springframework.data.aerospike.sample.PersonSomeFields; import org.springframework.data.aerospike.sample.PersonTouchOnRead; -import org.springframework.test.context.TestPropertySource; import reactor.core.scheduler.Schedulers; import java.util.Arrays; @@ -14,10 +13,7 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateFindByIdProjectionTests extends BaseReactiveIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByIdTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByIdTests.java index cd54c1244..8d5e7ccb6 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByIdTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByIdTests.java @@ -7,7 +7,6 @@ import org.springframework.data.aerospike.sample.SampleClasses; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithTouchOnRead; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithTouchOnReadAndExpirationProperty; -import org.springframework.test.context.TestPropertySource; import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; @@ -17,7 +16,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.sample.SampleClasses.EXPIRATION_ONE_MINUTE; /** @@ -25,8 +23,6 @@ * * @author Igor Ermolenko */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateFindByIdTests extends BaseReactiveIntegrationTests { @Test @@ -110,7 +106,7 @@ public void findByIds_shouldFindExisting() { @Test public void findById_shouldReadClassWithNonStringId() { - if (reactiveTemplate.getAerospikeConverter().getAerospikeDataSettings().isKeepOriginalKeyTypes()) { + if (reactiveTemplate.getAerospikeConverter().getAerospikeSettings().isKeepOriginalKeyTypes()) { long longId = 10L; SampleClasses.DocumentWithLongId document = SampleClasses.DocumentWithLongId.builder().id(longId).build(); reactiveTemplate.save(document).block(); diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByQueryProjectionTest.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByQueryProjectionTest.java index f6858952f..6adbaf024 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByQueryProjectionTest.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByQueryProjectionTest.java @@ -13,7 +13,6 @@ import org.springframework.data.aerospike.sample.PersonSomeFields; import org.springframework.data.aerospike.utility.QueryUtils; import org.springframework.data.domain.Sort; -import org.springframework.test.context.TestPropertySource; import reactor.core.scheduler.Schedulers; import java.util.List; @@ -22,11 +21,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateFindByQueryProjectionTest extends BaseReactiveIntegrationTests { @BeforeAll diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByQueryTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByQueryTests.java index 4436ee11e..2040c04b5 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByQueryTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateFindByQueryTests.java @@ -14,7 +14,6 @@ import org.springframework.data.aerospike.sample.Person; import org.springframework.data.aerospike.utility.QueryUtils; import org.springframework.data.domain.Sort; -import org.springframework.test.context.TestPropertySource; import reactor.core.scheduler.Schedulers; import java.util.ArrayList; @@ -27,12 +26,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.domain.Sort.Order.asc; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateFindByQueryTests extends BaseReactiveIntegrationTests { @BeforeAll diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateIndexTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateIndexTests.java index 1e6b9e067..671088be7 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateIndexTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateIndexTests.java @@ -12,7 +12,6 @@ import org.springframework.data.aerospike.exceptions.IndexNotFoundException; import org.springframework.data.aerospike.mapping.Document; import org.springframework.data.aerospike.query.model.Index; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Mono; import java.util.Objects; @@ -22,11 +21,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.utility.AwaitilityUtils.awaitTenSecondsUntil; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateIndexTests extends BaseReactiveIntegrationTests { private static final String INDEX_TEST_1 = "index-test-77777"; 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 9280e63ff..66097ad28 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 @@ -15,7 +15,6 @@ import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithByteArray; import org.springframework.data.aerospike.sample.SampleClasses.VersionedClass; import org.springframework.data.aerospike.utility.AsyncUtils; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; @@ -29,10 +28,7 @@ import java.util.stream.IntStream; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup @TestInstance(Lifecycle.PER_CLASS) public class ReactiveAerospikeTemplateInsertTests extends BaseReactiveIntegrationTests { diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateMiscTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateMiscTests.java index b49966f3b..c93f98fb8 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateMiscTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateMiscTests.java @@ -10,19 +10,14 @@ import org.springframework.data.aerospike.core.ReactiveAerospikeTemplate; import org.springframework.data.aerospike.core.WritePolicyBuilder; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; - /** * Tests for different methods in {@link ReactiveAerospikeTemplate}. * * @author Igor Ermolenko */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateMiscTests extends BaseReactiveIntegrationTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateModificationRelatedTests.java b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateModificationRelatedTests.java index 505ce5755..6c6269bf7 100644 --- a/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateModificationRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/core/reactive/ReactiveAerospikeTemplateModificationRelatedTests.java @@ -4,7 +4,6 @@ import org.springframework.data.aerospike.BaseReactiveIntegrationTests; import org.springframework.data.aerospike.core.ReactiveAerospikeTemplate; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; @@ -12,15 +11,11 @@ import java.util.HashMap; import java.util.Map; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; - /** * Tests for save related methods in {@link ReactiveAerospikeTemplate}. * * @author Yevhen Tsyba */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateModificationRelatedTests extends BaseReactiveIntegrationTests { @Test 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 bc235cc6d..29734d571 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 @@ -10,7 +10,6 @@ import org.springframework.data.aerospike.sample.SampleClasses.CustomCollectionClass; import org.springframework.data.aerospike.sample.SampleClasses.VersionedClass; import org.springframework.data.aerospike.utility.AsyncUtils; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; @@ -21,15 +20,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.entry; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * Tests for save related methods in {@link ReactiveAerospikeTemplate}. * * @author Igor Ermolenko */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateSaveRelatedTests extends BaseReactiveIntegrationTests { @Test 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 cc63d75dd..bc5cc6c9a 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 @@ -12,7 +12,6 @@ import org.springframework.data.aerospike.sample.Person; import org.springframework.data.aerospike.sample.SampleClasses.VersionedClass; import org.springframework.data.aerospike.utility.AsyncUtils; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -24,11 +23,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static reactor.test.StepVerifier.create; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeTemplateUpdateTests extends BaseReactiveIntegrationTests { @BeforeEach diff --git a/src/test/java/org/springframework/data/aerospike/index/AerospikePersistenceEntityIndexCreatorTest.java b/src/test/java/org/springframework/data/aerospike/index/AerospikePersistenceEntityIndexCreatorTest.java index babd06e03..3c4669b8a 100644 --- a/src/test/java/org/springframework/data/aerospike/index/AerospikePersistenceEntityIndexCreatorTest.java +++ b/src/test/java/org/springframework/data/aerospike/index/AerospikePersistenceEntityIndexCreatorTest.java @@ -7,7 +7,6 @@ import org.springframework.data.aerospike.exceptions.IndexAlreadyExistsException; import org.springframework.data.aerospike.sample.AutoIndexedDocument; import org.springframework.data.aerospike.utility.MockObjectProvider; -import org.springframework.test.context.TestPropertySource; import java.util.Collections; import java.util.Set; @@ -16,10 +15,7 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup class AerospikePersistenceEntityIndexCreatorTest { final boolean createIndexesOnStartup = true; diff --git a/src/test/java/org/springframework/data/aerospike/index/IndexNotScheduledCacheRefreshTest.java b/src/test/java/org/springframework/data/aerospike/index/IndexNotScheduledCacheRefreshTest.java index e036b2f3b..07e6f062f 100644 --- a/src/test/java/org/springframework/data/aerospike/index/IndexNotScheduledCacheRefreshTest.java +++ b/src/test/java/org/springframework/data/aerospike/index/IndexNotScheduledCacheRefreshTest.java @@ -12,11 +12,10 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; @Slf4j @ContextConfiguration -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) +@TestPropertySource(properties = {"spring-data-aerospike.data.server-version-refresh-seconds = 0"}) public class IndexNotScheduledCacheRefreshTest extends BaseBlockingIntegrationTests { String setName = "scheduled"; diff --git a/src/test/java/org/springframework/data/aerospike/index/IndexScheduledCacheRefreshTest.java b/src/test/java/org/springframework/data/aerospike/index/IndexScheduledCacheRefreshTest.java index b270fb5fd..49c724c9f 100644 --- a/src/test/java/org/springframework/data/aerospike/index/IndexScheduledCacheRefreshTest.java +++ b/src/test/java/org/springframework/data/aerospike/index/IndexScheduledCacheRefreshTest.java @@ -12,11 +12,10 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; @Slf4j @ContextConfiguration -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 4", "createIndexesOnStartup = false"}) +@TestPropertySource(properties = {"spring-data-aerospike.data.index-cache-refresh-seconds=4"}) public class IndexScheduledCacheRefreshTest extends BaseBlockingIntegrationTests { String setName = "scheduled"; diff --git a/src/test/java/org/springframework/data/aerospike/index/IndexedAnnotationTests.java b/src/test/java/org/springframework/data/aerospike/index/IndexedAnnotationTests.java index 22494e09d..45aa36935 100644 --- a/src/test/java/org/springframework/data/aerospike/index/IndexedAnnotationTests.java +++ b/src/test/java/org/springframework/data/aerospike/index/IndexedAnnotationTests.java @@ -15,9 +15,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = true"}) +@TestPropertySource(properties = {"spring-data-aerospike.data.create-indexes-on-startup=true"}) // this test class requires secondary indexes created on startup public class IndexedAnnotationTests extends BaseBlockingIntegrationTests { diff --git a/src/test/java/org/springframework/data/aerospike/index/ReactiveAerospikePersistenceEntityIndexCreatorTest.java b/src/test/java/org/springframework/data/aerospike/index/ReactiveAerospikePersistenceEntityIndexCreatorTest.java index 812cab345..cd705fe1e 100644 --- a/src/test/java/org/springframework/data/aerospike/index/ReactiveAerospikePersistenceEntityIndexCreatorTest.java +++ b/src/test/java/org/springframework/data/aerospike/index/ReactiveAerospikePersistenceEntityIndexCreatorTest.java @@ -7,7 +7,6 @@ import org.springframework.data.aerospike.exceptions.IndexAlreadyExistsException; import org.springframework.data.aerospike.sample.AutoIndexedDocument; import org.springframework.data.aerospike.utility.MockObjectProvider; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Mono; import java.util.Collections; @@ -16,10 +15,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup class ReactiveAerospikePersistenceEntityIndexCreatorTest { final boolean createIndexesOnStartup = true; diff --git a/src/test/java/org/springframework/data/aerospike/logging/LoggingTests.java b/src/test/java/org/springframework/data/aerospike/logging/LoggingTests.java index 13f923fd7..0b3b21995 100644 --- a/src/test/java/org/springframework/data/aerospike/logging/LoggingTests.java +++ b/src/test/java/org/springframework/data/aerospike/logging/LoggingTests.java @@ -80,7 +80,7 @@ void queryIsCreated() { private MappingAerospikeConverter getMappingAerospikeConverter(AerospikeCustomConversions conversions) { MappingAerospikeConverter converter = new MappingAerospikeConverter(new AerospikeMappingContext(), - conversions, new AerospikeTypeAliasAccessor(), AerospikeDataSettings.builder().build()); + conversions, new AerospikeTypeAliasAccessor(), new AerospikeDataSettings()); converter.afterPropertiesSet(); return converter; } diff --git a/src/test/java/org/springframework/data/aerospike/mapping/AerospikeMappingContextTest.java b/src/test/java/org/springframework/data/aerospike/mapping/AerospikeMappingContextTest.java index 8f6dcd18e..612b6db69 100644 --- a/src/test/java/org/springframework/data/aerospike/mapping/AerospikeMappingContextTest.java +++ b/src/test/java/org/springframework/data/aerospike/mapping/AerospikeMappingContextTest.java @@ -18,18 +18,14 @@ import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * @author Peter Milne * @author Jean Mercier */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikeMappingContextTest { @Test diff --git a/src/test/java/org/springframework/data/aerospike/mapping/AerospikePersistentEntityTest.java b/src/test/java/org/springframework/data/aerospike/mapping/AerospikePersistentEntityTest.java index 8ef682f6c..57304e04c 100644 --- a/src/test/java/org/springframework/data/aerospike/mapping/AerospikePersistentEntityTest.java +++ b/src/test/java/org/springframework/data/aerospike/mapping/AerospikePersistentEntityTest.java @@ -18,18 +18,14 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; -import org.springframework.test.context.TestPropertySource; import java.util.concurrent.TimeUnit; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.springframework.data.aerospike.mapping.BasicAerospikePersistentEntity.DEFAULT_EXPIRATION; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.sample.SampleClasses.*; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class AerospikePersistentEntityTest extends BaseBlockingIntegrationTests { @Autowired diff --git a/src/test/java/org/springframework/data/aerospike/mapping/BasicAerospikePersistentEntityTest.java b/src/test/java/org/springframework/data/aerospike/mapping/BasicAerospikePersistentEntityTest.java index 4a1c73876..7e27cff50 100644 --- a/src/test/java/org/springframework/data/aerospike/mapping/BasicAerospikePersistentEntityTest.java +++ b/src/test/java/org/springframework/data/aerospike/mapping/BasicAerospikePersistentEntityTest.java @@ -20,14 +20,10 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithExpressionInCollection; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithoutCollection; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup @ExtendWith(MockitoExtension.class) public class BasicAerospikePersistentEntityTest { diff --git a/src/test/java/org/springframework/data/aerospike/mapping/CachingAerospikePersistentPropertyTest.java b/src/test/java/org/springframework/data/aerospike/mapping/CachingAerospikePersistentPropertyTest.java index f2a171284..0a01cf6c2 100644 --- a/src/test/java/org/springframework/data/aerospike/mapping/CachingAerospikePersistentPropertyTest.java +++ b/src/test/java/org/springframework/data/aerospike/mapping/CachingAerospikePersistentPropertyTest.java @@ -19,18 +19,14 @@ import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.data.aerospike.sample.Person; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * @author Peter Milne * @author Jean Mercier */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class CachingAerospikePersistentPropertyTest { AerospikeMappingContext context; diff --git a/src/test/java/org/springframework/data/aerospike/query/FilterOperationRegexpBuilderTest.java b/src/test/java/org/springframework/data/aerospike/query/FilterOperationRegexpBuilderTest.java index b3033961f..ce60c7913 100644 --- a/src/test/java/org/springframework/data/aerospike/query/FilterOperationRegexpBuilderTest.java +++ b/src/test/java/org/springframework/data/aerospike/query/FilterOperationRegexpBuilderTest.java @@ -18,17 +18,13 @@ import org.junit.jupiter.api.Test; import org.springframework.data.aerospike.utility.FilterOperationRegexpBuilder; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /* * Tests to ensure that Qualifiers are built successfully for non-indexed bins. */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class FilterOperationRegexpBuilderTest { @Test diff --git a/src/test/java/org/springframework/data/aerospike/query/cache/IndexTests.java b/src/test/java/org/springframework/data/aerospike/query/cache/IndexTests.java index 519639d24..c0143e33f 100644 --- a/src/test/java/org/springframework/data/aerospike/query/cache/IndexTests.java +++ b/src/test/java/org/springframework/data/aerospike/query/cache/IndexTests.java @@ -7,7 +7,6 @@ import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.query.model.Index; import org.springframework.data.aerospike.query.model.IndexKey; -import org.springframework.test.context.TestPropertySource; import java.util.List; import java.util.Optional; @@ -19,11 +18,8 @@ import static com.aerospike.client.query.IndexType.NUMERIC; import static com.aerospike.client.query.IndexType.STRING; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.query.model.Index.builder; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class IndexTests extends BaseBlockingIntegrationTests { private static final String SET = "index-test"; diff --git a/src/test/java/org/springframework/data/aerospike/query/reactive/ReactiveIndexedPersonRepositoryQueryTests.java b/src/test/java/org/springframework/data/aerospike/query/reactive/ReactiveIndexedPersonRepositoryQueryTests.java index a63c96eed..36229f629 100644 --- a/src/test/java/org/springframework/data/aerospike/query/reactive/ReactiveIndexedPersonRepositoryQueryTests.java +++ b/src/test/java/org/springframework/data/aerospike/query/reactive/ReactiveIndexedPersonRepositoryQueryTests.java @@ -23,7 +23,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; -import org.springframework.test.context.TestPropertySource; import reactor.core.scheduler.Schedulers; import java.util.Arrays; @@ -32,13 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.springframework.data.aerospike.AsCollections.of; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.repository.query.CriteriaDefinition.AerospikeMapCriteria.VALUE; import static org.springframework.data.aerospike.repository.query.CriteriaDefinition.AerospikeMetadata.SINCE_UPDATE_TIME; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveIndexedPersonRepositoryQueryTests extends BaseReactiveIntegrationTests { static final IndexedPerson alain = IndexedPerson.builder().id(nextId()).firstName("Alain").lastName("Sebastian") diff --git a/src/test/java/org/springframework/data/aerospike/repository/CustomerRepositoriesIntegrationTests.java b/src/test/java/org/springframework/data/aerospike/repository/CustomerRepositoriesIntegrationTests.java index fc9aa3015..bba9cb1aa 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/CustomerRepositoriesIntegrationTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/CustomerRepositoriesIntegrationTests.java @@ -20,20 +20,16 @@ import org.springframework.data.aerospike.BaseBlockingIntegrationTests; import org.springframework.data.aerospike.sample.Customer; import org.springframework.data.aerospike.sample.CustomerRepository; -import org.springframework.test.context.TestPropertySource; import java.util.Arrays; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * @author Oliver Gierke */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class CustomerRepositoriesIntegrationTests extends BaseBlockingIntegrationTests { @Autowired diff --git a/src/test/java/org/springframework/data/aerospike/repository/IdTypesRepositoryQueryTests.java b/src/test/java/org/springframework/data/aerospike/repository/IdTypesRepositoryQueryTests.java index cca456c52..aa22d6f9c 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/IdTypesRepositoryQueryTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/IdTypesRepositoryQueryTests.java @@ -22,16 +22,12 @@ import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithLongId; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithShortId; import org.springframework.data.aerospike.sample.SampleClasses.DocumentWithStringId; -import org.springframework.test.context.TestPropertySource; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class IdTypesRepositoryQueryTests extends BaseBlockingIntegrationTests { @Autowired diff --git a/src/test/java/org/springframework/data/aerospike/repository/IndexedPersonRepositoryQueryTests.java b/src/test/java/org/springframework/data/aerospike/repository/IndexedPersonRepositoryQueryTests.java index 11c5003e1..ab15bbed8 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/IndexedPersonRepositoryQueryTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/IndexedPersonRepositoryQueryTests.java @@ -19,7 +19,6 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; -import org.springframework.test.context.TestPropertySource; import java.util.ArrayList; import java.util.List; @@ -35,12 +34,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.springframework.data.aerospike.AsCollections.of; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.repository.query.CriteriaDefinition.AerospikeMapCriteria.VALUE; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class IndexedPersonRepositoryQueryTests extends BaseBlockingIntegrationTests { @Autowired 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 01db5a9cb..fca6687af 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java @@ -20,7 +20,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; -import org.springframework.test.context.TestPropertySource; import java.math.BigDecimal; import java.math.BigInteger; @@ -41,15 +40,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.springframework.data.aerospike.AsCollections.of; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.repository.query.CriteriaDefinition.AerospikeMapCriteria.KEY; import static org.springframework.data.aerospike.repository.query.CriteriaDefinition.AerospikeMapCriteria.VALUE; import static org.springframework.data.aerospike.repository.query.CriteriaDefinition.AerospikeMapCriteria.VALUE_CONTAINING; import static org.springframework.data.aerospike.repository.query.CriteriaDefinition.AerospikeMetadata.SINCE_UPDATE_TIME; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class PersonRepositoryQueryTests extends BaseBlockingIntegrationTests { static final Person dave = Person.builder().id(nextId()).firstName("Dave").lastName("Matthews").age(42) @@ -857,7 +853,7 @@ void findByMapKeyValueLessThanOrEqual() { List persons = repository.findByIntMapLessThanEqual("key2", 1); assertThat(persons).containsExactly(carter); - if (template.getAerospikeConverter().getAerospikeDataSettings().isKeepOriginalKeyTypes()) { + if (template.getAerospikeConverter().getAerospikeSettings().isKeepOriginalKeyTypes()) { carter.setLongIntMap(Map.of(10L, 10)); repository.save(carter); assertThat(carter.getLongIntMap().get(10L) <= 10).isTrue(); diff --git a/src/test/java/org/springframework/data/aerospike/repository/RepositoriesIntegrationTests.java b/src/test/java/org/springframework/data/aerospike/repository/RepositoriesIntegrationTests.java index 6d5c5670b..a499ca643 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/RepositoriesIntegrationTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/RepositoriesIntegrationTests.java @@ -21,15 +21,11 @@ import org.springframework.data.aerospike.sample.CompositeObject; import org.springframework.data.aerospike.sample.CompositeObjectRepository; import org.springframework.data.aerospike.sample.SimpleObject; -import org.springframework.test.context.TestPropertySource; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class RepositoriesIntegrationTests extends BaseBlockingIntegrationTests { @Autowired diff --git a/src/test/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreatorUnitTests.java b/src/test/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreatorUnitTests.java index ad77de305..f565c7d6a 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreatorUnitTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreatorUnitTests.java @@ -58,7 +58,7 @@ public void createQueryByInList() { private MappingAerospikeConverter getMappingAerospikeConverter(AerospikeCustomConversions conversions) { MappingAerospikeConverter converter = new MappingAerospikeConverter(new AerospikeMappingContext(), - conversions, new AerospikeTypeAliasAccessor(), AerospikeDataSettings.builder().build()); + conversions, new AerospikeTypeAliasAccessor(), new AerospikeDataSettings()); converter.afterPropertiesSet(); return converter; } diff --git a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryDeleteRelatedTests.java b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryDeleteRelatedTests.java index 5ad6a6818..ccdd1eb11 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryDeleteRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryDeleteRelatedTests.java @@ -8,7 +8,6 @@ import org.springframework.data.aerospike.BaseReactiveIntegrationTests; import org.springframework.data.aerospike.sample.Customer; import org.springframework.data.aerospike.sample.ReactiveCustomerRepository; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Flux; import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; @@ -17,13 +16,10 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * @author Igor Ermolenko */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeRepositoryDeleteRelatedTests extends BaseReactiveIntegrationTests { @Autowired diff --git a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryExistRelatedTests.java b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryExistRelatedTests.java index 2fa399ca4..759ca1f3f 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryExistRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryExistRelatedTests.java @@ -6,18 +6,13 @@ import org.springframework.data.aerospike.BaseReactiveIntegrationTests; import org.springframework.data.aerospike.sample.Customer; import org.springframework.data.aerospike.sample.ReactiveCustomerRepository; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Flux; import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; - /** * @author Igor Ermolenko */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeRepositoryExistRelatedTests extends BaseReactiveIntegrationTests { @Autowired diff --git a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryFindRelatedTests.java b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryFindRelatedTests.java index 99a099f5f..e02ed49f2 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryFindRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryFindRelatedTests.java @@ -12,7 +12,6 @@ import org.springframework.data.aerospike.sample.CustomerSomeFields; import org.springframework.data.aerospike.sample.ReactiveCustomerRepository; import org.springframework.data.domain.Sort; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Flux; import reactor.core.scheduler.Schedulers; @@ -20,14 +19,11 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.domain.Sort.Order.asc; /** * @author Igor Ermolenko */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ReactiveAerospikeRepositoryFindRelatedTests extends BaseReactiveIntegrationTests { diff --git a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositorySaveRelatedTests.java b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositorySaveRelatedTests.java index 1b3cdf5df..74271d460 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositorySaveRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositorySaveRelatedTests.java @@ -9,7 +9,6 @@ import org.springframework.data.aerospike.sample.ReactiveCompositeObjectRepository; import org.springframework.data.aerospike.sample.ReactiveCustomerRepository; import org.springframework.data.aerospike.sample.SimpleObject; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Flux; import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; @@ -18,13 +17,10 @@ import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * @author Igor Ermolenko */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class ReactiveAerospikeRepositorySaveRelatedTests extends BaseReactiveIntegrationTests { @Autowired diff --git a/src/test/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryTest.java b/src/test/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryTest.java index 9c5243fde..839acb0f6 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryTest.java +++ b/src/test/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryTest.java @@ -32,21 +32,17 @@ import org.springframework.data.repository.core.RepositoryInformation; import org.springframework.data.repository.core.RepositoryMetadata; import org.springframework.data.repository.core.support.PersistentEntityInformation; -import org.springframework.test.context.TestPropertySource; import java.io.Serializable; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * @author Peter Milne * @author Jean Mercier */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup @MockitoSettings(strictness = Strictness.LENIENT) @ExtendWith(MockitoExtension.class) public class AerospikeRepositoryFactoryTest { diff --git a/src/test/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactoryTest.java b/src/test/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactoryTest.java index 7fbf02efe..203f6e2ee 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactoryTest.java +++ b/src/test/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactoryTest.java @@ -32,20 +32,16 @@ import org.springframework.data.repository.core.RepositoryInformation; import org.springframework.data.repository.core.RepositoryMetadata; import org.springframework.data.repository.core.support.PersistentEntityInformation; -import org.springframework.test.context.TestPropertySource; import java.io.Serializable; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * @author Igor Ermolenko */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup @MockitoSettings(strictness = Strictness.LENIENT) @ExtendWith(MockitoExtension.class) public class ReactiveAerospikeRepositoryFactoryTest { diff --git a/src/test/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepositoryTest.java b/src/test/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepositoryTest.java index 302df0428..1e666b1fb 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepositoryTest.java +++ b/src/test/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepositoryTest.java @@ -34,7 +34,6 @@ import org.springframework.data.domain.Sort; import org.springframework.data.keyvalue.core.IterableConverter; import org.springframework.data.repository.core.EntityInformation; -import org.springframework.test.context.TestPropertySource; import java.util.ArrayList; import java.util.List; @@ -46,14 +45,11 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * @author Peter Milne * @author Jean Mercier */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup @MockitoSettings(strictness = Strictness.LENIENT) @ExtendWith(MockitoExtension.class) public class SimpleAerospikeRepositoryTest { diff --git a/src/test/java/org/springframework/data/aerospike/repository/support/SimpleReactiveAerospikeRepositoryTest.java b/src/test/java/org/springframework/data/aerospike/repository/support/SimpleReactiveAerospikeRepositoryTest.java index 565036760..2b7da0850 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/support/SimpleReactiveAerospikeRepositoryTest.java +++ b/src/test/java/org/springframework/data/aerospike/repository/support/SimpleReactiveAerospikeRepositoryTest.java @@ -27,7 +27,6 @@ import org.springframework.data.aerospike.core.ReactiveAerospikeOperations; import org.springframework.data.aerospike.sample.Customer; import org.springframework.data.repository.core.EntityInformation; -import org.springframework.test.context.TestPropertySource; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -45,13 +44,10 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; /** * @author Igor Ermolenko */ -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup @ExtendWith(MockitoExtension.class) public class SimpleReactiveAerospikeRepositoryTest { diff --git a/src/test/java/org/springframework/data/aerospike/utility/InfoResponseUtilsTests.java b/src/test/java/org/springframework/data/aerospike/utility/InfoResponseUtilsTests.java index 3a5b17cc1..0a4ed1a63 100644 --- a/src/test/java/org/springframework/data/aerospike/utility/InfoResponseUtilsTests.java +++ b/src/test/java/org/springframework/data/aerospike/utility/InfoResponseUtilsTests.java @@ -1,16 +1,12 @@ package org.springframework.data.aerospike.utility; import org.junit.jupiter.api.Test; -import org.springframework.test.context.TestPropertySource; import java.util.function.Function; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup class InfoResponseUtilsTests { @Test diff --git a/src/test/java/org/springframework/data/aerospike/utility/QueryUtils.java b/src/test/java/org/springframework/data/aerospike/utility/QueryUtils.java index 2a76acc7d..d759737e8 100644 --- a/src/test/java/org/springframework/data/aerospike/utility/QueryUtils.java +++ b/src/test/java/org/springframework/data/aerospike/utility/QueryUtils.java @@ -76,7 +76,7 @@ public static Query createQueryForMethodWithArgs(String methodName, Object... ar private static MappingAerospikeConverter getMappingAerospikeConverter(AerospikeCustomConversions conversions) { MappingAerospikeConverter converter = new MappingAerospikeConverter(new AerospikeMappingContext(), - conversions, new AerospikeTypeAliasAccessor(), AerospikeDataSettings.builder().build()); + conversions, new AerospikeTypeAliasAccessor(), new AerospikeDataSettings()); converter.afterPropertiesSet(); return converter; } diff --git a/src/test/java/org/springframework/data/aerospike/utility/TimeUtilsTests.java b/src/test/java/org/springframework/data/aerospike/utility/TimeUtilsTests.java index 46521ab78..38109f4b4 100644 --- a/src/test/java/org/springframework/data/aerospike/utility/TimeUtilsTests.java +++ b/src/test/java/org/springframework/data/aerospike/utility/TimeUtilsTests.java @@ -3,14 +3,10 @@ import org.assertj.core.data.Offset; import org.joda.time.DateTime; import org.junit.jupiter.api.Test; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.aerospike.query.cache.IndexRefresher.INDEX_CACHE_REFRESH_SECONDS; import static org.springframework.data.aerospike.sample.SampleClasses.EXPIRATION_ONE_SECOND; -@TestPropertySource(properties = {INDEX_CACHE_REFRESH_SECONDS + " = 0", "createIndexesOnStartup = false"}) -// this test class does not require secondary indexes created on startup public class TimeUtilsTests { @Test diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties new file mode 100644 index 000000000..7030f0c82 --- /dev/null +++ b/src/test/resources/application.properties @@ -0,0 +1,9 @@ +spring-data-aerospike.connection.hosts=${embedded.aerospike.host}:${embedded.aerospike.port} +spring-data-aerospike.connection.namespace=${embedded.aerospike.namespace} +spring-data-aerospike.data.scans-enabled=true +spring-data-aerospike.data.create-indexes-on-startup=false +spring-data-aerospike.data.index-cache-refresh-seconds=0 +spring-data-aerospike.data.server-version-refresh-seconds=0 +spring-data-aerospike.data.query-max-records=5000 +spring-data-aerospike.data.batch-write-size=100 +spring-data-aerospike.data.keep-original-key-types=false \ No newline at end of file