Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import graphql.GraphQLError;
import graphql.language.Document;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

import static graphql.Assert.assertNotNull;
import static java.util.Collections.singletonList;

/**
* An instance of a preparsed document entry represents the result of a query parse and validation, like
Expand All @@ -16,19 +17,19 @@ public class PreparsedDocumentEntry {
private final List<? extends GraphQLError> errors;

public PreparsedDocumentEntry(Document document) {
Objects.requireNonNull(document);
assertNotNull(document);
this.document = document;
this.errors = null;
}

public PreparsedDocumentEntry(List<? extends GraphQLError> errors) {
Objects.requireNonNull(errors);
assertNotNull(errors);
this.document = null;
this.errors = errors;
}

public PreparsedDocumentEntry(GraphQLError error) {
this(Collections.singletonList(Objects.requireNonNull(error)));
this(singletonList(assertNotNull(error)));
}

public Document getDocument() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package graphql.execution.preparsed

import graphql.AssertException
import graphql.GraphQLError
import graphql.InvalidSyntaxError
import graphql.language.Document
Expand All @@ -21,12 +22,12 @@ class PreparsedDocumentEntryTest extends Specification {
docEntry.errors == null
}

def "Ensure a null document throws NPE"() {
def "Ensure a null document throws Exception"() {
when:
new PreparsedDocumentEntry((Document) null)

then:
thrown(NullPointerException)
thrown(AssertException)
}

def "Ensure a non-null errors returns"() {
Expand All @@ -42,20 +43,20 @@ class PreparsedDocumentEntryTest extends Specification {
docEntry.errors == errors
}

def "Ensure a null errors throws NPE"() {
def "Ensure a null errors throws Exception"() {
when:
new PreparsedDocumentEntry((List<GraphQLError>) null)

then:
thrown(NullPointerException)
thrown(AssertException)
}

def "Ensure a null error throws NPE"() {
def "Ensure a null error throws Exception"() {
when:
new PreparsedDocumentEntry((GraphQLError) null)

then:
thrown(NullPointerException)
thrown(AssertException)
}


Expand Down