Skip to content

Commit

Permalink
Minor style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajay Kannan committed Jan 15, 2016
1 parent e4113c4 commit 461f375
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ public Integer limit() {
}

public Builder<V> toBuilder() {
return new Builder<V>(this);
return new Builder<>(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,11 @@ public void testQueryPaginationWithLimit() throws DatastoreRpcException {
.andReturn(responses.get(i));
}
EasyMock.replay(rpcFactoryMock, rpcMock);
Datastore mockDatastore =
options.toBuilder()
.retryParams(RetryParams.defaultInstance())
.serviceRpcFactory(rpcFactoryMock)
.build()
.service();
Datastore mockDatastore = options.toBuilder()
.retryParams(RetryParams.defaultInstance())
.serviceRpcFactory(rpcFactoryMock)
.build()
.service();
int limit = 2;
int totalCount = 0;
StructuredQuery<Entity> query = Query.entityQueryBuilder().limit(limit).build();
Expand Down Expand Up @@ -511,45 +510,40 @@ private List<RunQueryResponse> buildResponsesForQueryPaginationWithLimit() {
Query<Entity> query = Query.entityQueryBuilder().build();
RunQueryRequest.Builder requestPb = RunQueryRequest.newBuilder();
query.populatePb(requestPb);
QueryResultBatch queryResultBatchPb =
RunQueryResponse.newBuilder()
.mergeFrom(((DatastoreImpl) datastore).runQuery(requestPb.build()))
.getBatch();
QueryResultBatch queryResultBatchPb1 =
QueryResultBatch.newBuilder()
.mergeFrom(queryResultBatchPb)
.setMoreResults(QueryResultBatch.MoreResultsType.NOT_FINISHED)
.clearEntityResult()
.addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(0, 1))
.setEndCursor(queryResultBatchPb.getEntityResultList().get(0).getCursor())
.build();
QueryResultBatch queryResultBatchPb = RunQueryResponse.newBuilder()
.mergeFrom(((DatastoreImpl) datastore).runQuery(requestPb.build()))
.getBatch();
QueryResultBatch queryResultBatchPb1 = QueryResultBatch.newBuilder()
.mergeFrom(queryResultBatchPb)
.setMoreResults(QueryResultBatch.MoreResultsType.NOT_FINISHED)
.clearEntityResult()
.addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(0, 1))
.setEndCursor(queryResultBatchPb.getEntityResultList().get(0).getCursor())
.build();
responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb1).build());
QueryResultBatch queryResultBatchPb2 =
QueryResultBatch.newBuilder()
.mergeFrom(queryResultBatchPb)
.setMoreResults(QueryResultBatch.MoreResultsType.MORE_RESULTS_AFTER_LIMIT)
.clearEntityResult()
.addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(1, 2))
.setEndCursor(queryResultBatchPb.getEntityResultList().get(1).getCursor())
.build();
QueryResultBatch queryResultBatchPb2 = QueryResultBatch.newBuilder()
.mergeFrom(queryResultBatchPb)
.setMoreResults(QueryResultBatch.MoreResultsType.MORE_RESULTS_AFTER_LIMIT)
.clearEntityResult()
.addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(1, 2))
.setEndCursor(queryResultBatchPb.getEntityResultList().get(1).getCursor())
.build();
responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb2).build());
QueryResultBatch queryResultBatchPb3 =
QueryResultBatch.newBuilder()
.mergeFrom(queryResultBatchPb)
.setMoreResults(QueryResultBatch.MoreResultsType.MORE_RESULTS_AFTER_LIMIT)
.clearEntityResult()
.addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(2, 4))
.setEndCursor(queryResultBatchPb.getEntityResultList().get(3).getCursor())
.build();
QueryResultBatch queryResultBatchPb3 = QueryResultBatch.newBuilder()
.mergeFrom(queryResultBatchPb)
.setMoreResults(QueryResultBatch.MoreResultsType.MORE_RESULTS_AFTER_LIMIT)
.clearEntityResult()
.addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(2, 4))
.setEndCursor(queryResultBatchPb.getEntityResultList().get(3).getCursor())
.build();
responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb3).build());
QueryResultBatch queryResultBatchPb4 =
QueryResultBatch.newBuilder()
.mergeFrom(queryResultBatchPb)
.setMoreResults(QueryResultBatch.MoreResultsType.NO_MORE_RESULTS)
.clearEntityResult()
.addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(4, 5))
.setEndCursor(queryResultBatchPb.getEntityResultList().get(4).getCursor())
.build();
QueryResultBatch queryResultBatchPb4 = QueryResultBatch.newBuilder()
.mergeFrom(queryResultBatchPb)
.setMoreResults(QueryResultBatch.MoreResultsType.NO_MORE_RESULTS)
.clearEntityResult()
.addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(4, 5))
.setEndCursor(queryResultBatchPb.getEntityResultList().get(4).getCursor())
.build();
responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb4).build());
return responses;
}
Expand Down

0 comments on commit 461f375

Please sign in to comment.