Skip to content

Commit 2a54ef4

Browse files
committed
Apply checkstyle changes to spring-graphql-test
See gh-943
1 parent 4f1f0a2 commit 2a54ef4

21 files changed

+95
-74
lines changed

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractDirectGraphQlTransport.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
* to a server-side GraphQL handler or service.
4242
*
4343
* @author Rossen Stoyanchev
44-
* @since 1.0.0
4544
*/
4645
abstract class AbstractDirectGraphQlTransport implements GraphQlTransport {
4746

@@ -56,15 +55,15 @@ public Mono<GraphQlResponse> execute(GraphQlRequest request) {
5655
@SuppressWarnings({"ConstantConditions", "unchecked"})
5756
@Override
5857
public Flux<GraphQlResponse> executeSubscription(GraphQlRequest request) {
59-
return executeInternal(toExecutionRequest(request)).flatMapMany(response -> {
58+
return executeInternal(toExecutionRequest(request)).flatMapMany((response) -> {
6059
try {
6160
Object data = response.getData();
6261
AssertionErrors.assertTrue("Not a Publisher: " + data, data instanceof Publisher);
6362

6463
List<ResponseError> errors = response.getErrors();
6564
AssertionErrors.assertTrue("Subscription errors: " + errors, CollectionUtils.isEmpty(errors));
6665

67-
return Flux.from((Publisher<ExecutionResult>) data).map(executionResult ->
66+
return Flux.from((Publisher<ExecutionResult>) data).map((executionResult) ->
6867
new DefaultExecutionGraphQlResponse(response.getExecutionInput(), executionResult));
6968
}
7069
catch (AssertionError ex) {

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractGraphQlTesterBuilder.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.graphql.test.tester;
1718

1819
import java.time.Duration;
@@ -35,7 +36,6 @@
3536
import org.springframework.graphql.client.AbstractGraphQlClientBuilder;
3637
import org.springframework.graphql.client.GraphQlClient;
3738
import org.springframework.graphql.client.GraphQlTransport;
38-
import org.springframework.graphql.support.CachingDocumentSource;
3939
import org.springframework.graphql.support.DocumentSource;
4040
import org.springframework.graphql.support.ResourceDocumentSource;
4141
import org.springframework.lang.Nullable;
@@ -51,6 +51,7 @@
5151
* agnostic {@code GraphQlTester}. A transport specific extension can then wrap
5252
* this default tester by extending {@link AbstractDelegatingGraphQlTester}.
5353
*
54+
* @param <B> the type of builder
5455
* @author Rossen Stoyanchev
5556
* @since 1.0.0
5657
* @see AbstractDelegatingGraphQlTester
@@ -86,7 +87,7 @@ private static DocumentSource initDocumentSource() {
8687

8788
@Override
8889
public B errorFilter(Predicate<ResponseError> predicate) {
89-
this.errorFilter = (this.errorFilter != null ? errorFilter.and(predicate) : predicate);
90+
this.errorFilter = (this.errorFilter != null) ? this.errorFilter.and(predicate) : predicate;
9091
return self();
9192
}
9293

@@ -115,6 +116,7 @@ private <T extends B> T self() {
115116
/**
116117
* Allow transport-specific subclass builders to register a JSON Path
117118
* {@link MappingProvider} that matches the JSON encoding/decoding they use.
119+
* @param configurer a function applied to the JSON Path configuration
118120
*/
119121
protected void configureJsonPathConfig(Function<Configuration, Configuration> configurer) {
120122
this.jsonPathConfig = configurer.apply(this.jsonPathConfig);
@@ -123,6 +125,7 @@ protected void configureJsonPathConfig(Function<Configuration, Configuration> co
123125
/**
124126
* Build the default transport-agnostic client that subclasses can then wrap
125127
* with {@link AbstractDelegatingGraphQlTester}.
128+
* @param transport the graphql transport to use
126129
*/
127130
protected GraphQlTester buildGraphQlTester(GraphQlTransport transport) {
128131

@@ -139,12 +142,12 @@ protected GraphQlTester buildGraphQlTester(GraphQlTransport transport) {
139142
* initialize new builder instances with, based on "this" builder.
140143
*/
141144
protected Consumer<AbstractGraphQlTesterBuilder<?>> getBuilderInitializer() {
142-
return builder -> {
145+
return (builder) -> {
143146
if (this.errorFilter != null) {
144147
builder.errorFilter(this.errorFilter);
145148
}
146149
builder.documentSource(this.documentSource);
147-
builder.configureJsonPathConfig(config -> this.jsonPathConfig);
150+
builder.configureJsonPathConfig((config) -> this.jsonPathConfig);
148151
builder.responseTimeout(this.responseTimeout);
149152
};
150153
}
@@ -153,6 +156,7 @@ protected Consumer<AbstractGraphQlTesterBuilder<?>> getBuilderInitializer() {
153156
* For cases where the Tester needs the {@link GraphQlTransport}, we can't use
154157
* transports directly since they are package private, but we can adapt the corresponding
155158
* {@link GraphQlClient} and adapt it to {@code GraphQlTransport}.
159+
* @param client the graphql client to use for extracting the transport
156160
*/
157161
protected static GraphQlTransport asTransport(GraphQlClient client) {
158162
return new GraphQlTransport() {
@@ -180,7 +184,7 @@ public Flux<GraphQlResponse> executeSubscription(GraphQlRequest request) {
180184
}
181185

182186

183-
private static class Jackson2Configurer {
187+
private static final class Jackson2Configurer {
184188

185189
private static final Class<?> defaultJsonProviderType;
186190

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultExecutionGraphQlServiceTesterBuilder.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
* wraps an {@code ExecutionGraphQlService}.
3838
*
3939
* @author Rossen Stoyanchev
40-
* @since 1.0.0
4140
*/
4241
final class DefaultExecutionGraphQlServiceTesterBuilder
4342
extends AbstractGraphQlTesterBuilder<DefaultExecutionGraphQlServiceTesterBuilder>
@@ -95,7 +94,7 @@ public ExecutionGraphQlServiceTester build() {
9594

9695
private void registerJsonPathMappingProvider() {
9796
if (this.encoder != null && this.decoder != null) {
98-
configureJsonPathConfig(config -> {
97+
configureJsonPathConfig((config) -> {
9998
EncoderDecoderMappingProvider provider = new EncoderDecoderMappingProvider(
10099
Collections.singletonList(this.encoder), Collections.singletonList(this.decoder));
101100
return config.mappingProvider(provider);
@@ -111,7 +110,7 @@ private GraphQlServiceGraphQlTransport createTransport() {
111110
/**
112111
* Default {@link ExecutionGraphQlServiceTester} implementation.
113112
*/
114-
private static class DefaultExecutionGraphQlServiceTester
113+
private static final class DefaultExecutionGraphQlServiceTester
115114
extends AbstractDelegatingGraphQlTester implements ExecutionGraphQlServiceTester {
116115

117116
private final GraphQlServiceGraphQlTransport transport;

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlTester.java

+20-20
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public DefaultRequest extension(String name, @Nullable Object value) {
153153
@SuppressWarnings("ConstantConditions")
154154
@Override
155155
public Response execute() {
156-
return transport.execute(request()).map(response -> mapResponse(response, request())).block(responseTimeout);
156+
return DefaultGraphQlTester.this.transport.execute(request()).map((response) -> mapResponse(response, request())).block(DefaultGraphQlTester.this.responseTimeout);
157157
}
158158

159159
@Override
@@ -163,15 +163,15 @@ public void executeAndVerify() {
163163

164164
@Override
165165
public Subscription executeSubscription() {
166-
return () -> transport.executeSubscription(request()).map(result -> mapResponse(result, request()));
166+
return () -> DefaultGraphQlTester.this.transport.executeSubscription(request()).map((result) -> mapResponse(result, request()));
167167
}
168168

169169
private GraphQlRequest request() {
170170
return new DefaultGraphQlRequest(this.document, this.operationName, this.variables, this.extensions);
171171
}
172172

173173
private DefaultResponse mapResponse(GraphQlResponse response, GraphQlRequest request) {
174-
return new DefaultResponse(response, errorFilter, assertDecorator(request), jsonPathConfig);
174+
return new DefaultResponse(response, DefaultGraphQlTester.this.errorFilter, assertDecorator(request), DefaultGraphQlTester.this.jsonPathConfig);
175175
}
176176

177177
private Consumer<Runnable> assertDecorator(GraphQlRequest request) {
@@ -191,7 +191,7 @@ private Consumer<Runnable> assertDecorator(GraphQlRequest request) {
191191
/**
192192
* Container for GraphQL response data and errors along with convenience methods.
193193
*/
194-
private final static class ResponseDelegate {
194+
private static final class ResponseDelegate {
195195

196196
private final DocumentContext jsonDoc;
197197

@@ -258,7 +258,7 @@ void expectErrors(Predicate<ResponseError> predicate) {
258258
}
259259

260260
void consumeErrors(Consumer<List<ResponseError>> consumer) {
261-
filterErrors(error -> true);
261+
filterErrors((error) -> true);
262262
consumer.accept(this.errors);
263263
}
264264

@@ -392,7 +392,7 @@ public Path valueIsNull() {
392392
this.delegate.doAssert(() -> {
393393
Object value = this.pathHelper.evaluateJsonPath(this.delegate.jsonContent());
394394
AssertionErrors.assertNull(
395-
"Expected null value at JSON path \"" + path + "\" but found " + value, value);
395+
"Expected null value at JSON path \"" + this.path + "\" but found " + value, value);
396396
});
397397
return this;
398398
}
@@ -464,7 +464,7 @@ static Path forNestedPath(@Nullable String basePath, String path, ResponseDelega
464464
}
465465

466466
private static String joinPaths(@Nullable String basePath, String path) {
467-
return (basePath != null ? basePath + "." + path : path);
467+
return (basePath != null) ? basePath + "." + path : path;
468468
}
469469

470470

@@ -476,65 +476,65 @@ private class DefaultEntity<D, S extends Entity<D, S>> implements Entity<D, S> {
476476
private final D entity;
477477

478478
protected DefaultEntity(TypeRefAdapter<D> typeAdapter) {
479-
this.entity = delegate.read(jsonPath, typeAdapter);
479+
this.entity = DefaultPath.this.delegate.read(DefaultPath.this.jsonPath, typeAdapter);
480480
}
481481

482482
protected D getEntity() {
483483
return this.entity;
484484
}
485485

486486
protected void doAssert(Runnable task) {
487-
delegate.doAssert(task);
487+
DefaultPath.this.delegate.doAssert(task);
488488
}
489489

490490
protected String getPath() {
491-
return path;
491+
return DefaultPath.this.path;
492492
}
493493

494494
@Override
495495
public Path path(String path) {
496-
return forPath(basePath, path, delegate);
496+
return forPath(DefaultPath.this.basePath, path, DefaultPath.this.delegate);
497497
}
498498

499499
@Override
500500
public Path path(String path, Consumer<Path> pathConsumer) {
501-
return forNestedPath(basePath, path, delegate, pathConsumer);
501+
return forNestedPath(DefaultPath.this.basePath, path, DefaultPath.this.delegate, pathConsumer);
502502
}
503503

504504
@Override
505505
public <T extends S> T isEqualTo(Object expected) {
506-
delegate.doAssert(() -> AssertionErrors.assertEquals(path, expected, this.entity));
506+
DefaultPath.this.delegate.doAssert(() -> AssertionErrors.assertEquals(DefaultPath.this.path, expected, this.entity));
507507
return self();
508508
}
509509

510510
@Override
511511
public <T extends S> T isNotEqualTo(Object other) {
512-
delegate.doAssert(() -> AssertionErrors.assertNotEquals(path, other, this.entity));
512+
DefaultPath.this.delegate.doAssert(() -> AssertionErrors.assertNotEquals(DefaultPath.this.path, other, this.entity));
513513
return self();
514514
}
515515

516516
@Override
517517
public <T extends S> T isSameAs(Object expected) {
518-
delegate.doAssert(() -> AssertionErrors.assertTrue(path, expected == this.entity));
518+
DefaultPath.this.delegate.doAssert(() -> AssertionErrors.assertTrue(DefaultPath.this.path, expected == this.entity));
519519
return self();
520520
}
521521

522522
@Override
523523
public <T extends S> T isNotSameAs(Object other) {
524-
delegate.doAssert(() -> AssertionErrors.assertTrue(path, other != this.entity));
524+
DefaultPath.this.delegate.doAssert(() -> AssertionErrors.assertTrue(DefaultPath.this.path, other != this.entity));
525525
return self();
526526
}
527527

528528
@Override
529529
public <T extends S> T matches(Predicate<D> predicate) {
530-
delegate
531-
.doAssert(() -> AssertionErrors.assertTrue(path, predicate.test(this.entity)));
530+
DefaultPath.this.delegate
531+
.doAssert(() -> AssertionErrors.assertTrue(DefaultPath.this.path, predicate.test(this.entity)));
532532
return self();
533533
}
534534

535535
@Override
536536
public <T extends S> T satisfies(Consumer<D> consumer) {
537-
delegate.doAssert(() -> consumer.accept(this.entity));
537+
DefaultPath.this.delegate.doAssert(() -> consumer.accept(this.entity));
538538
return self();
539539
}
540540

@@ -557,7 +557,7 @@ private <T extends S> T self() {
557557
private final class DefaultEntityList<E>
558558
extends DefaultEntity<List<E>, EntityList<E>> implements EntityList<E> {
559559

560-
public DefaultEntityList(TypeRefAdapter<List<E>> typeAdapter) {
560+
DefaultEntityList(TypeRefAdapter<List<E>> typeAdapter) {
561561
super(typeAdapter);
562562
}
563563

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultHttpGraphQlTesterBuilder.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
* {@link WebTestClient.Builder}.
3434
*
3535
* @author Rossen Stoyanchev
36-
* @since 1.0.0
3736
*/
3837
final class DefaultHttpGraphQlTesterBuilder
3938
extends AbstractGraphQlTesterBuilder<DefaultHttpGraphQlTesterBuilder>
@@ -93,8 +92,8 @@ public HttpGraphQlTester build() {
9392
}
9493

9594
private void registerJsonPathMappingProvider() {
96-
this.webTestClientBuilder.codecs(codecConfigurer ->
97-
configureJsonPathConfig(config -> {
95+
this.webTestClientBuilder.codecs((codecConfigurer) ->
96+
configureJsonPathConfig((config) -> {
9897
EncoderDecoderMappingProvider provider = new EncoderDecoderMappingProvider(codecConfigurer);
9998
return config.mappingProvider(provider);
10099
}));
@@ -105,7 +104,7 @@ private void registerJsonPathMappingProvider() {
105104
* Default {@link HttpGraphQlTester} that builds and uses a {@link WebTestClient}
106105
* for request execution.
107106
*/
108-
private static class DefaultHttpGraphQlTester extends AbstractDelegatingGraphQlTester implements HttpGraphQlTester {
107+
private static final class DefaultHttpGraphQlTester extends AbstractDelegatingGraphQlTester implements HttpGraphQlTester {
109108

110109
private final WebTestClient webTestClient;
111110

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultRSocketGraphQlTesterBuilder.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ public RSocketGraphQlTester build() {
113113
}
114114

115115
private void registerJsonPathMappingProvider() {
116-
this.rsocketGraphQlClientBuilder.rsocketRequester(builder ->
117-
builder.rsocketStrategies(strategiesBuilder ->
118-
configureJsonPathConfig(config -> {
116+
this.rsocketGraphQlClientBuilder.rsocketRequester((builder) ->
117+
builder.rsocketStrategies((strategiesBuilder) ->
118+
configureJsonPathConfig((config) -> {
119119
RSocketStrategies strategies = strategiesBuilder.build();
120120
List<Encoder<?>> encoders = strategies.encoders();
121121
List<Decoder<?>> decoders = strategies.decoders();

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultTransportGraphQlTesterBuilder.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
* Default {@link GraphQlTester.Builder} with a given, externally prepared transport.
2828
*
2929
* @author Rossen Stoyanchev
30-
* @since 1.0.0
3130
*/
3231
final class DefaultTransportGraphQlTesterBuilder
3332
extends AbstractGraphQlTesterBuilder<DefaultTransportGraphQlTesterBuilder> {
@@ -50,7 +49,7 @@ public GraphQlTester build() {
5049
/**
5150
* {@link GraphQlTester} with a given transport.
5251
*/
53-
private static class DefaultTransportGraphQlTester extends AbstractDelegatingGraphQlTester {
52+
private static final class DefaultTransportGraphQlTester extends AbstractDelegatingGraphQlTester {
5453

5554
private final GraphQlTransport transport;
5655

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultWebGraphQlTester.java renamed to spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultWebGraphQlTesterBuilder.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
* {@link WebGraphQlHandler} for request execution.
3535
*
3636
* @author Rossen Stoyanchev
37-
* @since 1.0.0
3837
*/
3938
final class DefaultWebGraphQlTesterBuilder
4039
extends AbstractGraphQlTesterBuilder<DefaultWebGraphQlTesterBuilder>
@@ -104,7 +103,7 @@ public WebGraphQlTester build() {
104103
}
105104

106105
private void registerJsonPathMappingProvider() {
107-
configureJsonPathConfig(jsonPathConfig -> {
106+
configureJsonPathConfig((jsonPathConfig) -> {
108107
EncoderDecoderMappingProvider provider = new EncoderDecoderMappingProvider(this.codecConfigurer);
109108
return jsonPathConfig.mappingProvider(provider);
110109
});
@@ -114,7 +113,7 @@ private void registerJsonPathMappingProvider() {
114113
/**
115114
* Default {@link WebGraphQlTester} implementation.
116115
*/
117-
private static class DefaultWebGraphQlTester extends AbstractDelegatingGraphQlTester implements WebGraphQlTester {
116+
private static final class DefaultWebGraphQlTester extends AbstractDelegatingGraphQlTester implements WebGraphQlTester {
118117

119118
private final WebGraphQlHandlerGraphQlTransport transport;
120119

+3-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
* {@link WebSocketGraphQlClient.Builder}.
3535
*
3636
* @author Rossen Stoyanchev
37-
* @since 1.0.0
3837
*/
3938
final class DefaultWebSocketGraphQlTesterBuilder
4039
extends AbstractGraphQlTesterBuilder<DefaultWebSocketGraphQlTesterBuilder>
@@ -108,8 +107,8 @@ public WebSocketGraphQlTester build() {
108107
}
109108

110109
private void registerJsonPathMappingProvider() {
111-
this.graphQlClientBuilder.codecConfigurer(codecConfigurer -> {
112-
configureJsonPathConfig(jsonPathConfig -> {
110+
this.graphQlClientBuilder.codecConfigurer((codecConfigurer) -> {
111+
configureJsonPathConfig((jsonPathConfig) -> {
113112
EncoderDecoderMappingProvider provider = new EncoderDecoderMappingProvider(codecConfigurer);
114113
return jsonPathConfig.mappingProvider(provider);
115114
});
@@ -120,7 +119,7 @@ private void registerJsonPathMappingProvider() {
120119
/**
121120
* Default {@link WebSocketGraphQlTester} implementation.
122121
*/
123-
private static class DefaultWebSocketGraphQlTester extends AbstractDelegatingGraphQlTester implements WebSocketGraphQlTester {
122+
private static final class DefaultWebSocketGraphQlTester extends AbstractDelegatingGraphQlTester implements WebSocketGraphQlTester {
124123

125124
private final WebSocketGraphQlClient client;
126125

0 commit comments

Comments
 (0)