Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashanth Sagar committed Aug 3, 2021
1 parent 199b0d9 commit cc89077
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;

/** Implements WritableByteChannel to provide write access to GCS via gRPC. */
/**
* Implements WritableByteChannel to provide write access to GCS via gRPC.
*/
public final class GoogleCloudStorageGrpcWriteChannel
extends BaseAbstractGoogleAsyncWriteChannel<WriteObjectResponse>
implements GoogleCloudStorageItemInfo.Provider {
Expand Down Expand Up @@ -345,7 +347,9 @@ private void recreateStub(Status.Code statusCode) {
}
}

/** Handler for responses from the Insert streaming RPC. */
/**
* Handler for responses from the Insert streaming RPC.
*/
private class InsertChunkResponseObserver
implements ClientResponseObserver<WriteObjectRequest, WriteObjectResponse> {

Expand Down Expand Up @@ -422,7 +426,9 @@ public void beforeStart(
}
}

/** Send a StartResumableWriteRequest and return the uploadId of the resumable write. */
/**
* Send a StartResumableWriteRequest and return the uploadId of the resumable write.
*/
private String startResumableUpload() throws IOException {
WriteObjectSpec.Builder insertObjectSpecBuilder =
WriteObjectSpec.newBuilder()
Expand All @@ -440,16 +446,19 @@ private String startResumableUpload() throws IOException {
insertObjectSpecBuilder.setIfMetagenerationMatch(writeConditions.getMetaGenerationMatch());
}

Builder commonRequestParamsBuilder = CommonRequestParams.newBuilder();
Builder commonRequestParamsBuilder = null;
if (requesterPaysProject != null) {
commonRequestParamsBuilder = CommonRequestParams.newBuilder();
commonRequestParamsBuilder.setUserProject(requesterPaysProject);
}

StartResumableWriteRequest request =
StartResumableWriteRequest.newBuilder()
.setWriteObjectSpec(insertObjectSpecBuilder)
.setCommonRequestParams(commonRequestParamsBuilder)
.build();
StartResumableWriteRequest.Builder startResumableWriteRequestBuilder = StartResumableWriteRequest
.newBuilder();
startResumableWriteRequestBuilder.setWriteObjectSpec(insertObjectSpecBuilder);
if (commonRequestParamsBuilder != null) {
startResumableWriteRequestBuilder.setCommonRequestParams(commonRequestParamsBuilder);
}
StartResumableWriteRequest request = startResumableWriteRequestBuilder.build();

SimpleResponseObserver<StartResumableWriteResponse> responseObserver =
new SimpleResponseObserver<>();
Expand Down Expand Up @@ -522,7 +531,9 @@ private long getCommittedWriteSize(String uploadId) throws IOException {
return responseObserver.getResponse().getCommittedSize();
}

/** Stream observer for single response RPCs. */
/**
* Stream observer for single response RPCs.
*/
private class SimpleResponseObserver<T> implements StreamObserver<T> {

// The response from the server, populated at the end of a successful RPC.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public void writeUsesRequesterPaysProjectIfProvided() throws Exception {
writeChannel.close();

StartResumableWriteRequest.Builder expectedRequestBuilder = START_REQUEST.toBuilder();
// expectedRequestBuilder.getWriteObjectSpecBuilder().setUserProject("project-id");
expectedRequestBuilder.getCommonRequestParamsBuilder().setUserProject("project-id");
verify(fakeService, times(1)).startResumableWrite(eq(expectedRequestBuilder.build()), any());
}

Expand Down

0 comments on commit cc89077

Please sign in to comment.