Skip to content

Commit 9385eec

Browse files
authored
Merge pull request graphql-java#989 from graphql-java/preparsed-document-assert
use graphql Assert
2 parents bc84afa + 393b468 commit 9385eec

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/main/java/graphql/execution/preparsed/PreparsedDocumentEntry.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import graphql.GraphQLError;
44
import graphql.language.Document;
55

6-
import java.util.Collections;
76
import java.util.List;
8-
import java.util.Objects;
7+
8+
import static graphql.Assert.assertNotNull;
9+
import static java.util.Collections.singletonList;
910

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

1819
public PreparsedDocumentEntry(Document document) {
19-
Objects.requireNonNull(document);
20+
assertNotNull(document);
2021
this.document = document;
2122
this.errors = null;
2223
}
2324

2425
public PreparsedDocumentEntry(List<? extends GraphQLError> errors) {
25-
Objects.requireNonNull(errors);
26+
assertNotNull(errors);
2627
this.document = null;
2728
this.errors = errors;
2829
}
2930

3031
public PreparsedDocumentEntry(GraphQLError error) {
31-
this(Collections.singletonList(Objects.requireNonNull(error)));
32+
this(singletonList(assertNotNull(error)));
3233
}
3334

3435
public Document getDocument() {

src/test/groovy/graphql/execution/preparsed/PreparsedDocumentEntryTest.groovy

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package graphql.execution.preparsed
22

3+
import graphql.AssertException
34
import graphql.GraphQLError
45
import graphql.InvalidSyntaxError
56
import graphql.language.Document
@@ -21,12 +22,12 @@ class PreparsedDocumentEntryTest extends Specification {
2122
docEntry.errors == null
2223
}
2324

24-
def "Ensure a null document throws NPE"() {
25+
def "Ensure a null document throws Exception"() {
2526
when:
2627
new PreparsedDocumentEntry((Document) null)
2728

2829
then:
29-
thrown(NullPointerException)
30+
thrown(AssertException)
3031
}
3132

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

45-
def "Ensure a null errors throws NPE"() {
46+
def "Ensure a null errors throws Exception"() {
4647
when:
4748
new PreparsedDocumentEntry((List<GraphQLError>) null)
4849

4950
then:
50-
thrown(NullPointerException)
51+
thrown(AssertException)
5152
}
5253

53-
def "Ensure a null error throws NPE"() {
54+
def "Ensure a null error throws Exception"() {
5455
when:
5556
new PreparsedDocumentEntry((GraphQLError) null)
5657

5758
then:
58-
thrown(NullPointerException)
59+
thrown(AssertException)
5960
}
6061

6162

0 commit comments

Comments
 (0)