mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Polish "Apply GraphQL customizers in order"
See gh-50908
This commit is contained in:
-1
@@ -81,7 +81,6 @@ import org.springframework.web.socket.server.support.WebSocketHandlerMapping;
|
|||||||
* Spring MVC.
|
* Spring MVC.
|
||||||
*
|
*
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @author Yanming Zhou
|
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration(after = GraphQlAutoConfiguration.class)
|
@AutoConfiguration(after = GraphQlAutoConfiguration.class)
|
||||||
|
|||||||
+38
@@ -24,6 +24,7 @@ import graphql.schema.idl.TypeRuntimeWiring;
|
|||||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||||
import org.assertj.core.api.ThrowingConsumer;
|
import org.assertj.core.api.ThrowingConsumer;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.InOrder;
|
||||||
|
|
||||||
import org.springframework.aot.hint.RuntimeHints;
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
@@ -31,6 +32,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|||||||
import org.springframework.boot.graphql.autoconfigure.GraphQlAutoConfiguration;
|
import org.springframework.boot.graphql.autoconfigure.GraphQlAutoConfiguration;
|
||||||
import org.springframework.boot.graphql.autoconfigure.GraphQlTestDataFetchers;
|
import org.springframework.boot.graphql.autoconfigure.GraphQlTestDataFetchers;
|
||||||
import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration;
|
import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration;
|
||||||
|
import org.springframework.boot.http.converter.autoconfigure.ServerHttpMessageConvertersCustomizer;
|
||||||
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
|
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||||
import org.springframework.boot.testsupport.classpath.resources.WithResource;
|
import org.springframework.boot.testsupport.classpath.resources.WithResource;
|
||||||
@@ -56,6 +58,9 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
|
|||||||
import org.springframework.web.socket.server.support.WebSocketHandlerMapping;
|
import org.springframework.web.socket.server.support.WebSocketHandlerMapping;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.inOrder;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,6 +245,22 @@ class GraphQlWebMvcAutoConfigurationTests {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldApplyJsonCustomizersInOrderB() {
|
||||||
|
this.contextRunner.withPropertyValues("spring.graphql.websocket.path=/ws")
|
||||||
|
.withUserConfiguration(CustomJsonConverterConfiguration.class)
|
||||||
|
.run((context) -> {
|
||||||
|
assertThat(context).hasSingleBean(GraphQlWebSocketHandler.class);
|
||||||
|
ServerHttpMessageConvertersCustomizer before = context.getBean("before",
|
||||||
|
ServerHttpMessageConvertersCustomizer.class);
|
||||||
|
ServerHttpMessageConvertersCustomizer after = context.getBean("after",
|
||||||
|
ServerHttpMessageConvertersCustomizer.class);
|
||||||
|
InOrder ordered = inOrder(before, after);
|
||||||
|
ordered.verify(before).customize(any());
|
||||||
|
ordered.verify(after).customize(any());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldConfigureWebSocketProperties() {
|
void shouldConfigureWebSocketProperties() {
|
||||||
this.contextRunner
|
this.contextRunner
|
||||||
@@ -314,6 +335,23 @@ class GraphQlWebMvcAutoConfigurationTests {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
static class CustomJsonConverterConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Order(1)
|
||||||
|
ServerHttpMessageConvertersCustomizer after() {
|
||||||
|
return mock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Order(-1)
|
||||||
|
ServerHttpMessageConvertersCustomizer before() {
|
||||||
|
return mock();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class CustomRouterFunctions {
|
static class CustomRouterFunctions {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user