use of com.google.storage.v2.WriteObjectRequest in project hadoop-connectors by GoogleCloudDataproc.
the class GoogleCloudStorageGrpcWriteChannelTest method writeSendsSingleInsertObjectRequestWithChecksums.
@Test
public void writeSendsSingleInsertObjectRequestWithChecksums() throws Exception {
AsyncWriteChannelOptions options = AsyncWriteChannelOptions.builder().setGrpcChecksumsEnabled(true).build();
ObjectWriteConditions writeConditions = ObjectWriteConditions.NONE;
GoogleCloudStorageGrpcWriteChannel writeChannel = newWriteChannel(options, writeConditions, /* requesterPaysProject= */
null);
fakeService.setQueryWriteStatusResponses(ImmutableList.of(QueryWriteStatusResponse.newBuilder().setPersistedSize(0).build(), QueryWriteStatusResponse.newBuilder().setPersistedSize(0).build()).iterator());
ByteString data = ByteString.copyFromUtf8("test data");
writeChannel.initialize();
writeChannel.write(data.asReadOnlyByteBuffer());
writeChannel.close();
WriteObjectRequest expectedInsertRequest = WriteObjectRequest.newBuilder().setUploadId(UPLOAD_ID).setChecksummedData(ChecksummedData.newBuilder().setContent(data).setCrc32C((uInt32Value(863614154)))).setObjectChecksums(ObjectChecksums.newBuilder().setCrc32C((uInt32Value(863614154)))).setFinishWrite(true).build();
verify(fakeService, times(1)).startResumableWrite(eq(START_REQUEST), any());
verify(fakeService.insertRequestObserver, times(1)).onNext(expectedInsertRequest);
verify(fakeService.insertRequestObserver, atLeast(1)).onCompleted();
}
use of com.google.storage.v2.WriteObjectRequest in project hadoop-connectors by GoogleCloudDataproc.
the class GoogleCloudStorageGrpcWriteChannelTest method writeSendsSingleInsertObjectRequestWithoutChecksums.
@Test
public void writeSendsSingleInsertObjectRequestWithoutChecksums() throws Exception {
AsyncWriteChannelOptions options = AsyncWriteChannelOptions.builder().setGrpcChecksumsEnabled(false).build();
ObjectWriteConditions writeConditions = ObjectWriteConditions.NONE;
GoogleCloudStorageGrpcWriteChannel writeChannel = newWriteChannel(options, writeConditions, /* requesterPaysProject= */
null);
ByteString data = ByteString.copyFromUtf8("test data");
writeChannel.initialize();
writeChannel.write(data.asReadOnlyByteBuffer());
writeChannel.close();
WriteObjectRequest expectedInsertRequest = WriteObjectRequest.newBuilder().setUploadId(UPLOAD_ID).setChecksummedData(ChecksummedData.newBuilder().setContent(data)).setFinishWrite(true).build();
verify(fakeService, times(1)).startResumableWrite(eq(START_REQUEST), any());
verify(fakeService.insertRequestObserver, times(1)).onNext(expectedInsertRequest);
verify(fakeService.insertRequestObserver, atLeast(1)).onCompleted();
}
Aggregations