@@ -477,12 +477,11 @@ public void testQueryPaginationWithLimit() throws DatastoreRpcException {
477477 .andReturn (responses .get (i ));
478478 }
479479 EasyMock .replay (rpcFactoryMock , rpcMock );
480- Datastore mockDatastore =
481- options .toBuilder ()
482- .retryParams (RetryParams .defaultInstance ())
483- .serviceRpcFactory (rpcFactoryMock )
484- .build ()
485- .service ();
480+ Datastore mockDatastore = options .toBuilder ()
481+ .retryParams (RetryParams .defaultInstance ())
482+ .serviceRpcFactory (rpcFactoryMock )
483+ .build ()
484+ .service ();
486485 int limit = 2 ;
487486 int totalCount = 0 ;
488487 StructuredQuery <Entity > query = Query .entityQueryBuilder ().limit (limit ).build ();
@@ -511,45 +510,40 @@ private List<RunQueryResponse> buildResponsesForQueryPaginationWithLimit() {
511510 Query <Entity > query = Query .entityQueryBuilder ().build ();
512511 RunQueryRequest .Builder requestPb = RunQueryRequest .newBuilder ();
513512 query .populatePb (requestPb );
514- QueryResultBatch queryResultBatchPb =
515- RunQueryResponse .newBuilder ()
516- .mergeFrom (((DatastoreImpl ) datastore ).runQuery (requestPb .build ()))
517- .getBatch ();
518- QueryResultBatch queryResultBatchPb1 =
519- QueryResultBatch .newBuilder ()
520- .mergeFrom (queryResultBatchPb )
521- .setMoreResults (QueryResultBatch .MoreResultsType .NOT_FINISHED )
522- .clearEntityResult ()
523- .addAllEntityResult (queryResultBatchPb .getEntityResultList ().subList (0 , 1 ))
524- .setEndCursor (queryResultBatchPb .getEntityResultList ().get (0 ).getCursor ())
525- .build ();
513+ QueryResultBatch queryResultBatchPb = RunQueryResponse .newBuilder ()
514+ .mergeFrom (((DatastoreImpl ) datastore ).runQuery (requestPb .build ()))
515+ .getBatch ();
516+ QueryResultBatch queryResultBatchPb1 = QueryResultBatch .newBuilder ()
517+ .mergeFrom (queryResultBatchPb )
518+ .setMoreResults (QueryResultBatch .MoreResultsType .NOT_FINISHED )
519+ .clearEntityResult ()
520+ .addAllEntityResult (queryResultBatchPb .getEntityResultList ().subList (0 , 1 ))
521+ .setEndCursor (queryResultBatchPb .getEntityResultList ().get (0 ).getCursor ())
522+ .build ();
526523 responses .add (RunQueryResponse .newBuilder ().setBatch (queryResultBatchPb1 ).build ());
527- QueryResultBatch queryResultBatchPb2 =
528- QueryResultBatch .newBuilder ()
529- .mergeFrom (queryResultBatchPb )
530- .setMoreResults (QueryResultBatch .MoreResultsType .MORE_RESULTS_AFTER_LIMIT )
531- .clearEntityResult ()
532- .addAllEntityResult (queryResultBatchPb .getEntityResultList ().subList (1 , 2 ))
533- .setEndCursor (queryResultBatchPb .getEntityResultList ().get (1 ).getCursor ())
534- .build ();
524+ QueryResultBatch queryResultBatchPb2 = QueryResultBatch .newBuilder ()
525+ .mergeFrom (queryResultBatchPb )
526+ .setMoreResults (QueryResultBatch .MoreResultsType .MORE_RESULTS_AFTER_LIMIT )
527+ .clearEntityResult ()
528+ .addAllEntityResult (queryResultBatchPb .getEntityResultList ().subList (1 , 2 ))
529+ .setEndCursor (queryResultBatchPb .getEntityResultList ().get (1 ).getCursor ())
530+ .build ();
535531 responses .add (RunQueryResponse .newBuilder ().setBatch (queryResultBatchPb2 ).build ());
536- QueryResultBatch queryResultBatchPb3 =
537- QueryResultBatch .newBuilder ()
538- .mergeFrom (queryResultBatchPb )
539- .setMoreResults (QueryResultBatch .MoreResultsType .MORE_RESULTS_AFTER_LIMIT )
540- .clearEntityResult ()
541- .addAllEntityResult (queryResultBatchPb .getEntityResultList ().subList (2 , 4 ))
542- .setEndCursor (queryResultBatchPb .getEntityResultList ().get (3 ).getCursor ())
543- .build ();
532+ QueryResultBatch queryResultBatchPb3 = QueryResultBatch .newBuilder ()
533+ .mergeFrom (queryResultBatchPb )
534+ .setMoreResults (QueryResultBatch .MoreResultsType .MORE_RESULTS_AFTER_LIMIT )
535+ .clearEntityResult ()
536+ .addAllEntityResult (queryResultBatchPb .getEntityResultList ().subList (2 , 4 ))
537+ .setEndCursor (queryResultBatchPb .getEntityResultList ().get (3 ).getCursor ())
538+ .build ();
544539 responses .add (RunQueryResponse .newBuilder ().setBatch (queryResultBatchPb3 ).build ());
545- QueryResultBatch queryResultBatchPb4 =
546- QueryResultBatch .newBuilder ()
547- .mergeFrom (queryResultBatchPb )
548- .setMoreResults (QueryResultBatch .MoreResultsType .NO_MORE_RESULTS )
549- .clearEntityResult ()
550- .addAllEntityResult (queryResultBatchPb .getEntityResultList ().subList (4 , 5 ))
551- .setEndCursor (queryResultBatchPb .getEntityResultList ().get (4 ).getCursor ())
552- .build ();
540+ QueryResultBatch queryResultBatchPb4 = QueryResultBatch .newBuilder ()
541+ .mergeFrom (queryResultBatchPb )
542+ .setMoreResults (QueryResultBatch .MoreResultsType .NO_MORE_RESULTS )
543+ .clearEntityResult ()
544+ .addAllEntityResult (queryResultBatchPb .getEntityResultList ().subList (4 , 5 ))
545+ .setEndCursor (queryResultBatchPb .getEntityResultList ().get (4 ).getCursor ())
546+ .build ();
553547 responses .add (RunQueryResponse .newBuilder ().setBatch (queryResultBatchPb4 ).build ());
554548 return responses ;
555549 }
0 commit comments