File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
main/java/org/springframework/graphql/test/tester
test/java/org/springframework/graphql/test/tester Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -330,24 +330,25 @@ private static final class DefaultPath implements Path {
330
330
private final JsonPathExpectationsHelper pathHelper ;
331
331
332
332
private DefaultPath (String path , ResponseDelegate delegate ) {
333
-
334
333
Assert .notNull (path , "`path` is required" );
335
334
Assert .notNull (delegate , "ResponseContainer is required" );
336
335
336
+ String fullPath = initFullPath (path );
337
+
337
338
this .path = path ;
338
339
this .delegate = delegate ;
339
- this .jsonPath = initJsonPath ( path );
340
- this .pathHelper = new JsonPathExpectationsHelper (this . jsonPath . getPath () );
340
+ this .jsonPath = JsonPath . compile ( fullPath );
341
+ this .pathHelper = new JsonPathExpectationsHelper (fullPath );
341
342
}
342
343
343
- private static JsonPath initJsonPath (String path ) {
344
+ private static String initFullPath (String path ) {
344
345
if (!StringUtils .hasText (path )) {
345
346
path = "$.data" ;
346
347
}
347
348
else if (!path .startsWith ("$" ) && !path .startsWith ("data." )) {
348
349
path = "$.data." + path ;
349
350
}
350
- return JsonPath . compile ( path ) ;
351
+ return path ;
351
352
}
352
353
353
354
@ Override
Original file line number Diff line number Diff line change @@ -48,9 +48,10 @@ void hasValue() {
48
48
GraphQlTester .Response response = graphQlTester ().document (document ).execute ();
49
49
response .path ("me.name" ).hasValue ();
50
50
response .path ("me.friends" ).hasValue ();
51
+ response .path ("me[?(@.name == 'Luke Skywalker')].name" ).hasValue (); // gh-377
51
52
52
53
assertThatThrownBy (() -> response .path ("hero" ).hasValue ())
53
- .hasMessageContaining ("No value at JSON path \" $[' data'][' hero'] " );
54
+ .hasMessageContaining ("No value at JSON path \" $. data. hero\" " );
54
55
55
56
assertThat (getActualRequestDocument ()).contains (document );
56
57
}
@@ -152,7 +153,7 @@ void entityList() {
152
153
"{" +
153
154
" \" me\" :{" +
154
155
" \" name\" :\" Luke Skywalker\" ,"
155
- + " \" friends\" :[{\" name\" :\" Han Solo\" }, {\" name\" :\" Leia Organa\" }]" +
156
+ + " \" friends\" :[{\" name\" :\" Han Solo\" }, {\" name\" :\" Leia Organa\" }]" +
156
157
" }" +
157
158
"}" );
158
159
You can’t perform that action at this time.
0 commit comments