Replace use of deprecated methods in tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,7 +24,7 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import io.micrometer.context.ContextSnapshot;
|
||||
import io.micrometer.context.ContextSnapshotFactory;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
@@ -60,7 +60,7 @@ public class BatchMappingPrincipalMethodArgumentResolverTests extends BatchMappi
|
||||
ReactiveSecurityContextHolder.withAuthentication(this.authentication);
|
||||
|
||||
private final Function<Context, Context> threadLocalContextWriter = context ->
|
||||
ContextSnapshot.captureAll().updateContext(context);
|
||||
ContextSnapshotFactory.builder().build().captureAll().updateContext(context);
|
||||
|
||||
|
||||
private static Stream<Arguments> controllers() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import java.util.function.Function;
|
||||
|
||||
import graphql.GraphqlErrorBuilder;
|
||||
import io.micrometer.context.ContextSnapshot;
|
||||
import io.micrometer.context.ContextSnapshotFactory;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
@@ -70,8 +71,10 @@ public class SchemaMappingPrincipalMethodArgumentResolverTests {
|
||||
private final Function<Context, Context> reactiveContextWriterWithoutAuthentication = context ->
|
||||
ReactiveSecurityContextHolder.withSecurityContext(Mono.just(SecurityContextHolder.createEmptyContext()));
|
||||
|
||||
private final Function<Context, Context> threadLocalContextWriter = context ->
|
||||
ContextSnapshot.captureAll().updateContext(context);
|
||||
private final Function<Context, Context> threadLocalContextWriter = context -> {
|
||||
ContextSnapshot snapshot = ContextSnapshotFactory.builder().build().captureAll();
|
||||
return snapshot.updateContext(context);
|
||||
};
|
||||
|
||||
private final GreetingController greetingController = new GreetingController();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,6 +25,7 @@ import graphql.GraphQLError;
|
||||
import graphql.GraphqlErrorBuilder;
|
||||
import io.micrometer.context.ContextRegistry;
|
||||
import io.micrometer.context.ContextSnapshot;
|
||||
import io.micrometer.context.ContextSnapshotFactory;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -109,7 +110,8 @@ public class CompositeSubscriptionExceptionResolverTests {
|
||||
.toGraphQl();
|
||||
|
||||
ExecutionInput input = ExecutionInput.newExecutionInput(query).build();
|
||||
ContextSnapshot.captureAll().updateContext(input.getGraphQLContext());
|
||||
ContextSnapshot snapshot = ContextSnapshotFactory.builder().build().captureAll();
|
||||
snapshot.updateContext(input.getGraphQLContext());
|
||||
|
||||
Flux<ResponseHelper> flux = Mono.defer(() -> Mono.fromFuture(graphQL.executeAsync(input)))
|
||||
.map(ResponseHelper::forSubscription)
|
||||
|
||||
@@ -37,6 +37,7 @@ import graphql.schema.idl.SchemaDirectiveWiring;
|
||||
import graphql.schema.idl.SchemaDirectiveWiringEnvironment;
|
||||
import io.micrometer.context.ContextRegistry;
|
||||
import io.micrometer.context.ContextSnapshot;
|
||||
import io.micrometer.context.ContextSnapshotFactory;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -181,7 +182,8 @@ public class ContextDataFetcherDecoratorTests {
|
||||
.toGraphQl();
|
||||
|
||||
ExecutionInput input = ExecutionInput.newExecutionInput().query("{ greeting }").build();
|
||||
ContextSnapshot.captureAll().updateContext(input.getGraphQLContext());
|
||||
ContextSnapshot snapshot = ContextSnapshotFactory.builder().build().captureAll();
|
||||
snapshot.updateContext(input.getGraphQLContext());
|
||||
|
||||
Mono<ExecutionResult> resultMono = Mono.delay(Duration.ofMillis(10))
|
||||
.flatMap((aLong) -> Mono.fromFuture(graphQl.executeAsync(input)));
|
||||
@@ -202,7 +204,7 @@ public class ContextDataFetcherDecoratorTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public GraphQLFieldDefinition onField(SchemaDirectiveWiringEnvironment<GraphQLFieldDefinition> env) {
|
||||
if (env.getDirective("UpperCase") != null) {
|
||||
if (env.getAppliedDirective("UpperCase") != null) {
|
||||
return env.setFieldDataFetcher(DataFetcherFactories.wrapDataFetcher(
|
||||
env.getFieldDataFetcher(),
|
||||
((dataFetchingEnv, value) -> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import graphql.ExecutionResult;
|
||||
import graphql.GraphqlErrorBuilder;
|
||||
import io.micrometer.context.ContextRegistry;
|
||||
import io.micrometer.context.ContextSnapshot;
|
||||
import io.micrometer.context.ContextSnapshotFactory;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -100,7 +101,8 @@ public class ExceptionResolversExceptionHandlerTests {
|
||||
.build());
|
||||
|
||||
resolver.setThreadLocalContextAware(true);
|
||||
ContextSnapshot.captureAll().updateContext(this.input.getGraphQLContext());
|
||||
ContextSnapshot snapshot = ContextSnapshotFactory.builder().build().captureAll();
|
||||
snapshot.updateContext(this.input.getGraphQLContext());
|
||||
|
||||
Mono<ExecutionResult> result = Mono.delay(Duration.ofMillis(10)).flatMap((aLong) ->
|
||||
Mono.fromFuture(this.graphQlSetup.exceptionResolver(resolver).toGraphQl().executeAsync(this.input)));
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.function.Consumer;
|
||||
|
||||
import io.micrometer.context.ContextRegistry;
|
||||
import io.micrometer.context.ContextSnapshot;
|
||||
import io.micrometer.context.ContextSnapshotFactory;
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -403,7 +404,8 @@ public class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
|
||||
GraphQlWebSocketHandler handler = initWebSocketHandler(threadLocalInterceptor);
|
||||
|
||||
// Ensure ContextSnapshot is present in WebSocketSession attributes
|
||||
this.session.getAttributes().put(ContextSnapshot.class.getName(), ContextSnapshot.captureAll());
|
||||
ContextSnapshot snapshot = ContextSnapshotFactory.builder().build().captureAll();
|
||||
this.session.getAttributes().put(ContextSnapshot.class.getName(), snapshot);
|
||||
|
||||
// Context should propagate, if message is handled on different thread
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -452,7 +454,8 @@ public class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
|
||||
|
||||
if (!this.session.getAttributes().containsKey(ContextSnapshot.class.getName())) {
|
||||
// Ensure ContextSnapshot is present in WebSocketSession attributes
|
||||
this.session.getAttributes().put(ContextSnapshot.class.getName(), ContextSnapshot.captureAll());
|
||||
ContextSnapshot snapshot = ContextSnapshotFactory.builder().build().captureAll();
|
||||
this.session.getAttributes().put(ContextSnapshot.class.getName(), snapshot);
|
||||
}
|
||||
|
||||
for (TextMessage message : textMessages) {
|
||||
|
||||
Reference in New Issue
Block a user