diff --git a/samples/webflux-websocket/src/test/java/io/spring/sample/graphql/QueryTests.java b/samples/webflux-websocket/src/test/java/io/spring/sample/graphql/QueryTests.java index eb285d6a..946bd991 100644 --- a/samples/webflux-websocket/src/test/java/io/spring/sample/graphql/QueryTests.java +++ b/samples/webflux-websocket/src/test/java/io/spring/sample/graphql/QueryTests.java @@ -20,23 +20,27 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.graphql.GraphQlService; +import org.springframework.graphql.boot.test.GraphQlTest; import org.springframework.graphql.test.tester.GraphQlTester; -import org.springframework.graphql.test.tester.WebGraphQlTester; -import org.springframework.graphql.web.WebGraphQlHandler; /** * GraphQL query tests directly via {@link GraphQL}. */ -@SpringBootTest +@GraphQlTest(controllers = SampleController.class, + includeFilters = @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = {ContextWebFilter.class, DataRepository.class})) public class QueryTests { private GraphQlTester graphQlTester; @BeforeEach - public void setUp(@Autowired WebGraphQlHandler handler) { - this.graphQlTester = WebGraphQlTester.create(webInput -> - handler.handleRequest(webInput).contextWrite(context -> context.put("name", "James"))); + public void setUp(@Autowired GraphQlService service) { + this.graphQlTester = GraphQlTester.create(requestInput -> + service.execute(requestInput).contextWrite(context -> context.put("name", "James"))); } @Test diff --git a/samples/webflux-websocket/src/test/java/io/spring/sample/graphql/SubscriptionTests.java b/samples/webflux-websocket/src/test/java/io/spring/sample/graphql/SubscriptionTests.java index e5019a11..5321d660 100644 --- a/samples/webflux-websocket/src/test/java/io/spring/sample/graphql/SubscriptionTests.java +++ b/samples/webflux-websocket/src/test/java/io/spring/sample/graphql/SubscriptionTests.java @@ -22,23 +22,27 @@ import reactor.core.publisher.Flux; import reactor.test.StepVerifier; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.graphql.GraphQlService; +import org.springframework.graphql.boot.test.GraphQlTest; import org.springframework.graphql.test.tester.GraphQlTester; -import org.springframework.graphql.test.tester.WebGraphQlTester; -import org.springframework.graphql.web.WebGraphQlHandler; /** * GraphQL subscription tests directly via {@link GraphQL}. */ -@SpringBootTest +@GraphQlTest(controllers = SampleController.class, + includeFilters = @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = {ContextWebFilter.class, DataRepository.class})) public class SubscriptionTests { private GraphQlTester graphQlTester; @BeforeEach - public void setUp(@Autowired WebGraphQlHandler handler) { - this.graphQlTester = WebGraphQlTester.create(webInput -> - handler.handleRequest(webInput).contextWrite(context -> context.put("name", "James"))); + public void setUp(@Autowired GraphQlService service) { + this.graphQlTester = GraphQlTester.create(requestInput -> + service.execute(requestInput).contextWrite(context -> context.put("name", "James"))); } @Test diff --git a/samples/webmvc-http-security/src/test/java/io/spring/sample/graphql/SampleApplicationTests.java b/samples/webmvc-http-security/src/test/java/io/spring/sample/graphql/SampleApplicationTests.java index 8885ed50..32a9ddc6 100644 --- a/samples/webmvc-http-security/src/test/java/io/spring/sample/graphql/SampleApplicationTests.java +++ b/samples/webmvc-http-security/src/test/java/io/spring/sample/graphql/SampleApplicationTests.java @@ -1,8 +1,8 @@ package io.spring.sample.graphql; import org.junit.jupiter.api.Test; + import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.graphql.boot.test.tester.AutoConfigureWebGraphQlTester; import org.springframework.graphql.execution.ErrorType; @@ -12,7 +12,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @SpringBootTest -@AutoConfigureMockMvc @AutoConfigureWebGraphQlTester class SampleApplicationTests {