Polish
This commit is contained in:
parent
4c71e8124d
commit
faeda6f917
|
|
@ -221,10 +221,9 @@ public final class ConnectionFactoryBuilder {
|
|||
String[] protocols = protocol.split(COLON, 2);
|
||||
String driverDelegate = protocols[0];
|
||||
String protocolDelegate = (protocols.length != 2) ? "" : protocols[1];
|
||||
ConnectionFactoryOptions newOptions = ConnectionFactoryOptions.builder().from(options)
|
||||
return ConnectionFactoryOptions.builder().from(options)
|
||||
.option(ConnectionFactoryOptions.DRIVER, driverDelegate)
|
||||
.option(ConnectionFactoryOptions.PROTOCOL, protocolDelegate).build();
|
||||
return newOptions;
|
||||
}
|
||||
|
||||
ConnectionPoolConfiguration connectionPoolConfiguration(ConnectionFactoryOptions options,
|
||||
|
|
@ -253,8 +252,7 @@ public final class ConnectionFactoryBuilder {
|
|||
map.from(options.getValue(PoolingConnectionFactoryProvider.VALIDATION_QUERY)).to(builder::validationQuery);
|
||||
map.from((Object) options.getValue(PoolingConnectionFactoryProvider.VALIDATION_DEPTH))
|
||||
.as(this::toValidationDepth).to(builder::validationDepth);
|
||||
ConnectionPoolConfiguration build = builder.build();
|
||||
return build;
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private Integer toInteger(Object object) {
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ class ConnectionFactoryBuilderTests {
|
|||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@MethodSource("poolingConnectionProviderOptions")
|
||||
void optionIsMappedWhenCreatingPoolConfiguration(Option option) {
|
||||
String url = "r2dbc:pool:h2:mem:///" + UUID.randomUUID().toString();
|
||||
String url = "r2dbc:pool:h2:mem:///" + UUID.randomUUID();
|
||||
ExpectedOption expectedOption = ExpectedOption.get(option);
|
||||
ConnectionFactoryOptions options = ConnectionFactoryBuilder.withUrl(url).configure((builder) -> builder
|
||||
.option(PoolingConnectionFactoryProvider.POOL_NAME, "defaultName").option(option, expectedOption.value))
|
||||
|
|
@ -202,7 +202,7 @@ class ConnectionFactoryBuilderTests {
|
|||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@MethodSource("poolingConnectionProviderOptions")
|
||||
void stringlyTypedOptionIsMappedWhenCreatingPoolConfiguration(Option option) {
|
||||
String url = "r2dbc:pool:h2:mem:///" + UUID.randomUUID().toString();
|
||||
String url = "r2dbc:pool:h2:mem:///" + UUID.randomUUID();
|
||||
ExpectedOption expectedOption = ExpectedOption.get(option);
|
||||
ConnectionFactoryOptions options = ConnectionFactoryBuilder.withUrl(url)
|
||||
.configure((builder) -> builder.option(PoolingConnectionFactoryProvider.POOL_NAME, "defaultName")
|
||||
|
|
@ -213,6 +213,14 @@ class ConnectionFactoryBuilderTests {
|
|||
assertThat(configuration).extracting(expectedOption.property).isEqualTo(expectedOption.value);
|
||||
}
|
||||
|
||||
private static Iterable<Arguments> poolingConnectionProviderOptions() {
|
||||
List<Arguments> arguments = new ArrayList<>();
|
||||
ReflectionUtils.doWithFields(PoolingConnectionFactoryProvider.class,
|
||||
(field) -> arguments.add(Arguments.of(ReflectionUtils.getField(field, null))),
|
||||
(field) -> Option.class.equals(field.getType()));
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private void assertMatchingOptions(ConnectionFactoryOptions actualOptions, ConnectionFactoryOptions expectedOptions,
|
||||
Option<?>... optionsToCheck) {
|
||||
for (Option<?> option : optionsToCheck) {
|
||||
|
|
@ -220,14 +228,6 @@ class ConnectionFactoryBuilderTests {
|
|||
}
|
||||
}
|
||||
|
||||
private static Iterable<Arguments> poolingConnectionProviderOptions() {
|
||||
List<Arguments> arguments = new ArrayList<>();
|
||||
ReflectionUtils.doWithFields(PoolingConnectionFactoryProvider.class,
|
||||
(field) -> arguments.add(Arguments.of((Option<?>) ReflectionUtils.getField(field, null))),
|
||||
(field) -> Option.class.equals(field.getType()));
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private enum ExpectedOption {
|
||||
|
||||
ACQUIRE_RETRY(PoolingConnectionFactoryProvider.ACQUIRE_RETRY, 4, "acquireRetry"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue