1515import reactor .test .StepVerifier ;
1616
1717import java .time .Duration ;
18- import java .util .Arrays ;
18+ import java .util .ArrayList ;
1919import java .util .function .Consumer ;
2020
2121import static graphql .schema .GraphQLObjectType .newObject ;
22+ import static java .util .Arrays .asList ;
23+ import static java .util .Collections .emptyList ;
2224import static java .util .concurrent .TimeUnit .MILLISECONDS ;
2325import static java .util .concurrent .TimeUnit .SECONDS ;
2426import static org .assertj .core .api .Assertions .assertThat ;
@@ -156,7 +158,7 @@ public void testArray() throws Exception {
156158
157159 subscriber
158160 .assertChanges (it -> it .containsExactly (
159- tuple ("01:800" , "" , ImmutableMap .of ("a" , Arrays . asList (ImmutableMap .of ("b" , "0 0" ), ImmutableMap .of ("b" , "0 1" ), ImmutableMap .of ("b" , "0 2" )))),
161+ tuple ("01:800" , "" , ImmutableMap .of ("a" , asList (ImmutableMap .of ("b" , "0 0" ), ImmutableMap .of ("b" , "0 1" ), ImmutableMap .of ("b" , "0 2" )))),
160162
161163 tuple ("02:100" , "a[0].b" , "1 0" ),
162164 tuple ("02:100" , "a[1].b" , "1 1" ),
@@ -173,6 +175,42 @@ public void testArray() throws Exception {
173175 .assertComplete ();
174176 }
175177
178+ @ Test
179+ public void testArrayStartsWith () throws Exception {
180+ GraphQLObjectType innerType = newObject ()
181+ .name ("Inner" )
182+ .field (newStringField ("b" ).staticValue ("foo" ))
183+ .build ();
184+
185+ GraphQLSchema schema = newQuerySchema (it -> it
186+ .field (
187+ newField ("a" , new GraphQLList (innerType ))
188+ .dataFetcher (env -> Flowable
189+ .just (asList (true , true , true ))
190+ .delay (1 , SECONDS , scheduler )
191+ .startWith (new ArrayList <Boolean >())
192+ )
193+ )
194+ );
195+
196+ ExecutionResult executionResult = new GraphQL (schema , strategy ).execute ("{ a { b } }" );
197+
198+ Flowable .fromPublisher ((Publisher <Change >) executionResult .getData ()).timestamp (scheduler ).subscribe (subscriber );
199+
200+ scheduler .advanceTimeBy (2 , SECONDS );
201+
202+ subscriber
203+ .assertChanges (it -> it .containsExactly (
204+ tuple ("00:000" , "" , ImmutableMap .of ("a" , emptyList ())),
205+
206+ tuple ("01:000" , "a" , asList (ImmutableMap .of ("b" , "foo" ), ImmutableMap .of ("b" , "foo" ), ImmutableMap .of ("b" , "foo" ))),
207+ // FIXME this values are duplicated. For now, let's call it "at least once" delivery :D
208+ tuple ("01:000" , "a[1]" , ImmutableMap .of ("b" , "foo" )),
209+ tuple ("01:000" , "a[2]" , ImmutableMap .of ("b" , "foo" ))
210+ ))
211+ .assertComplete ();
212+ }
213+
176214 @ Test
177215 public void testAnyPublisher () throws Exception {
178216 Duration tick = Duration .ofSeconds (1 );
0 commit comments