|
| 1 | +package graphql.execution |
| 2 | + |
| 3 | +import graphql.ExecutionResult |
| 4 | +import graphql.Scalars |
| 5 | +import graphql.language.Field |
| 6 | +import graphql.schema.GraphQLList |
| 7 | +import graphql.schema.GraphQLObjectType |
| 8 | +import spock.lang.Ignore |
| 9 | +import spock.lang.Specification |
| 10 | + |
| 11 | +class ExecutionStrategySpec extends Specification { |
| 12 | + |
| 13 | + ExecutionStrategy executionStrategy |
| 14 | + |
| 15 | + def setup() { |
| 16 | + executionStrategy = new ExecutionStrategy() { |
| 17 | + @Override |
| 18 | + ExecutionResult execute(ExecutionContext executionContext, GraphQLObjectType parentType, Object source, Map<String, List<Field>> fields) { |
| 19 | + return null |
| 20 | + } |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | + def "completes value for a java.util.List"() { |
| 25 | + given: |
| 26 | + ExecutionContext executionContext = new ExecutionContext(); |
| 27 | + Field field = new Field() |
| 28 | + def fieldType = new GraphQLList(Scalars.GraphQLString) |
| 29 | + def result = Arrays.asList("test") |
| 30 | + when: |
| 31 | + def executionResult = executionStrategy.completeValue(executionContext, fieldType, [field], result) |
| 32 | + |
| 33 | + then: |
| 34 | + executionResult.data == ["test"] |
| 35 | + } |
| 36 | + |
| 37 | + @Ignore |
| 38 | + def "completes value for a array"() { |
| 39 | + given: |
| 40 | + ExecutionContext executionContext = new ExecutionContext(); |
| 41 | + Field field = new Field() |
| 42 | + def fieldType = new GraphQLList(Scalars.GraphQLString) |
| 43 | + String[] result = {"test"} |
| 44 | + when: |
| 45 | + def executionResult = executionStrategy.completeValue(executionContext, fieldType, [field], result) |
| 46 | + |
| 47 | + then: |
| 48 | + executionResult.data == ["test"] |
| 49 | + } |
| 50 | + |
| 51 | +} |
0 commit comments