File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
main/java/graphql/kickstart/spring/webclient/boot
test/java/graphql/kickstart/spring/webclient/boot Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ private JsonNode readTree(String rawResponse) {
4141 }
4242
4343 private List <GraphQLError > readErrors (JsonNode tree ) {
44- if (tree .has (ERRORS_FIELD ) && tree . get ( ERRORS_FIELD ) != null ) {
44+ if (tree .hasNonNull (ERRORS_FIELD )) {
4545 return convertList (tree .get (ERRORS_FIELD ), GraphQLError .class );
4646 }
4747 return emptyList ();
@@ -56,7 +56,7 @@ private JavaType constructListType(Class<?> type) {
5656 }
5757
5858 public <T > T get (String fieldName , Class <T > type ) {
59- if (data != null && data .has (fieldName ) && data . get ( fieldName ) != null ) {
59+ if (data != null && data .hasNonNull (fieldName )) {
6060 return objectMapper .convertValue (data .get (fieldName ), type );
6161 }
6262 return null ;
@@ -74,7 +74,7 @@ private Optional<JsonNode> getFirstDataEntry() {
7474 }
7575
7676 public <T > List <T > getList (String fieldName , Class <T > type ) {
77- if (data != null && data .has (fieldName ) && data . get ( fieldName ) != null ) {
77+ if (data != null && data .hasNonNull (fieldName )) {
7878 return convertList (data .get (fieldName ), type );
7979 }
8080 return emptyList ();
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ private GraphQLResponse constructResponse(String json) {
3030 return new GraphQLResponse (json , mockedMapper );
3131 }
3232
33+ @ Test
34+ void getErrors_noErrors_returnsEmptyList () {
35+ GraphQLResponse response = constructResponse ("{ \" data\" : null }" );
36+ assertTrue (response .getErrors ().isEmpty ());
37+ }
38+
3339 @ Test
3440 void getFieldName_dataIsNull_returnsNull () {
3541 GraphQLResponse response = constructResponse ("{ \" data\" : null }" );
You can’t perform that action at this time.
0 commit comments