Remove formatter-on/off comments

This commit is contained in:
Rossen Stoyanchev
2021-07-06 15:51:50 +01:00
parent b594c19526
commit 69c2d08c71
32 changed files with 2 additions and 112 deletions

View File

@@ -95,7 +95,7 @@ public class GraphQlWebFluxAutoConfiguration {
if (logger.isInfoEnabled()) {
logger.info("GraphQL endpoint HTTP POST " + graphQLPath);
}
// @formatter:off
RouterFunctions.Builder builder = RouterFunctions.route()
.GET(graphQLPath, request ->
ServerResponse.status(HttpStatus.METHOD_NOT_ALLOWED)
@@ -104,7 +104,6 @@ public class GraphQlWebFluxAutoConfiguration {
.POST(graphQLPath,
accept(MediaType.APPLICATION_JSON).and(contentType(MediaType.APPLICATION_JSON)),
handler::handleRequest);
// @formatter:on
if (properties.getGraphiql().isEnabled()) {
Resource resource = resourceLoader.getResource("classpath:graphiql/index.html");

View File

@@ -105,7 +105,6 @@ public class GraphQlWebMvcAutoConfiguration {
logger.info("GraphQL endpoint HTTP POST " + graphQLPath);
}
// @formatter:off
RouterFunctions.Builder builder = RouterFunctions.route()
.GET(graphQLPath, request ->
ServerResponse.status(HttpStatus.METHOD_NOT_ALLOWED)
@@ -114,7 +113,6 @@ public class GraphQlWebMvcAutoConfiguration {
.POST(graphQLPath,
contentType(MediaType.APPLICATION_JSON).and(accept(MediaType.APPLICATION_JSON)),
handler::handleRequest);
// @formatter:on
if (properties.getGraphiql().isEnabled()) {
Resource resource = resourceLoader.getResource("classpath:graphiql/index.html");
@@ -139,12 +137,11 @@ public class GraphQlWebMvcAutoConfiguration {
@ConditionalOnMissingBean
public GraphQlWebSocketHandler graphQlWebSocketHandler(WebGraphQlHandler webGraphQlHandler,
GraphQlProperties properties, HttpMessageConverters converters) {
// @formatter:off
HttpMessageConverter<?> converter = converters.getConverters().stream()
.filter((candidate) -> candidate.canRead(Map.class, MediaType.APPLICATION_JSON))
.findFirst()
.orElseThrow(() -> new IllegalStateException("No JSON converter"));
// @formatter:on
return new GraphQlWebSocketHandler(webGraphQlHandler, converter,
properties.getWebsocket().getConnectionInitTimeout());

View File

@@ -37,8 +37,6 @@ import org.springframework.test.web.reactive.server.WebTestClient;
import static org.hamcrest.Matchers.containsString;
// @formatter:off
class GraphQlWebFluxAutoConfigurationTests {
private static final String BASE_URL = "https://spring.example.org/graphql";

View File

@@ -42,8 +42,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
// @formatter:off
class GraphQlWebMvcAutoConfigurationTests {
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()

View File

@@ -29,8 +29,6 @@ import org.springframework.graphql.test.tester.TestExecutionResult;
import static org.assertj.core.api.Assertions.assertThat;
// @formatter:off
/**
* Tests for {@link GraphQlTags}
*

View File

@@ -82,11 +82,9 @@ class GraphQlTesterAutoConfigurationTests {
@Bean
WebTestClient webTestClient() {
// @formatter:off
RouterFunction<ServerResponse> routes =
RouterFunctions.route().POST("/graphql", (request) -> ServerResponse.ok().build()).build();
return WebTestClient.bindToRouterFunction(routes).build();
// @formatter:on
}
@Bean

View File

@@ -27,8 +27,6 @@ import org.springframework.graphql.test.tester.WebGraphQlTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
// @formatter:off
@SpringBootTest()
@AutoConfigureWebTestClient
@AutoConfigureGraphQlTester

View File

@@ -32,12 +32,10 @@ public class SampleWiring implements RuntimeWiringBuilderCustomizer {
@Override
public void customize(RuntimeWiring.Builder wiringBuilder) {
// @formatter:off
wiringBuilder.type("Query", builder -> builder.dataFetcher("greeting", this.repository::getBasic));
wiringBuilder.type("Query", builder -> builder.dataFetcher("greetingMono", this.repository::getGreeting));
wiringBuilder.type("Query", builder -> builder.dataFetcher("greetingsFlux", this.repository::getGreetings));
wiringBuilder.type("Subscription", builder -> builder.dataFetcher("greetings", this.repository::getGreetingsStream));
// @formatter:on
}
}

View File

@@ -25,8 +25,6 @@ import org.springframework.graphql.test.tester.GraphQlTester;
import org.springframework.graphql.test.tester.WebGraphQlTester;
import org.springframework.graphql.web.WebGraphQlHandler;
// @formatter:off
/**
* GraphQL query tests directly via {@link GraphQL}.
*/

View File

@@ -27,8 +27,6 @@ import org.springframework.graphql.test.tester.GraphQlTester;
import org.springframework.graphql.test.tester.WebGraphQlTester;
import org.springframework.graphql.web.WebGraphQlHandler;
// @formatter:off
/**
* GraphQL subscription tests directly via {@link GraphQL}.
*/

View File

@@ -11,8 +11,6 @@ import org.springframework.graphql.test.tester.WebGraphQlTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
// @formatter:off
@SpringBootTest
@AutoConfigureMockMvc
@AutoConfigureGraphQlTester

View File

@@ -10,12 +10,10 @@ public enum ProjectStatus {
@JsonCreator
public static ProjectStatus fromName(String name) {
// @formatter:off
return Arrays.stream(ProjectStatus.values())
.filter(type -> type.name().equals(name))
.findFirst()
.orElse(ProjectStatus.ACTIVE);
// @formatter:on
}
}

View File

@@ -10,12 +10,10 @@ public enum ReleaseStatus {
@JsonCreator
public static ReleaseStatus fromName(String name) {
// @formatter:off
return Arrays.stream(ReleaseStatus.values())
.filter(type -> type.name().equals(name))
.findFirst()
.orElse(ReleaseStatus.GENERAL_AVAILABILITY);
// @formatter:on
}
}

View File

@@ -17,13 +17,9 @@ import org.springframework.web.client.RestTemplate;
@Component
public class SpringProjectsClient {
// @formatter:off
private static final TypeReferences.CollectionModelType<Release> releaseCollection =
new TypeReferences.CollectionModelType<Release>() {};
// @formatter:on
private final Traverson traverson;
public SpringProjectsClient(RestTemplateBuilder builder) {
@@ -34,11 +30,9 @@ public class SpringProjectsClient {
}
public Project fetchProject(String projectSlug) {
// @formatter:off
return this.traverson.follow("projects")
.follow(Hop.rel("project").withParameter("id", projectSlug))
.toObject(Project.class);
// @formatter:on
}
public List<Release> fetchProjectReleases(String projectSlug) {

View File

@@ -18,12 +18,10 @@ public class ArtifactRepositoriesInitializer implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
// @formatter:off
List<ArtifactRepository> repositoryList = Arrays.asList(
new ArtifactRepository("spring-releases", "Spring Releases", "https://repo.spring.io/libs-releases"),
new ArtifactRepository("spring-milestones", "Spring Milestones", "https://repo.spring.io/libs-milestones"),
new ArtifactRepository("spring-snapshots", "Spring Snapshots", "https://repo.spring.io/libs-snapshots"));
// @formatter:on
repositories.saveAll(repositoryList);
}

View File

@@ -26,8 +26,6 @@ import org.springframework.test.web.servlet.MockMvc;
import static org.assertj.core.api.Assertions.assertThat;
// @formatter:off
/**
* GraphQL requests via {@link GraphQlTester} connecting to {@link MockMvc}.
*/

View File

@@ -44,8 +44,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
// @formatter:off
/**
* Tests for {@link GraphQlTester}.
*

View File

@@ -52,8 +52,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
// @formatter:off
/**
* Tests for {@link WebGraphQlTester} parameterized to:
* <ul>

View File

@@ -63,8 +63,6 @@ class ExceptionResolversExceptionHandler implements DataFetcherExceptionHandler
return invokeChain(exception, parameters.getDataFetchingEnvironment());
}
// @formatter:off
DataFetcherExceptionHandlerResult invokeChain(Throwable ex, DataFetchingEnvironment env) {
// For now we have to block:
// https://github.com/graphql-java/graphql-java/issues/2356
@@ -97,6 +95,4 @@ class ExceptionResolversExceptionHandler implements DataFetcherExceptionHandler
return DataFetcherExceptionHandlerResult.newResult(error).build();
}
// @formatter:on
}

View File

@@ -86,12 +86,10 @@ class DefaultWebGraphQlHandlerBuilder implements WebGraphQlHandler.Builder {
WebGraphQlHandler targetHandler = (webInput) ->
this.service.execute(webInput).map((result) -> new WebOutput(webInput, result));
// @formatter:off
WebGraphQlHandler interceptionChain = interceptorsToUse.stream()
.reduce(WebInterceptor::andThen)
.map((interceptor) -> (WebGraphQlHandler) (input) -> interceptor.intercept(input, targetHandler))
.orElse(targetHandler);
// @formatter:on
return (CollectionUtils.isEmpty(this.accessors) ? interceptionChain
: new ThreadLocalExtractingHandler(interceptionChain, ThreadLocalAccessor.composite(this.accessors)));

View File

@@ -39,10 +39,8 @@ public class GraphQlHttpHandler {
private static final Log logger = LogFactory.getLog(GraphQlHttpHandler.class);
// @formatter:off
private static final ParameterizedTypeReference<Map<String, Object>> MAP_PARAMETERIZED_TYPE_REF =
new ParameterizedTypeReference<Map<String, Object>>() {};
// @formatter:on
private final WebGraphQlHandler graphQlHandler;

View File

@@ -69,15 +69,12 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
private static final Log logger = LogFactory.getLog(GraphQlWebSocketHandler.class);
// @formatter:off
private static final List<String> SUB_PROTOCOL_LIST =
Arrays.asList("graphql-transport-ws", "subscriptions-transport-ws");
static final ResolvableType MAP_RESOLVABLE_TYPE =
ResolvableType.forType(new ParameterizedTypeReference<Map<String, Object>>() {});
// @formatter:off
private final WebGraphQlHandler graphQlHandler;
@@ -104,8 +101,6 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
this.initTimeoutDuration = connectionInitTimeout;
}
// @formatter:off
private static Decoder<?> initDecoder(ServerCodecConfigurer configurer) {
return configurer.getReaders().stream()
.filter((reader) -> reader.canRead(MAP_RESOLVABLE_TYPE, MediaType.APPLICATION_JSON))
@@ -122,8 +117,6 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
.orElseThrow(() -> new IllegalArgumentException("No JSON Encoder"));
}
// @formatter:on
@Override
public List<String> getSubProtocols() {
return SUB_PROTOCOL_LIST;
@@ -144,8 +137,6 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
AtomicBoolean connectionInitProcessed = new AtomicBoolean();
Map<String, Subscription> subscriptions = new ConcurrentHashMap<>();
// @formatter:off
Mono.delay(this.initTimeoutDuration)
.then(Mono.defer(() ->
connectionInitProcessed.compareAndSet(false, true) ?
@@ -153,8 +144,6 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
Mono.empty()))
.subscribe();
// @formatter:on
return session.send(session.receive().flatMap((message) -> {
Map<String, Object> map = decode(message);
String id = (String) map.get("id");
@@ -209,8 +198,6 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
return payload;
}
// @formatter:off
@SuppressWarnings("unchecked")
private Flux<WebSocketMessage> handleWebOutput(WebSocketSession session, String id,
Map<String, Subscription> subscriptions, WebOutput output) {
@@ -258,8 +245,6 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
});
}
// @formatter:on
@SuppressWarnings("unchecked")
private <T> WebSocketMessage encode(WebSocketSession session, @Nullable String id, MessageType messageType,
@Nullable Object payload) {
@@ -281,8 +266,6 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
private enum MessageType {
// @formatter:off
CONNECTION_INIT("connection_init"),
CONNECTION_ACK("connection_ack"),
SUBSCRIBE("subscribe"),
@@ -290,8 +273,6 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
ERROR("error"),
COMPLETE("complete");
// @formatter:on
private static final Map<String, MessageType> messageTypes = new HashMap<>(6);
static {
@@ -319,8 +300,6 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
private static class GraphQlStatus {
// @formatter:off
static final CloseStatus INVALID_MESSAGE_STATUS = new CloseStatus(4400, "Invalid message");
static final CloseStatus UNAUTHORIZED_STATUS = new CloseStatus(4401, "Unauthorized");
@@ -329,8 +308,6 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
static final CloseStatus TOO_MANY_INIT_REQUESTS_STATUS = new CloseStatus(4429, "Too many initialisation requests");
// @formatter:on
static <V> Flux<V> close(WebSocketSession session, CloseStatus status) {
return session.close(status).thenMany(Mono.empty());
}

View File

@@ -46,10 +46,8 @@ public class GraphQlHttpHandler {
private static final Log logger = LogFactory.getLog(GraphQlHttpHandler.class);
// @formatter:off
private static final ParameterizedTypeReference<Map<String, Object>> MAP_PARAMETERIZED_TYPE_REF =
new ParameterizedTypeReference<Map<String, Object>>() {};
// @formatter:on
private final WebGraphQlHandler graphQlHandler;

View File

@@ -72,12 +72,9 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
private static final Log logger = LogFactory.getLog(GraphQlWebSocketHandler.class);
// @formatter:off
private static final List<String> SUB_PROTOCOL_LIST =
Arrays.asList("graphql-transport-ws", "subscriptions-transport-ws");
// @formatter:on
private final WebGraphQlHandler graphQlHandler;
@@ -123,8 +120,6 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
SessionState sessionState = new SessionState(session.getId());
this.sessionInfoMap.put(session.getId(), sessionState);
// @formatter:off
Mono.delay(this.initTimeoutDuration)
.then(Mono.fromRunnable(() -> {
if (sessionState.isConnectionInitNotProcessed()) {
@@ -133,8 +128,6 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
}))
.subscribe();
// @formatter:on
}
@Override
@@ -165,12 +158,10 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
if (logger.isDebugEnabled()) {
logger.debug("Executing: " + input);
}
// @formatter:off
this.graphQlHandler.handle(input)
.flatMapMany((output) -> handleWebOutput(session, input.getId(), output))
.publishOn(sessionState.getScheduler()) // Serial blocking send via single thread
.subscribe(new SendMessageSubscriber(id, session, sessionState));
// @formatter:on
return;
case COMPLETE:
if (id != null) {
@@ -212,8 +203,6 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
return info;
}
// @formatter:off
@SuppressWarnings("unchecked")
private Flux<TextMessage> handleWebOutput(WebSocketSession session, String id, WebOutput output) {
if (logger.isDebugEnabled()) {
@@ -258,8 +247,6 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
});
}
// @formatter:on
@SuppressWarnings("unchecked")
private <T> TextMessage encode(@Nullable String id, MessageType messageType, @Nullable Object payload) {
Map<String, Object> payloadMap = new HashMap<>(3);
@@ -303,8 +290,6 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
private enum MessageType {
// @formatter:off
CONNECTION_INIT("connection_init"),
CONNECTION_ACK("connection_ack"),
SUBSCRIBE("subscribe"),
@@ -312,8 +297,6 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
ERROR("error"),
COMPLETE("complete");
// @formatter:on
private static final Map<String, MessageType> messageTypes = new HashMap<>(6);
static {
@@ -341,8 +324,6 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
private static class GraphQlStatus {
// @formatter:off
private static final CloseStatus INVALID_MESSAGE_STATUS = new CloseStatus(4400, "Invalid message");
private static final CloseStatus UNAUTHORIZED_STATUS = new CloseStatus(4401, "Unauthorized");
@@ -351,8 +332,6 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
private static final CloseStatus TOO_MANY_INIT_REQUESTS_STATUS = new CloseStatus(4429, "Too many initialisation requests");
// @formatter:on
static void closeSession(WebSocketSession session, CloseStatus status) {
try {
session.close(status);

View File

@@ -27,8 +27,6 @@ import org.springframework.core.io.ByteArrayResource;
import org.springframework.graphql.execution.DataFetcherExceptionResolver;
import org.springframework.graphql.execution.GraphQlSource;
// @formatter:off
/**
* Utility methods for GraphQL tests.
*/

View File

@@ -35,8 +35,6 @@ import org.springframework.graphql.TestThreadLocalAccessor;
import static org.assertj.core.api.Assertions.assertThat;
// @formatter:off
/**
* Tests for {@link ContextDataFetcherDecorator}.
*/

View File

@@ -38,8 +38,6 @@ import org.springframework.graphql.TestThreadLocalAccessor;
import static org.assertj.core.api.Assertions.assertThat;
// @formatter:off
/**
* Tests for {@link ExceptionResolversExceptionHandler}.
*/

View File

@@ -28,8 +28,6 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.graphql.execution.ExecutionGraphQlService;
import org.springframework.graphql.execution.GraphQlSource;
// @formatter:off
public abstract class BookTestUtils {
public static final String SUBSCRIPTION_ID = "1";

View File

@@ -42,8 +42,6 @@ import org.springframework.http.HttpHeaders;
import static org.assertj.core.api.Assertions.assertThat;
// @formatter:off
/**
* Tests for {@link WebGraphQlHandler}, common to both HTTP and WebSocket.
*/

View File

@@ -32,8 +32,6 @@ import org.springframework.http.HttpHeaders;
import static org.assertj.core.api.Assertions.assertThat;
// @formatter:off
/**
* Unit tests for a {@link WebInterceptor} chain.
*/

View File

@@ -44,8 +44,6 @@ import org.springframework.web.reactive.socket.WebSocketMessage;
import static org.assertj.core.api.Assertions.as;
import static org.assertj.core.api.Assertions.assertThat;
// @formatter:off
/**
* Unit tests for {@link GraphQlWebSocketHandler}.
*/

View File

@@ -44,8 +44,6 @@ import org.springframework.web.socket.WebSocketMessage;
import static org.assertj.core.api.Assertions.as;
import static org.assertj.core.api.Assertions.assertThat;
// @formatter:off
/**
* Unit tests for {@link GraphQlWebSocketHandler}.
*/