2020import static com .google .cloud .firestore .AggregateField .count ;
2121import static com .google .cloud .firestore .AggregateField .sum ;
2222import static com .google .common .truth .Truth .assertThat ;
23- import static org .mockito .Mockito .doReturn ;
2423import static java .util .Arrays .asList ;
2524import static java .util .Collections .singletonList ;
2625import static org .mockito .ArgumentMatchers .any ;
2726import static org .mockito .Mockito .doAnswer ;
27+ import static org .mockito .Mockito .doReturn ;
2828import static org .mockito .Mockito .mock ;
2929
30- import com .google .api .gax .rpc .ServerStreamingCallable ;
3130import com .google .cloud .firestore .spi .v1 .FirestoreRpc ;
3231import com .google .firestore .v1 .RunAggregationQueryRequest ;
3332import com .google .firestore .v1 .StructuredQuery ;
@@ -47,11 +46,11 @@ public class AggregateQueryTest {
4746 private final FirestoreRpc firestoreRpc = Mockito .mock (FirestoreRpc .class );
4847
4948 @ Spy
50- private final FirestoreImpl firestoreMock = new FirestoreImpl (
51- FirestoreOptions .newBuilder ().setProjectId ("test-project" ).build (), firestoreRpc );
49+ private final FirestoreImpl firestoreMock =
50+ new FirestoreImpl (
51+ FirestoreOptions .newBuilder ().setProjectId ("test-project" ).build (), firestoreRpc );
5252
53- @ Captor
54- private ArgumentCaptor <RunAggregationQueryRequest > runQuery ;
53+ @ Captor private ArgumentCaptor <RunAggregationQueryRequest > runQuery ;
5554
5655 private Query mockQuery ;
5756 private Query mockQuery2 ;
@@ -158,30 +157,31 @@ public void toProtoFromProtoRoundTripShouldProduceEqualAggregateQueryObjects() {
158157 @ Test
159158 public void withAlwaysUseImplicitOrderBy () throws Exception {
160159 doAnswer (
161- invocation -> {
162- com .google .api .gax .rpc .ResponseObserver <com .google .firestore .v1 .RunAggregationQueryResponse > observer = invocation
163- .getArgument (1 );
164- observer .onResponse (
165- com .google .firestore .v1 .RunAggregationQueryResponse .newBuilder ()
166- .setResult (
167- com .google .firestore .v1 .AggregationResult .newBuilder ()
168- .putAggregateFields (
169- "aggregate_0" ,
170- com .google .firestore .v1 .Value .newBuilder ()
171- .setIntegerValue (1 )
172- .build ()))
173- .build ());
174- observer .onComplete ();
175- return null ;
176- })
160+ invocation -> {
161+ com .google .api .gax .rpc .ResponseObserver <
162+ com .google .firestore .v1 .RunAggregationQueryResponse >
163+ observer = invocation .getArgument (1 );
164+ observer .onResponse (
165+ com .google .firestore .v1 .RunAggregationQueryResponse .newBuilder ()
166+ .setResult (
167+ com .google .firestore .v1 .AggregationResult .newBuilder ()
168+ .putAggregateFields (
169+ "aggregate_0" ,
170+ com .google .firestore .v1 .Value .newBuilder ()
171+ .setIntegerValue (1 )
172+ .build ()))
173+ .build ());
174+ observer .onComplete ();
175+ return null ;
176+ })
177177 .when (firestoreMock )
178178 .streamRequest (runQuery .capture (), any (), any ());
179179
180180 doReturn (
181- FirestoreOptions .newBuilder ()
182- .setProjectId ("test-project" )
183- .setAlwaysUseImplicitOrderBy (true )
184- .build ())
181+ FirestoreOptions .newBuilder ()
182+ .setProjectId ("test-project" )
183+ .setAlwaysUseImplicitOrderBy (true )
184+ .build ())
185185 .when (firestoreMock )
186186 .getOptions ();
187187
0 commit comments