diff --git a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeAutoConfiguration.java b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeAutoConfiguration.java index e3d58db..14a71fe 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeAutoConfiguration.java +++ b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeAutoConfiguration.java @@ -32,6 +32,6 @@ @AutoConfiguration @ConditionalOnClass(IAerospikeClient.class) @ConditionalOnProperty("spring.aerospike.hosts") -@EnableConfigurationProperties({AerospikeProperties.class, AerospikeDataProperties.class}) // TODO: shoud data properties be here? +@EnableConfigurationProperties({AerospikeProperties.class, AerospikeDataProperties.class}) // TODO: should data properties be here? public class AerospikeAutoConfiguration { } diff --git a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeProperties.java b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeProperties.java index 620f4ab..41eb916 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeProperties.java +++ b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeProperties.java @@ -157,7 +157,7 @@ public abstract static class PolicyDefault { public Duration sleepBetweenRetries; /** - * If the key is sent on a write, the key will be stored with the record on the server. + * If the key is sent in a write operation, it will be stored with the record on the server. */ public Boolean sendKey; } diff --git a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataProperties.java b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataProperties.java index a1974f0..7564e2d 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataProperties.java +++ b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataProperties.java @@ -19,7 +19,6 @@ import lombok.Getter; import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.data.aerospike.config.AerospikeDataSettings; /** * Configuration properties for Spring Data Aerospike. @@ -38,12 +37,12 @@ public class AerospikeDataProperties { private String namespace; /** - * Bin name that will be used for storing entity's type. + * Bin name that will be used for storing entity's type. Default value is null *

* * @see org.springframework.data.aerospike.convert.AerospikeTypeAliasAccessor */ - private String typeKey = "@_class"; + private String classKey = "@_class"; /** * Gives ability to disable queries that will run scan on Aerospike server. diff --git a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeReactiveDataConfiguration.java b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeReactiveDataConfiguration.java index 488154d..7c7a386 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeReactiveDataConfiguration.java +++ b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeReactiveDataConfiguration.java @@ -58,7 +58,7 @@ protected String nameSpace() { } @Override - protected EventLoops eventLoops() { + public EventLoops eventLoops() { return new NioEventLoops(); } diff --git a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/utils/AerospikeConfigurationUtils.java b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/utils/AerospikeConfigurationUtils.java index 12e3b1e..abfbe98 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/utils/AerospikeConfigurationUtils.java +++ b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/utils/AerospikeConfigurationUtils.java @@ -59,6 +59,9 @@ public static ClientPolicy getClientPolicyConfig(ClientPolicy clientPolicy, Aero clientPolicy.batchUDFPolicyDefault = setupBatchUDFPolicy(properties); // aerospikeEventLoops.ifPresent(loops -> clientPolicy.eventLoops = loops); // TODO +// clientPolicy.user = "tester"; +// clientPolicy.password = "psw"; + return clientPolicy; } diff --git a/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataAutoConfigurationTest.java b/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataAutoConfigurationTest.java index 20e0d15..e8ed9e9 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataAutoConfigurationTest.java +++ b/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataAutoConfigurationTest.java @@ -17,6 +17,7 @@ package org.springframework.boot.autoconfigure.data.aerospike; import com.aerospike.client.AerospikeClient; +import com.aerospike.client.IAerospikeClient; import com.aerospike.client.reactor.AerospikeReactorClient; import com.aerospike.client.reactor.IAerospikeReactorClient; import com.aerospike.client.reactor.retry.AerospikeReactorRetryClient; @@ -84,16 +85,16 @@ public void classKeyDefault() { AerospikeTypeAliasAccessor aliasAccessor = context.getBean(AerospikeTypeAliasAccessor.class); String classKey = getField(aliasAccessor, "classKey"); - assertThat(classKey).isEqualTo(AerospikeConverter.CLASS_KEY); + assertThat(classKey).isEqualTo(AerospikeConverter.CLASS_KEY_DEFAULT); }); } -// @Test // TODO: requires ability to configure typeKey + @Test public void typeKeyCanBeCustomized() { contextRunner .withPropertyValues("spring.aerospike.hosts=localhost:3000") .withPropertyValues("spring.data.aerospike.namespace=TEST") - .withPropertyValues("spring.data.aerospike.type-key=++amazing++") + .withPropertyValues("spring.data.aerospike.class-key=++amazing++") .run((context) -> { AerospikeTypeAliasAccessor aliasAccessor = context.getBean(AerospikeTypeAliasAccessor.class); String typeKey = getField(aliasAccessor, "classKey"); @@ -102,12 +103,12 @@ public void typeKeyCanBeCustomized() { }); } -// @Test + @Test public void typeKeyCanBeNull() { contextRunner .withPropertyValues("spring.aerospike.hosts=localhost:3000") .withPropertyValues("spring.data.aerospike.namespace=TEST") - .withPropertyValues("spring.data.aerospike.type-key=") + .withPropertyValues("spring.data.aerospike.class-key=") .run((context) -> { AerospikeTypeAliasAccessor aliasAccessor = context.getBean(AerospikeTypeAliasAccessor.class); String typeKey = getField(aliasAccessor, "classKey"); @@ -116,9 +117,7 @@ public void typeKeyCanBeNull() { }); } -// @Test - // TODO: there already is CustomConversions bean, needs a change: override the method - // or change SpringData Aerospike + @Test public void customConversions() { contextRunner .withPropertyValues("spring.aerospike.hosts=localhost:3000") @@ -130,6 +129,27 @@ public void customConversions() { }); } + @Test + public void sendKeyPropertyIsRead() { + contextRunner + .withPropertyValues("spring.aerospike.hosts=localhost:3000") + .withPropertyValues("spring.data.aerospike.namespace=TEST") + .withPropertyValues("spring.aerospike.write.sendKey=false") + .run(context -> { + IAerospikeClient client = context.getBean(IAerospikeClient.class); + assertThat(client.getWritePolicyDefault().sendKey).isFalse(); + }); + + contextRunner + .withPropertyValues("spring.aerospike.hosts=localhost:3000") + .withPropertyValues("spring.data.aerospike.namespace=TEST") + .withPropertyValues("spring.aerospike.write.sendKey=true") + .run(context -> { + IAerospikeClient client = context.getBean(IAerospikeClient.class); + assertThat(client.getWritePolicyDefault().sendKey).isTrue(); + }); + } + @Test public void configurationIsApplied() { contextRunner diff --git a/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeReactiveDataAutoConfigurationTest.java b/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeReactiveDataAutoConfigurationTest.java index 024e0bd..9bc5844 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeReactiveDataAutoConfigurationTest.java +++ b/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeReactiveDataAutoConfigurationTest.java @@ -71,7 +71,7 @@ public void entityScanShouldSetInitialEntitySet() { }); } -// @Test // TODO: requires ability to configure typeKey + @Test public void classKeyDefault() { contextRunner .withPropertyValues("spring.aerospike.hosts=localhost:3000") @@ -80,16 +80,16 @@ public void classKeyDefault() { AerospikeTypeAliasAccessor aliasAccessor = context.getBean(AerospikeTypeAliasAccessor.class); String typeKey = getField(aliasAccessor, "classKey"); - assertThat(typeKey).isEqualTo(AerospikeConverter.CLASS_KEY); + assertThat(typeKey).isEqualTo(AerospikeConverter.CLASS_KEY_DEFAULT); }); } -// @Test + @Test public void classKeyCanBeCustomized() { contextRunner .withPropertyValues("spring.aerospike.hosts=localhost:3000") .withPropertyValues("spring.data.aerospike.namespace=TEST") - .withPropertyValues("spring.data.aerospike.type-key=++amazing++") + .withPropertyValues("spring.data.aerospike.class-key=++amazing++") .run((context) -> { AerospikeTypeAliasAccessor aliasAccessor = context.getBean(AerospikeTypeAliasAccessor.class); String typeKey = getField(aliasAccessor, "classKey"); @@ -98,16 +98,12 @@ public void classKeyCanBeCustomized() { }); } -// @Test - // TODO: there already is CustomConversions bean, needs a change: override the method - // or change SpringData Aerospike + @Test public void customConversions() { contextRunner .withPropertyValues("spring.aerospike.hosts=localhost:3000") .withPropertyValues("spring.data.aerospike.namespace=TEST") - .withUserConfiguration(AerospikeTestConfigurations.CustomConversionsConfig.class, - AerospikeClientMockConfiguration.class, MockReactiveIndexRefresher.class, - AerospikeServerVersionSupportMockConfiguration.class) + .withUserConfiguration(AerospikeTestConfigurations.CustomConversionsConfig.class) .run(context -> { MappingAerospikeConverter converter = context.getBean(MappingAerospikeConverter.class); assertThat(converter.getConversionService().canConvert(City.class, String.class)).isTrue(); diff --git a/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeTestConfigurations.java b/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeTestConfigurations.java index f771852..04a7111 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeTestConfigurations.java +++ b/spring-boot-autoconfigure-data-aerospike/src/test/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeTestConfigurations.java @@ -8,7 +8,7 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Bean; import org.springframework.core.convert.converter.Converter; -import org.springframework.data.aerospike.convert.AerospikeCustomConversions; +import org.springframework.data.aerospike.convert.AerospikeCustomConverters; import org.springframework.data.aerospike.query.cache.ReactorIndexRefresher; import org.springframework.data.aerospike.server.version.ServerVersionSupport; @@ -60,9 +60,9 @@ public static class EntityScanConfiguration { @AutoConfiguration public static class CustomConversionsConfig { - @Bean(name = "aerospikeCustomConversions") - AerospikeCustomConversions myCustomConversions() { - return new AerospikeCustomConversions(List.of(new CityToStringConverter())); + @Bean + AerospikeCustomConverters myCustomConversions() { + return new AerospikeCustomConverters(List.of(new CityToStringConverter())); } }