From f072795d8a6171489337cb1756f18ff7cf5b9a45 Mon Sep 17 00:00:00 2001 From: Victor Gabriel <100782235+vitinh0z@users.noreply.github.com> Date: Tue, 16 Dec 2025 14:19:46 +0000 Subject: [PATCH 1/3] Fix: Remove duplicate commons-io dependency in pom.xml --- pom.xml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index fc13b6e7..61032926 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ - + 4.0.0 github-java-client github-client @@ -276,12 +276,6 @@ ${okhttp.version} test - - commons-io - commons-io - 2.14.0 - compile - From 457a590843af8750291da1a53516223cf7ee2c24 Mon Sep 17 00:00:00 2001 From: Victor Gabriel <100782235+vitinh0z@users.noreply.github.com> Date: Tue, 16 Dec 2025 14:27:26 +0000 Subject: [PATCH 2/3] Fix: Remove duplicate dependency and invalid root attribute in pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 61032926..21bbb319 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ - + 4.0.0 github-java-client github-client From d7a4c5f23decf18b2dbe7b0760c7bfafa5cf0483 Mon Sep 17 00:00:00 2001 From: Victor Gabriel <100782235+vitinh0z@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:38:08 +0000 Subject: [PATCH 3/3] Feat: Add Spring Boot AutoConfiguration with tests --- pom.xml | 19 +++++- .../spring/GithubClientAutoConfiguration.java | 39 +++++++++++ .../GithubClientAutoConfigurationTest.java | 65 +++++++++++++++++++ ...ot.autoconfigure.AutoConfiguration.imports | 1 + 4 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/spotify/github/v3/spring/GithubClientAutoConfiguration.java create mode 100644 src/test/java/com/spotify/github/v3/spring/GithubClientAutoConfigurationTest.java create mode 100644 src/test/resources/META-INF/Spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/pom.xml b/pom.xml index 21bbb319..6eed5f0d 100644 --- a/pom.xml +++ b/pom.xml @@ -113,6 +113,24 @@ + + org.springframework.boot + spring-boot-autoconfigure + 2.7.18 + true + + + org.springframework.boot + spring-boot-autoconfigure-processor + 2.7.18 + true + + + org.springframework.boot + spring-boot-starter-test + 2.7.18 + test + com.google.guava guava @@ -173,7 +191,6 @@ opencensus-api ${opencensus.version} - io.opentelemetry opentelemetry-api diff --git a/src/main/java/com/spotify/github/v3/spring/GithubClientAutoConfiguration.java b/src/main/java/com/spotify/github/v3/spring/GithubClientAutoConfiguration.java new file mode 100644 index 00000000..4fdaad79 --- /dev/null +++ b/src/main/java/com/spotify/github/v3/spring/GithubClientAutoConfiguration.java @@ -0,0 +1,39 @@ +/*- + * -\-\- + * github-api + * -- + * Copyright (C) 2016 - 2025 Spotify AB + * -- + * 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 + * + * http://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 com.spotify.github.v3.spring; + +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.context.annotation.Bean; + +import com.spotify.github.v3.clients.GitHubClient; + +@AutoConfiguration +@ConditionalOnClass(GitHubClient.class) +public class GithubClientAutoConfiguration { + + @Bean + @ConditionalOnBean + public GitHubClient gitHubClient() { + return GitHubClient.create(null, null); + } +} diff --git a/src/test/java/com/spotify/github/v3/spring/GithubClientAutoConfigurationTest.java b/src/test/java/com/spotify/github/v3/spring/GithubClientAutoConfigurationTest.java new file mode 100644 index 00000000..7d5eac41 --- /dev/null +++ b/src/test/java/com/spotify/github/v3/spring/GithubClientAutoConfigurationTest.java @@ -0,0 +1,65 @@ +/*- + * -\-\- + * github-api + * -- + * Copyright (C) 2016 - 2025 Spotify AB + * -- + * 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 + * + * http://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 com.spotify.github.v3.spring; + +import org.junit.Test; +import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import static org.assertj.core.api.Assertions.assertThat; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.spotify.github.jackson.GithubApiModule; + +public class GithubClientAutoConfigurationTest { + + + private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(GithubClientAutoConfiguration.class)); + + @Test + public void testModuleIsRegistered(){ + + this.contextRunner + .withUserConfiguration(JacksonConfig.class) + .run((context) -> { + assertThat(context).hasSingleBean(GithubApiModule.class); + }); + } + + @Test + public void testModuleIsNotRegisteredIfObjectMapperMissing(){ + + this.contextRunner + .run((context) -> { + assertThat(context).doesNotHaveBean(GithubApiModule.class); + }); + } + + @Configuration + static class JacksonConfig { + + @Bean + public ObjectMapper objectMapper() { + return new ObjectMapper(); + } + } +} diff --git a/src/test/resources/META-INF/Spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/src/test/resources/META-INF/Spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..182f3dbb --- /dev/null +++ b/src/test/resources/META-INF/Spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.spotify.github.v3.spring.GithubClientAutoConfiguration \ No newline at end of file