mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-04 00:09:01 +00:00
Add nullability annotations to module/spring-boot-graphql-test
See gh-46587
This commit is contained in:
+12
-3
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.springframework.boot.test.graphql.tester;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aot.AotDetector;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -41,6 +44,7 @@ import org.springframework.test.context.ContextCustomizer;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
import org.springframework.test.context.TestContextAnnotationUtils;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
@@ -59,6 +63,7 @@ class HttpGraphQlTesterContextCustomizer implements ContextCustomizer {
|
||||
}
|
||||
SpringBootTest springBootTest = TestContextAnnotationUtils.findMergedAnnotation(mergedConfig.getTestClass(),
|
||||
SpringBootTest.class);
|
||||
Assert.state(springBootTest != null, "'springBootTest' must not be null");
|
||||
if (springBootTest.webEnvironment().isEmbedded()) {
|
||||
registerHttpGraphQlTester(context);
|
||||
}
|
||||
@@ -78,7 +83,7 @@ class HttpGraphQlTesterContextCustomizer implements ContextCustomizer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
return (obj != null) && (obj.getClass() == getClass());
|
||||
}
|
||||
|
||||
@@ -89,6 +94,7 @@ class HttpGraphQlTesterContextCustomizer implements ContextCustomizer {
|
||||
|
||||
static class HttpGraphQlTesterRegistrar implements BeanDefinitionRegistryPostProcessor, Ordered, BeanFactoryAware {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
@@ -126,9 +132,10 @@ class HttpGraphQlTesterContextCustomizer implements ContextCustomizer {
|
||||
|
||||
private static final String REACTIVE_APPLICATION_CONTEXT_CLASS = "org.springframework.boot.web.context.reactive.ReactiveWebApplicationContext";
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
private HttpGraphQlTester object;
|
||||
private @Nullable HttpGraphQlTester object;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
@@ -183,7 +190,9 @@ class HttpGraphQlTesterContextCustomizer implements ContextCustomizer {
|
||||
|
||||
}
|
||||
else if (webApplicationType == WebApplicationType.SERVLET) {
|
||||
serverBasePath = ((WebApplicationContext) this.applicationContext).getServletContext().getContextPath();
|
||||
ServletContext servletContext = ((WebApplicationContext) this.applicationContext).getServletContext();
|
||||
Assert.state(servletContext != null, "'servletContext' must not be null");
|
||||
serverBasePath = servletContext.getContextPath();
|
||||
}
|
||||
return (serverBasePath != null) ? serverBasePath : "";
|
||||
}
|
||||
|
||||
+3
-1
@@ -18,6 +18,8 @@ package org.springframework.boot.test.graphql.tester;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.graphql.test.tester.HttpGraphQlTester;
|
||||
import org.springframework.test.context.ContextConfigurationAttributes;
|
||||
@@ -39,7 +41,7 @@ class HttpGraphQlTesterContextCustomizerFactory implements ContextCustomizerFact
|
||||
private static final String WEBTESTCLIENT_CLASS = "org.springframework.test.web.reactive.server.WebTestClient";
|
||||
|
||||
@Override
|
||||
public ContextCustomizer createContextCustomizer(Class<?> testClass,
|
||||
public @Nullable ContextCustomizer createContextCustomizer(Class<?> testClass,
|
||||
List<ContextConfigurationAttributes> configAttributes) {
|
||||
SpringBootTest springBootTest = TestContextAnnotationUtils.findMergedAnnotation(testClass,
|
||||
SpringBootTest.class);
|
||||
|
||||
+3
@@ -17,4 +17,7 @@
|
||||
/**
|
||||
* {@link org.springframework.graphql.test.tester.GraphQlTester} utilities.
|
||||
*/
|
||||
@NullMarked
|
||||
package org.springframework.boot.test.graphql.tester;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
Reference in New Issue
Block a user