Make TestExecutionResult package private
This commit is contained in:
@@ -19,14 +19,13 @@ package org.springframework.graphql.boot.actuate.metrics;
|
||||
import java.util.Arrays;
|
||||
|
||||
import graphql.ErrorType;
|
||||
import graphql.ExecutionResult;
|
||||
import graphql.ExecutionResultImpl;
|
||||
import graphql.GraphQLError;
|
||||
import graphql.GraphqlErrorBuilder;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.graphql.test.tester.TestExecutionResult;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
@@ -38,13 +37,15 @@ class GraphQlTagsTests {
|
||||
|
||||
@Test
|
||||
void executionOutcomeShouldSucceed() {
|
||||
Tag outcomeTag = GraphQlTags.executionOutcome(new TestExecutionResult(), null);
|
||||
ExecutionResult result = ExecutionResultImpl.newExecutionResult().build();
|
||||
Tag outcomeTag = GraphQlTags.executionOutcome(result, null);
|
||||
assertThat(outcomeTag.getValue()).isEqualTo("SUCCESS");
|
||||
}
|
||||
|
||||
@Test
|
||||
void executionOutcomeShouldErrorWhenExceptionThrown() {
|
||||
Tag tag = GraphQlTags.executionOutcome(new TestExecutionResult(), new IllegalArgumentException("test error"));
|
||||
ExecutionResult result = ExecutionResultImpl.newExecutionResult().build();
|
||||
Tag tag = GraphQlTags.executionOutcome(result, new IllegalArgumentException("test error"));
|
||||
assertThat(tag.getValue()).isEqualTo("ERROR");
|
||||
}
|
||||
|
||||
|
||||
@@ -26,14 +26,18 @@ import graphql.ExecutionResult;
|
||||
import graphql.ExecutionResultImpl;
|
||||
import graphql.GraphQLError;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link GraphQLError} with setters for deserialization.
|
||||
* {@link GraphQLError} with setters, for internal use to use to deserialize
|
||||
* from a response.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class TestExecutionResult implements ExecutionResult {
|
||||
final class TestExecutionResult implements ExecutionResult {
|
||||
|
||||
@Nullable
|
||||
private Object data;
|
||||
|
||||
private List<GraphQLError> errors = Collections.emptyList();
|
||||
@@ -46,6 +50,7 @@ public class TestExecutionResult implements ExecutionResult {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public <T> T getData() {
|
||||
return (T) this.data;
|
||||
}
|
||||
@@ -75,7 +80,8 @@ public class TestExecutionResult implements ExecutionResult {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toSpecification() {
|
||||
ExecutionResultImpl.Builder builder = ExecutionResultImpl.newExecutionResult().addErrors(this.errors)
|
||||
ExecutionResultImpl.Builder builder = ExecutionResultImpl.newExecutionResult()
|
||||
.addErrors(this.errors)
|
||||
.extensions(this.extensions);
|
||||
|
||||
if (isDataPresent()) {
|
||||
|
||||
@@ -30,12 +30,13 @@ import graphql.language.SourceLocation;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link GraphQLError} with setters to use for deserialization.
|
||||
* {@link GraphQLError} with setters, for internal use to use to deserialize
|
||||
* from a response.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
class TestGraphQlError implements GraphQLError {
|
||||
final class TestGraphQlError implements GraphQLError {
|
||||
|
||||
@Nullable
|
||||
private String message;
|
||||
|
||||
@@ -24,13 +24,14 @@ import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
/**
|
||||
* {@link TypeRef} with a {@link #getType() type} that is given rather than obtained from
|
||||
* the declared generic type information.
|
||||
* Adapter for a JSONPath {@link TypeRef} with a {@link #getType() type} that
|
||||
* returns fixed type information rather than obtained from the generic type
|
||||
* declaration.
|
||||
*
|
||||
* @param <T> the referenced type
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
class TypeRefAdapter<T> extends TypeRef<T> {
|
||||
final class TypeRefAdapter<T> extends TypeRef<T> {
|
||||
|
||||
private final Type type;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user