From 1e61beb0a4d6a464dc1af3013ecccd326bf2a7ea Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 16 Sep 2020 16:09:37 +0200 Subject: [PATCH] Remove auto-configurations from starter modules --- spring-boot-starter-graphql-web/build.gradle | 1 - .../servlet/GraphQLEndpointConfiguration.java | 23 -------- .../boot/graphql/servlet/package-info.java | 6 -- .../main/resources/META-INF/spring.factories | 2 - .../boot/graphql/servlet/IntegrationTest.java | 54 ------------------ .../servlet/IntegrationTestConfig.java | 18 ------ .../GraphQLEndpointConfiguration.java | 23 -------- .../boot/graphql/reactive/package-info.java | 6 -- .../main/resources/META-INF/spring.factories | 2 +- .../graphql/reactive/IntegrationTest.java | 56 ------------------- .../reactive/IntegrationTestConfig.java | 18 ------ 11 files changed, 1 insertion(+), 208 deletions(-) delete mode 100644 spring-boot-starter-graphql-web/src/main/java/org/springframework/boot/graphql/servlet/GraphQLEndpointConfiguration.java delete mode 100644 spring-boot-starter-graphql-web/src/main/java/org/springframework/boot/graphql/servlet/package-info.java delete mode 100644 spring-boot-starter-graphql-web/src/main/resources/META-INF/spring.factories delete mode 100644 spring-boot-starter-graphql-web/src/test/java/org/springframework/boot/graphql/servlet/IntegrationTest.java delete mode 100644 spring-boot-starter-graphql-web/src/test/java/org/springframework/boot/graphql/servlet/IntegrationTestConfig.java delete mode 100644 spring-boot-starter-graphql-webflux/src/main/java/org/springframework/boot/graphql/reactive/GraphQLEndpointConfiguration.java delete mode 100644 spring-boot-starter-graphql-webflux/src/main/java/org/springframework/boot/graphql/reactive/package-info.java delete mode 100644 spring-boot-starter-graphql-webflux/src/test/java/org/springframework/boot/graphql/reactive/IntegrationTest.java delete mode 100644 spring-boot-starter-graphql-webflux/src/test/java/org/springframework/boot/graphql/reactive/IntegrationTestConfig.java diff --git a/spring-boot-starter-graphql-web/build.gradle b/spring-boot-starter-graphql-web/build.gradle index aba33a6c..b7071f3c 100644 --- a/spring-boot-starter-graphql-web/build.gradle +++ b/spring-boot-starter-graphql-web/build.gradle @@ -2,6 +2,5 @@ description = "Starter for building GraphQL Java applications with Spring MVC" dependencies { api project(':spring-graphql-web') - api 'io.projectreactor:reactor-core' api 'org.springframework.boot:spring-boot-starter-web' } diff --git a/spring-boot-starter-graphql-web/src/main/java/org/springframework/boot/graphql/servlet/GraphQLEndpointConfiguration.java b/spring-boot-starter-graphql-web/src/main/java/org/springframework/boot/graphql/servlet/GraphQLEndpointConfiguration.java deleted file mode 100644 index a0dab9b5..00000000 --- a/spring-boot-starter-graphql-web/src/main/java/org/springframework/boot/graphql/servlet/GraphQLEndpointConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.springframework.boot.graphql.servlet; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.graphql.servlet.components.GraphQLController; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -import javax.annotation.PostConstruct; - -@Configuration -@ConditionalOnWebApplication -@ComponentScan(basePackageClasses = GraphQLController.class) -public class GraphQLEndpointConfiguration { - - @Autowired - ApplicationContext applicationContext; - - @PostConstruct - public void init() { - } -} diff --git a/spring-boot-starter-graphql-web/src/main/java/org/springframework/boot/graphql/servlet/package-info.java b/spring-boot-starter-graphql-web/src/main/java/org/springframework/boot/graphql/servlet/package-info.java deleted file mode 100644 index 7909e686..00000000 --- a/spring-boot-starter-graphql-web/src/main/java/org/springframework/boot/graphql/servlet/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -@NonNullApi -@NonNullFields -package org.springframework.boot.graphql.servlet; - -import org.springframework.lang.NonNullApi; -import org.springframework.lang.NonNullFields; diff --git a/spring-boot-starter-graphql-web/src/main/resources/META-INF/spring.factories b/spring-boot-starter-graphql-web/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 94fbd530..00000000 --- a/spring-boot-starter-graphql-web/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.springframework.boot.graphql.servlet.GraphQLEndpointConfiguration diff --git a/spring-boot-starter-graphql-web/src/test/java/org/springframework/boot/graphql/servlet/IntegrationTest.java b/spring-boot-starter-graphql-web/src/test/java/org/springframework/boot/graphql/servlet/IntegrationTest.java deleted file mode 100644 index e1f689e8..00000000 --- a/spring-boot-starter-graphql-web/src/test/java/org/springframework/boot/graphql/servlet/IntegrationTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.springframework.boot.graphql.servlet; - -import graphql.ExecutionInput; -import graphql.ExecutionResultImpl; -import graphql.GraphQL; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -import static org.assertj.core.api.Assertions.assertThat; - - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ExtendWith(SpringExtension.class) -public class IntegrationTest { - - @Autowired - private TestRestTemplate restTemplate; - - @Autowired - GraphQL graphql; - - @Test - public void endpointIsAvailable() { - String query = "{foo}"; - - ExecutionResultImpl executionResult = ExecutionResultImpl.newExecutionResult() - .data("bar") - .build(); - CompletableFuture cf = CompletableFuture.completedFuture(executionResult); - ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionInput.class); - Mockito.when(graphql.executeAsync(captor.capture())).thenReturn(cf); - - Map body = new LinkedHashMap<>(); - body.put("query", query); - - ResponseEntity responseEntity = this.restTemplate.postForEntity("/graphql", body, Map.class); - - Map responseBody = (Map) responseEntity.getBody(); - assertThat(responseBody.get("data")).isEqualTo("bar"); - assertThat(captor.getValue().getQuery()).isEqualTo(query); - } - -} \ No newline at end of file diff --git a/spring-boot-starter-graphql-web/src/test/java/org/springframework/boot/graphql/servlet/IntegrationTestConfig.java b/spring-boot-starter-graphql-web/src/test/java/org/springframework/boot/graphql/servlet/IntegrationTestConfig.java deleted file mode 100644 index 0d77f0aa..00000000 --- a/spring-boot-starter-graphql-web/src/test/java/org/springframework/boot/graphql/servlet/IntegrationTestConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.springframework.boot.graphql.servlet; - -import graphql.GraphQL; -import org.mockito.Mockito; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -public class IntegrationTestConfig { - - - @Bean - public GraphQL graphQL() { - return Mockito.mock(GraphQL.class); - } - -} - diff --git a/spring-boot-starter-graphql-webflux/src/main/java/org/springframework/boot/graphql/reactive/GraphQLEndpointConfiguration.java b/spring-boot-starter-graphql-webflux/src/main/java/org/springframework/boot/graphql/reactive/GraphQLEndpointConfiguration.java deleted file mode 100644 index b054834f..00000000 --- a/spring-boot-starter-graphql-webflux/src/main/java/org/springframework/boot/graphql/reactive/GraphQLEndpointConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.springframework.boot.graphql.reactive; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.graphql.reactive.components.GraphQLController; - -import javax.annotation.PostConstruct; - -@Configuration -@ConditionalOnWebApplication -@ComponentScan(basePackageClasses = GraphQLController.class) -public class GraphQLEndpointConfiguration { - - @Autowired - ApplicationContext applicationContext; - - @PostConstruct - public void init() { - } -} diff --git a/spring-boot-starter-graphql-webflux/src/main/java/org/springframework/boot/graphql/reactive/package-info.java b/spring-boot-starter-graphql-webflux/src/main/java/org/springframework/boot/graphql/reactive/package-info.java deleted file mode 100644 index b112b1d9..00000000 --- a/spring-boot-starter-graphql-webflux/src/main/java/org/springframework/boot/graphql/reactive/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -@NonNullApi -@NonNullFields -package org.springframework.boot.graphql.reactive; - -import org.springframework.lang.NonNullApi; -import org.springframework.lang.NonNullFields; diff --git a/spring-boot-starter-graphql-webflux/src/main/resources/META-INF/spring.factories b/spring-boot-starter-graphql-webflux/src/main/resources/META-INF/spring.factories index 85517296..90756d27 100644 --- a/spring-boot-starter-graphql-webflux/src/main/resources/META-INF/spring.factories +++ b/spring-boot-starter-graphql-webflux/src/main/resources/META-INF/spring.factories @@ -1,2 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.springframework.boot.graphql.reactive.GraphQLEndpointConfiguration +org.springframework.boot.graphql.reactive.GraphQLWebFluxAutoConfiguration diff --git a/spring-boot-starter-graphql-webflux/src/test/java/org/springframework/boot/graphql/reactive/IntegrationTest.java b/spring-boot-starter-graphql-webflux/src/test/java/org/springframework/boot/graphql/reactive/IntegrationTest.java deleted file mode 100644 index adbb74d7..00000000 --- a/spring-boot-starter-graphql-webflux/src/test/java/org/springframework/boot/graphql/reactive/IntegrationTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.springframework.boot.graphql.reactive; - -import graphql.ExecutionInput; -import graphql.ExecutionResultImpl; -import graphql.GraphQL; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.web.reactive.server.WebTestClient; -import org.springframework.web.reactive.function.BodyInserters; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -import static org.assertj.core.api.Assertions.assertThat; - - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ExtendWith(SpringExtension.class) -public class IntegrationTest { - - @Autowired - WebTestClient webClient; - - @Autowired - GraphQL graphql; - - @Test - public void endpointIsAvailable() { - String query = "{foo}"; - - ExecutionResultImpl executionResult = ExecutionResultImpl.newExecutionResult() - .data("bar") - .build(); - CompletableFuture cf = CompletableFuture.completedFuture(executionResult); - ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionInput.class); - Mockito.when(graphql.executeAsync(captor.capture())).thenReturn(cf); - - Map body = new LinkedHashMap<>(); - body.put("query", query); - - Map expectedResult = new LinkedHashMap<>(); - expectedResult.put("data", "bar"); - - this.webClient.post().uri("/graphql").body(BodyInserters.fromValue(body)).exchange().expectStatus().isOk() - .expectBody(Map.class).isEqualTo(expectedResult); - - Assertions.assertThat(captor.getValue().getQuery()).isEqualTo(query); - } - -} \ No newline at end of file diff --git a/spring-boot-starter-graphql-webflux/src/test/java/org/springframework/boot/graphql/reactive/IntegrationTestConfig.java b/spring-boot-starter-graphql-webflux/src/test/java/org/springframework/boot/graphql/reactive/IntegrationTestConfig.java deleted file mode 100644 index 4387ab1e..00000000 --- a/spring-boot-starter-graphql-webflux/src/test/java/org/springframework/boot/graphql/reactive/IntegrationTestConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.springframework.boot.graphql.reactive; - -import graphql.GraphQL; -import org.mockito.Mockito; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -public class IntegrationTestConfig { - - - @Bean - public GraphQL graphQL() { - return Mockito.mock(GraphQL.class); - } - -} -