Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 3ae1db5

Browse files
committed
Fix sonar issues
1 parent 1adce3d commit 3ae1db5

File tree

40 files changed

+122
-125
lines changed

40 files changed

+122
-125
lines changed

example-request-scoped-dataloader/src/main/java/graphql/servlet/examples/dataloader/requestscope/CustomGraphQLContextBuilder.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package graphql.servlet.examples.dataloader.requestscope;
22

3+
import static java.util.concurrent.CompletableFuture.supplyAsync;
4+
35
import graphql.kickstart.execution.context.DefaultGraphQLContext;
46
import graphql.kickstart.execution.context.GraphQLContext;
57
import graphql.kickstart.servlet.context.DefaultGraphQLServletContext;
68
import graphql.kickstart.servlet.context.DefaultGraphQLWebSocketContext;
79
import graphql.kickstart.servlet.context.GraphQLServletContextBuilder;
8-
import java.util.concurrent.CompletableFuture;
910
import javax.servlet.http.HttpServletRequest;
1011
import javax.servlet.http.HttpServletResponse;
1112
import javax.websocket.Session;
@@ -44,10 +45,10 @@ public GraphQLContext build(Session session, HandshakeRequest request) {
4445

4546
private DataLoaderRegistry buildDataLoaderRegistry() {
4647
DataLoaderRegistry dataLoaderRegistry = new DataLoaderRegistry();
47-
dataLoaderRegistry.register("customerDataLoader",
48-
new DataLoader<Integer, String>(customerIds ->
49-
CompletableFuture.supplyAsync(() ->
50-
customerRepository.getUserNamesForIds(customerIds))));
48+
DataLoader<Integer, String> customerLoader = new DataLoader<>(
49+
customerIds -> supplyAsync(() -> customerRepository.getUserNamesForIds(customerIds))
50+
);
51+
dataLoaderRegistry.register("customerDataLoader", customerLoader);
5152
return dataLoaderRegistry;
5253
}
5354
}

example-spring-common/src/main/java/graphql/kickstart/spring/web/boot/sample/ApplicationBootConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@SpringBootApplication
2929
public class ApplicationBootConfiguration {
3030

31-
public static void main(String[] args) throws Exception {
31+
public static void main(String[] args) {
3232
SpringApplication.run(ApplicationBootConfiguration.class, args);
3333
}
3434
}

example-webflux/src/main/java/graphql/kickstart/spring/web/boot/sample/ApplicationWebfluxConfiguration.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
package graphql.kickstart.spring.web.boot.sample;
2121

2222
import graphql.Scalars;
23+
import graphql.schema.DataFetcher;
24+
import graphql.schema.FieldCoordinates;
25+
import graphql.schema.GraphQLCodeRegistry;
2326
import graphql.schema.GraphQLObjectType;
2427
import graphql.schema.GraphQLSchema;
2528
import org.springframework.boot.SpringApplication;
@@ -40,15 +43,18 @@ public static void main(String[] args) {
4043

4144
@Bean
4245
GraphQLSchema schema() {
46+
DataFetcher<String> test = env -> "response";
4347
return GraphQLSchema.newSchema()
4448
.query(GraphQLObjectType.newObject()
4549
.name("query")
4650
.field(field -> field
4751
.name("test")
4852
.type(Scalars.GraphQLString)
49-
.dataFetcher(environment -> "response")
5053
)
5154
.build())
55+
.codeRegistry(GraphQLCodeRegistry.newCodeRegistry()
56+
.dataFetcher(FieldCoordinates.coordinates("query", "test"), test)
57+
.build())
5258
.build();
5359
}
5460
}

example/src/main/java/graphql/kickstart/spring/web/boot/sample/ApplicationBootConfiguration.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
package graphql.kickstart.spring.web.boot.sample;
2121

2222
import graphql.Scalars;
23+
import graphql.schema.DataFetcher;
24+
import graphql.schema.FieldCoordinates;
25+
import graphql.schema.GraphQLCodeRegistry;
2326
import graphql.schema.GraphQLObjectType;
2427
import graphql.schema.GraphQLSchema;
2528
import org.springframework.boot.SpringApplication;
@@ -35,15 +38,18 @@ public static void main(String[] args) {
3538

3639
@Bean
3740
GraphQLSchema schema() {
41+
DataFetcher<String> test = env -> "response";
3842
return GraphQLSchema.newSchema()
3943
.query(GraphQLObjectType.newObject()
4044
.name("query")
4145
.field(field -> field
4246
.name("test")
4347
.type(Scalars.GraphQLString)
44-
.dataFetcher(environment -> "response")
4548
)
4649
.build())
50+
.codeRegistry(GraphQLCodeRegistry.newCodeRegistry()
51+
.dataFetcher(FieldCoordinates.coordinates("query", "test"), test)
52+
.build())
4753
.build();
4854
}
4955
}

graphiql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/graphiql/boot/ServletGraphiQLController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
@Controller
1818
public class ServletGraphiQLController extends GraphiQLController {
1919

20+
@Override
2021
@PostConstruct
2122
public void onceConstructed() throws IOException {
2223
super.onceConstructed();

graphiql-spring-boot-autoconfigure/src/test/java/graphql/kickstart/graphiql/boot/ReactiveGraphiQLControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
@ExtendWith(SpringExtension.class)
1515
@WebFluxTest
16-
public class ReactiveGraphiQLControllerTest {
16+
class ReactiveGraphiQLControllerTest {
1717

1818
@Autowired
1919
private WebTestClient webTestClient;
2020

2121
@Test
22-
public void shouldBeAbleToAccessGraphiQL() {
22+
void shouldBeAbleToAccessGraphiQL() {
2323
webTestClient.get()
2424
.uri("/graphiql")
2525
.exchange()

graphiql-spring-boot-autoconfigure/src/test/java/graphql/kickstart/graphiql/boot/ServletGraphiQLControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
@ExtendWith(SpringExtension.class)
1818
@WebMvcTest
19-
public class ServletGraphiQLControllerTest {
19+
class ServletGraphiQLControllerTest {
2020

2121
@Autowired
2222
private MockMvc mockMvc;
2323

2424
@Test
25-
public void shouldBeAbleToAccessGraphiQL() throws Exception {
25+
void shouldBeAbleToAccessGraphiQL() throws Exception {
2626
mockMvc.perform(get("/graphiql"))
2727
.andExpect(status().is2xxSuccessful())
2828
.andExpect(content().contentType("text/html; charset=UTF-8"));

graphiql-spring-boot-autoconfigure/src/test/java/graphql/kickstart/graphiql/boot/test/GraphiQLControllerTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,33 @@
1010
import org.springframework.context.annotation.Bean;
1111
import org.springframework.context.annotation.Configuration;
1212
import org.springframework.context.annotation.PropertySource;
13+
import org.springframework.context.support.AbstractApplicationContext;
1314
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
1415
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
1516

1617
/**
1718
* @author Andrew Potter
1819
*/
19-
public class GraphiQLControllerTest extends AbstractAutoConfigurationTest {
20+
class GraphiQLControllerTest extends AbstractAutoConfigurationTest {
2021

2122
public GraphiQLControllerTest() {
2223
super(AnnotationConfigWebApplicationContext.class, GraphiQLAutoConfiguration.class);
2324
}
2425

2526
@Test
26-
public void graphiqlLoads() {
27+
void graphiqlLoads() {
2728
load(EnabledConfiguration.class);
2829

2930
assertThat(this.getContext().getBean(GraphiQLController.class)).isNotNull();
3031
}
3132

3233
@Test
33-
public void graphiqlDoesNotLoad() {
34+
void graphiqlDoesNotLoad() {
3435
load(DisabledConfiguration.class);
3536

37+
AbstractApplicationContext context = getContext();
3638
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
37-
.isThrownBy(() -> this.getContext().getBean(GraphiQLController.class));
39+
.isThrownBy(() -> context.getBean(GraphiQLController.class));
3840
}
3941

4042
@Configuration

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/main/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private void setQueryResolverClass(
133133
) {
134134
final Set<Class<?>> queryResolvers
135135
= getTypesAnnotatedWith(reflections, GraphQLQueryResolver.class);
136-
if (queryResolvers.size() == 0) {
136+
if (queryResolvers.isEmpty()) {
137137
throw new MissingQueryResolverException();
138138
}
139139
if (queryResolvers.size() > 1) {

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsBeanTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1414
@ActiveProfiles({"test", "query-test"})
15-
public class GraphQLAnnotationsBeanTest {
15+
class GraphQLAnnotationsBeanTest {
1616

1717
@Autowired
1818
private ApplicationContext applicationContext;

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsCustomAnnotationProcessorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@DisplayName("Testing custom annotation processor configuration")
1414
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1515
@ActiveProfiles({"test", "custom-annotation-processor-test"})
16-
public class GraphQLAnnotationsCustomAnnotationProcessorTest {
16+
class GraphQLAnnotationsCustomAnnotationProcessorTest {
1717

1818
@SpyBean
1919
private CustomAnnotationProcessor customAnnotationProcessor;

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsCustomScalarTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@DisplayName("Testing that custom scalar beans are properly registered.")
1616
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1717
@ActiveProfiles({"test", "custom-scalar-test"})
18-
public class GraphQLAnnotationsCustomScalarTest {
18+
class GraphQLAnnotationsCustomScalarTest {
1919

2020
@Autowired
2121
private GraphQLTestTemplate graphQLTestTemplate;

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsCustomTypeFunctionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@DisplayName("Testing custom type function registration")
1515
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1616
@ActiveProfiles({"test", "custom-type-function-test"})
17-
public class GraphQLAnnotationsCustomTypeFunctionTest {
17+
class GraphQLAnnotationsCustomTypeFunctionTest {
1818

1919
@Autowired
2020
private GraphQLTestTemplate graphQLTestTemplate;

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsDirectiveTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@DisplayName("Testing directive registration")
1515
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1616
@ActiveProfiles({"test", "directive-test"})
17-
public class GraphQLAnnotationsDirectiveTest {
17+
class GraphQLAnnotationsDirectiveTest {
1818

1919
@Autowired
2020
private GraphQLTestTemplate graphQLTestTemplate;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.springframework.context.ApplicationContextException;
1010

1111
@DisplayName("Test exception if no query resolver defined.")
12-
public class GraphQLAnnotationsErrorMissingQueryResolver {
12+
class GraphQLAnnotationsErrorMissingQueryResolverTest {
1313

1414
@Test
1515
@DisplayName("Assert that MissingQueryResolverException is throw if no GraphQLQueryResolver classes are found.")
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import org.springframework.context.ApplicationContextException;
1010

1111
@DisplayName("Test exception if multiple mutation resolvers are defined.")
12-
public class GraphQLAnnotationsErrorMultipleMutationResolvers {
12+
class GraphQLAnnotationsMultipleMutationResolversTest {
1313

1414
@Test
1515
@DisplayName("Assert that MultipleMutationResolversException is thrown when multiple mutation resolvers are found.")
16-
public void testMultipleMutationResolversExceptionIsThrown() {
16+
void testMultipleMutationResolversExceptionIsThrown() {
1717
// GIVEN
1818
final SpringApplication app = new SpringApplication(TestApplication.class);
1919
app.setAdditionalProfiles("test", "test-multiple-mutation-resolvers-exception");

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsExtendTypeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@DisplayName("Test type extension registration")
1515
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1616
@ActiveProfiles({"test", "extend-type-test"})
17-
public class GraphQLAnnotationsExtendTypeTest {
17+
class GraphQLAnnotationsExtendTypeTest {
1818

1919
@Autowired
2020
private GraphQLTestTemplate graphQLTestTemplate;

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsMutationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@DisplayName("Testing mutation resolver registration")
1515
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1616
@ActiveProfiles({"test", "mutation-test"})
17-
public class GraphQLAnnotationsMutationTest {
17+
class GraphQLAnnotationsMutationTest {
1818

1919
@Autowired
2020
private GraphQLTestTemplate graphQLTestTemplate;

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsPrettifyDefaultTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@DisplayName("Testing prettify settings (default)")
1515
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1616
@ActiveProfiles({"test", "prettify-default-test"})
17-
public class GraphQLAnnotationsPrettifyDefaultTest {
17+
class GraphQLAnnotationsPrettifyDefaultTest {
1818

1919
@Autowired
2020
private GraphQLTestTemplate graphQLTestTemplate;

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsPrettifyDisabledTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@DisplayName("Test prettify settings (disabled)")
1515
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1616
@ActiveProfiles({"test", "prettify-disabled-test"})
17-
public class GraphQLAnnotationsPrettifyDisabledTest {
17+
class GraphQLAnnotationsPrettifyDisabledTest {
1818

1919
@Autowired
2020
private GraphQLTestTemplate graphQLTestTemplate;

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsPrettifyEnabledTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@DisplayName("Testing prettify settings (enabled)")
1515
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1616
@ActiveProfiles({"test", "prettify-enabled-test"})
17-
public class GraphQLAnnotationsPrettifyEnabledTest {
17+
class GraphQLAnnotationsPrettifyEnabledTest {
1818

1919
@Autowired
2020
private GraphQLTestTemplate graphQLTestTemplate;

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsQueryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@DisplayName("Testing query resolver registration.")
1717
@ActiveProfiles({"test", "query-test"})
1818
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TestApplication.class)
19-
public class GraphQLAnnotationsQueryTest {
19+
class GraphQLAnnotationsQueryTest {
2020

2121
@Autowired
2222
private GraphQLTestTemplate graphQLTestTemplate;

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsSubscriptionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@DisplayName("Testing subscription resolver registration.")
1414
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1515
@ActiveProfiles({"test", "subscription-test"})
16-
public class GraphQLAnnotationsSubscriptionTest {
16+
class GraphQLAnnotationsSubscriptionTest {
1717

1818
@Autowired
1919
private GraphQLTestSubscription graphQLTestSubscription;

graphql-kickstart-spring-boot-autoconfigure-tools/src/test/java/graphql/kickstart/tools/boot/ClasspathResourceSchemaStringProviderTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
import org.junit.jupiter.api.Test;
1111
import org.springframework.context.annotation.Configuration;
1212

13-
public class ClasspathResourceSchemaStringProviderTest extends AbstractAutoConfigurationTest {
14-
15-
private ClasspathResourceSchemaStringProvider schemaStringProvider;
13+
class ClasspathResourceSchemaStringProviderTest extends AbstractAutoConfigurationTest {
1614

1715
public ClasspathResourceSchemaStringProviderTest() {
1816
super(GraphQLJavaToolsAutoConfiguration.class);
@@ -29,9 +27,10 @@ public void clear() {
2927
}
3028

3129
@Test
32-
public void schemaStrings() throws IOException {
30+
void schemaStrings() throws IOException {
3331
load(BaseConfiguration.class);
34-
schemaStringProvider = getContext().getBean(ClasspathResourceSchemaStringProvider.class);
32+
ClasspathResourceSchemaStringProvider schemaStringProvider = getContext()
33+
.getBean(ClasspathResourceSchemaStringProvider.class);
3534

3635
List<String> schemaStrings = schemaStringProvider.schemaStrings();
3736
assertThat(schemaStrings).hasSize(1);
@@ -41,7 +40,7 @@ public void schemaStrings() throws IOException {
4140
@Configuration
4241
static class BaseConfiguration {
4342

44-
public class Query implements GraphQLQueryResolver {
43+
public static class Query implements GraphQLQueryResolver {
4544

4645
String schemaLocationTest(String id) {
4746
return id;

graphql-kickstart-spring-boot-autoconfigure-tools/src/test/java/graphql/kickstart/tools/boot/GraphQLJavaToolsAutoConfigurationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
/**
1313
* @author <a href="mailto:[email protected]">oEmbedler Inc.</a>
1414
*/
15-
public class GraphQLJavaToolsAutoConfigurationTest extends AbstractAutoConfigurationTest {
15+
class GraphQLJavaToolsAutoConfigurationTest extends AbstractAutoConfigurationTest {
1616

1717
public GraphQLJavaToolsAutoConfigurationTest() {
1818
super(GraphQLJavaToolsAutoConfiguration.class);
1919
}
2020

2121
@Test
22-
public void appContextLoads() {
22+
void appContextLoads() {
2323
load(BaseConfiguration.class);
2424

2525
assertThat(this.getContext().getBean(GraphQLSchema.class)).isNotNull();
2626
}
2727

2828
@Test
29-
public void schemaWithInterfaceLoads() {
29+
void schemaWithInterfaceLoads() {
3030
load(InterfaceConfiguration.class);
3131

3232
assertThat(this.getContext().getBean(GraphQLSchema.class)).isNotNull();

graphql-kickstart-spring-boot-autoconfigure-webflux/src/main/java/graphql/kickstart/spring/webflux/boot/GraphQLSpringWebfluxAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.springframework.web.reactive.socket.WebSocketHandler;
4848
import org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter;
4949

50+
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
5051
@Slf4j
5152
@Configuration
5253
@ConditionalOnBean({GraphQLSchema.class})

0 commit comments

Comments
 (0)