From ccbfcbedf0a852ad395345b33bb3faae62cb9fba Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 28 Mar 2018 13:42:33 +0200 Subject: [PATCH] Add support for org.jooq.RecordUnmapperProvider Closes gh-12560 --- .../jooq/JooqAutoConfiguration.java | 8 ++++ .../jooq/JooqAutoConfigurationTests.java | 39 +++++++++++++------ .../main/asciidoc/spring-boot-features.adoc | 1 + 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java index 870ffa4621..bf8052bb99 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java @@ -23,6 +23,7 @@ import org.jooq.DSLContext; import org.jooq.ExecuteListenerProvider; import org.jooq.RecordListenerProvider; import org.jooq.RecordMapperProvider; +import org.jooq.RecordUnmapperProvider; import org.jooq.TransactionProvider; import org.jooq.VisitListenerProvider; import org.jooq.conf.Settings; @@ -94,6 +95,8 @@ public class JooqAutoConfiguration { private final RecordMapperProvider recordMapperProvider; + private final RecordUnmapperProvider recordUnmapperProvider; + private final Settings settings; private final RecordListenerProvider[] recordListenerProviders; @@ -106,6 +109,7 @@ public class JooqAutoConfiguration { ConnectionProvider connectionProvider, DataSource dataSource, ObjectProvider transactionProvider, ObjectProvider recordMapperProvider, + ObjectProvider recordUnmapperProvider, ObjectProvider settings, ObjectProvider recordListenerProviders, ExecuteListenerProvider[] executeListenerProviders, @@ -115,6 +119,7 @@ public class JooqAutoConfiguration { this.dataSource = dataSource; this.transactionProvider = transactionProvider.getIfAvailable(); this.recordMapperProvider = recordMapperProvider.getIfAvailable(); + this.recordUnmapperProvider = recordUnmapperProvider.getIfAvailable(); this.settings = settings.getIfAvailable(); this.recordListenerProviders = recordListenerProviders.getIfAvailable(); this.executeListenerProviders = executeListenerProviders; @@ -138,6 +143,9 @@ public class JooqAutoConfiguration { if (this.recordMapperProvider != null) { configuration.set(this.recordMapperProvider); } + if (this.recordUnmapperProvider != null) { + configuration.set(this.recordUnmapperProvider); + } if (this.settings != null) { configuration.set(this.settings); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java index c316614f67..625c7d9b39 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java @@ -27,6 +27,8 @@ import org.jooq.RecordListenerProvider; import org.jooq.RecordMapper; import org.jooq.RecordMapperProvider; import org.jooq.RecordType; +import org.jooq.RecordUnmapper; +import org.jooq.RecordUnmapperProvider; import org.jooq.SQLDialect; import org.jooq.TransactionalRunnable; import org.jooq.VisitListener; @@ -134,18 +136,21 @@ public class JooqAutoConfigurationTests { public void customProvidersArePickedUp() { this.contextRunner.withUserConfiguration(JooqDataSourceConfiguration.class, TxManagerConfiguration.class, TestRecordMapperProvider.class, - TestRecordListenerProvider.class, TestExecuteListenerProvider.class, - TestVisitListenerProvider.class).run((context) -> { - DSLContext dsl = context.getBean(DSLContext.class); - assertThat(dsl.configuration().recordMapperProvider().getClass()) - .isEqualTo(TestRecordMapperProvider.class); - assertThat(dsl.configuration().recordListenerProviders().length) - .isEqualTo(1); - assertThat(dsl.configuration().executeListenerProviders().length) - .isEqualTo(2); - assertThat(dsl.configuration().visitListenerProviders().length) - .isEqualTo(1); - }); + TestRecordUnmapperProvider.class, TestRecordListenerProvider.class, + TestExecuteListenerProvider.class, TestVisitListenerProvider.class + ).run((context) -> { + DSLContext dsl = context.getBean(DSLContext.class); + assertThat(dsl.configuration().recordMapperProvider().getClass()) + .isEqualTo(TestRecordMapperProvider.class); + assertThat(dsl.configuration().recordUnmapperProvider().getClass()) + .isEqualTo(TestRecordUnmapperProvider.class); + assertThat(dsl.configuration().recordListenerProviders().length) + .isEqualTo(1); + assertThat(dsl.configuration().executeListenerProviders().length) + .isEqualTo(2); + assertThat(dsl.configuration().visitListenerProviders().length) + .isEqualTo(1); + }); } @Test @@ -230,6 +235,16 @@ public class JooqAutoConfigurationTests { } + protected static class TestRecordUnmapperProvider implements RecordUnmapperProvider { + + @Override + public RecordUnmapper provide( + Class aClass, RecordType recordType) { + return null; + } + + } + protected static class TestRecordListenerProvider implements RecordListenerProvider { @Override diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index a2afc0fd30..05c91f0875 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -3733,6 +3733,7 @@ following jOOQ Types: * `ConnectionProvider` * `TransactionProvider` * `RecordMapperProvider` +* `RecordUnmapperProvider` * `RecordListenerProvider` * `ExecuteListenerProvider` * `VisitListenerProvider`