1616
1717package org .springframework .graphql .data .query ;
1818
19+ import java .nio .charset .StandardCharsets ;
1920import java .util .List ;
2021import java .util .concurrent .atomic .AtomicReference ;
22+ import java .util .stream .Stream ;
2123
2224import graphql .schema .DataFetcher ;
2325import graphql .schema .DataFetchingFieldSelectionSet ;
24- import org .junit .jupiter .api .Test ;
26+ import org .junit .jupiter .params .ParameterizedTest ;
27+ import org .junit .jupiter .params .provider .Arguments ;
28+ import org .junit .jupiter .params .provider .MethodSource ;
2529
30+ import org .springframework .core .io .ByteArrayResource ;
31+ import org .springframework .core .io .Resource ;
2632import org .springframework .data .util .TypeInformation ;
2733import org .springframework .graphql .BookSource ;
2834import org .springframework .graphql .GraphQlSetup ;
3440 * Unit test for {@link PropertySelection}.
3541 *
3642 * @author Rossen Stoyanchev
43+ * @author Brian Clozel
3744 */
3845class PropertySelectionTests {
3946
40- @ Test
41- void propertySelectionWithConnection () {
47+ @ ParameterizedTest
48+ @ MethodSource ("schemaResource" )
49+ void propertySelectionWithConnection (Resource schemaResource ) {
4250
4351 AtomicReference <DataFetchingFieldSelectionSet > ref = new AtomicReference <>();
4452 DataFetcher <?> dataFetcher = environment -> {
4553 ref .set (environment .getSelectionSet ());
4654 return null ;
4755 };
4856
49- GraphQlSetup .schemaResource (BookSource . paginationSchema )
57+ GraphQlSetup .schemaResource (schemaResource )
5058 .typeDefinitionConfigurer (new ConnectionTypeDefinitionConfigurer ())
5159 .dataFetcher ("Query" , "books" , dataFetcher )
5260 .toGraphQlService ()
@@ -59,4 +67,20 @@ void propertySelectionWithConnection() {
5967 assertThat (list ).containsExactly ("id" , "name" );
6068 }
6169
70+ static Stream <Arguments > schemaResource () {
71+ return Stream .of (
72+ Arguments .of (BookSource .paginationSchema ),
73+ Arguments .of (new ByteArrayResource ("""
74+ type Query {
75+ books(first:Int, after:String): BookConnection!
76+ }
77+
78+ type Book {
79+ id: ID
80+ name: String
81+ }
82+ """ .getBytes (StandardCharsets .UTF_8 )))
83+ );
84+ }
85+
6286}
0 commit comments