@@ -57,7 +57,7 @@ void parsePath() throws Exception {
57
57
}
58
58
59
59
private void testParsePath (String path , Object ... expected ) throws Exception {
60
- assertThat (getField (path , "{}" ).getParsedPath ()).containsExactly (expected );
60
+ assertThat (getFieldOnDataResponse (path , "{}" ).getParsedPath ()).containsExactly (expected );
61
61
}
62
62
63
63
@ Test
@@ -73,7 +73,7 @@ void parsePathInvalid() {
73
73
}
74
74
75
75
private void testParseInvalidPath (String path ) {
76
- assertThatIllegalArgumentException ().isThrownBy (() -> getField (path , "{}" )).withMessage ("Invalid path: '" + path + "'" );
76
+ assertThatIllegalArgumentException ().isThrownBy (() -> getFieldOnDataResponse (path , "{}" )).withMessage ("Invalid path: '" + path + "'" );
77
77
}
78
78
79
79
@ Test
@@ -87,14 +87,15 @@ void fieldValue() throws Exception {
87
87
testFieldValue ("me" , "{}" , null ); // "data" not null but no such key
88
88
testFieldValue ("me.friends" , "{\" me\" :{}}" , null );
89
89
testFieldValue ("me.friends[0]" , "{\" me\" : {\" friends\" : []}}" , null );
90
+ testFieldValue ("me.friends[0]" , "{\" me\" : {\" friends\" : []}}" , null );
90
91
91
92
// nest within map or list
92
93
testFieldValue ("me.name" , "{\" me\" :{\" name\" :\" Luke\" }}" , "Luke" );
93
94
testFieldValue ("me.friends[1].name" , "{\" me\" : {\" friends\" : [{\" name\" : \" Luke\" }, {\" name\" : \" Yoda\" }]}}" , "Yoda" );
94
95
}
95
96
96
97
private void testFieldValue (String path , String dataJson , @ Nullable Object expected ) throws Exception {
97
- Object value = getField (path , dataJson ).getValue ();
98
+ Object value = getFieldOnDataResponse (path , dataJson ).getValue ();
98
99
if (expected == null ) {
99
100
assertThat (value ).isNull ();
100
101
}
@@ -112,7 +113,7 @@ void fieldValueInvalidPath() {
112
113
}
113
114
114
115
private void testFieldValueInvalidPath (String path , String json ) {
115
- assertThatIllegalArgumentException ().isThrownBy (() -> getField (path , json ))
116
+ assertThatIllegalArgumentException ().isThrownBy (() -> getFieldOnDataResponse (path , json ))
116
117
.withMessageStartingWith ("Invalid path" );
117
118
}
118
119
@@ -126,7 +127,7 @@ void fieldErrors() {
126
127
GraphQLError error2 = createError ("/me/friends" , "fail-me-friends" );
127
128
GraphQLError error3 = createError ("/me/friends[0]/name" , "fail-me-friends-name" );
128
129
129
- ClientResponseField field = getField (path , error0 , error1 , error2 , error3 );
130
+ ClientResponseField field = getFieldOnErrorResponse (path , error0 , error1 , error2 , error3 );
130
131
List <ResponseError > errors = field .getErrors ();
131
132
132
133
assertThat (errors ).hasSize (3 );
@@ -143,13 +144,13 @@ private GraphQLError createError(@Nullable String errorPath, String message) {
143
144
return builder .build ();
144
145
}
145
146
146
- private ClientResponseField getField (String path , String dataJson ) throws Exception {
147
+ private ClientResponseField getFieldOnDataResponse (String path , String dataJson ) throws Exception {
147
148
Map <?, ?> dataMap = mapper .readValue (dataJson , Map .class );
148
149
ClientGraphQlResponse response = creatResponse (Collections .singletonMap ("data" , dataMap ));
149
150
return response .field (path );
150
151
}
151
152
152
- private ClientResponseField getField (String path , GraphQLError ... errors ) {
153
+ private ClientResponseField getFieldOnErrorResponse (String path , GraphQLError ... errors ) {
153
154
List <?> list = Arrays .stream (errors ).map (GraphQLError ::toSpecification ).collect (Collectors .toList ());
154
155
ClientGraphQlResponse response = creatResponse (Collections .singletonMap ("errors" , list ));
155
156
return response .field (path );
0 commit comments