Skip to content
Permalink
Browse files
feat: re-generated to pick up changes in the API or client library ge…
…nerator. (#70)
  • Loading branch information
yoshi-automation committed Feb 10, 2020
1 parent 2bbbb65 commit 363196550f5d5a7381ec88e3404d334475fe430e
@@ -53,8 +53,12 @@
* <code>
* BaseBigQueryReadSettings.Builder baseBigQueryReadSettingsBuilder =
* BaseBigQueryReadSettings.newBuilder();
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* baseBigQueryReadSettingsBuilder
* .createReadSessionSettings()
* .setRetrySettings(
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* BaseBigQueryReadSettings baseBigQueryReadSettings = baseBigQueryReadSettingsBuilder.build();
* </code>
* </pre>
@@ -68,8 +68,12 @@
* <code>
* BigQueryReadStubSettings.Builder baseBigQueryReadSettingsBuilder =
* BigQueryReadStubSettings.newBuilder();
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* baseBigQueryReadSettingsBuilder
* .createReadSessionSettings()
* .setRetrySettings(
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* BigQueryReadStubSettings baseBigQueryReadSettings = baseBigQueryReadSettingsBuilder.build();
* </code>
* </pre>
@@ -62,8 +62,12 @@
* <code>
* BigQueryWriteSettings.Builder bigQueryWriteSettingsBuilder =
* BigQueryWriteSettings.newBuilder();
* bigQueryWriteSettingsBuilder.createWriteStreamSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* bigQueryWriteSettingsBuilder
* .createWriteStreamSettings()
* .setRetrySettings(
* bigQueryWriteSettingsBuilder.createWriteStreamSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* BigQueryWriteSettings bigQueryWriteSettings = bigQueryWriteSettingsBuilder.build();
* </code>
* </pre>
@@ -71,8 +71,12 @@
* <code>
* BigQueryWriteStubSettings.Builder bigQueryWriteSettingsBuilder =
* BigQueryWriteStubSettings.newBuilder();
* bigQueryWriteSettingsBuilder.createWriteStreamSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* bigQueryWriteSettingsBuilder
* .createWriteStreamSettings()
* .setRetrySettings(
* bigQueryWriteSettingsBuilder.createWriteStreamSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* BigQueryWriteStubSettings bigQueryWriteSettings = bigQueryWriteSettingsBuilder.build();
* </code>
* </pre>
@@ -63,8 +63,12 @@
* <code>
* BaseBigQueryStorageSettings.Builder baseBigQueryStorageSettingsBuilder =
* BaseBigQueryStorageSettings.newBuilder();
* baseBigQueryStorageSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* baseBigQueryStorageSettingsBuilder
* .createReadSessionSettings()
* .setRetrySettings(
* baseBigQueryStorageSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* BaseBigQueryStorageSettings baseBigQueryStorageSettings = baseBigQueryStorageSettingsBuilder.build();
* </code>
* </pre>
@@ -72,8 +72,12 @@
* <code>
* BigQueryStorageStubSettings.Builder baseBigQueryStorageSettingsBuilder =
* BigQueryStorageStubSettings.newBuilder();
* baseBigQueryStorageSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* baseBigQueryStorageSettingsBuilder
* .createReadSessionSettings()
* .setRetrySettings(
* baseBigQueryStorageSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* BigQueryStorageStubSettings baseBigQueryStorageSettings = baseBigQueryStorageSettingsBuilder.build();
* </code>
* </pre>
@@ -53,8 +53,12 @@
* <code>
* BaseBigQueryReadSettings.Builder baseBigQueryReadSettingsBuilder =
* BaseBigQueryReadSettings.newBuilder();
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* baseBigQueryReadSettingsBuilder
* .createReadSessionSettings()
* .setRetrySettings(
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* BaseBigQueryReadSettings baseBigQueryReadSettings = baseBigQueryReadSettingsBuilder.build();
* </code>
* </pre>
@@ -68,8 +68,12 @@
* <code>
* BigQueryReadStubSettings.Builder baseBigQueryReadSettingsBuilder =
* BigQueryReadStubSettings.newBuilder();
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* baseBigQueryReadSettingsBuilder
* .createReadSessionSettings()
* .setRetrySettings(
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* BigQueryReadStubSettings baseBigQueryReadSettings = baseBigQueryReadSettingsBuilder.build();
* </code>
* </pre>
@@ -163,4 +163,41 @@ public void readRowsExceptionTest() throws Exception {
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}

@Test
@SuppressWarnings("all")
public void splitReadStreamTest() {
SplitReadStreamResponse expectedResponse = SplitReadStreamResponse.newBuilder().build();
mockBigQueryRead.addResponse(expectedResponse);

SplitReadStreamRequest request = SplitReadStreamRequest.newBuilder().build();

SplitReadStreamResponse actualResponse = client.splitReadStream(request);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockBigQueryRead.getRequests();
Assert.assertEquals(1, actualRequests.size());
SplitReadStreamRequest actualRequest = (SplitReadStreamRequest) actualRequests.get(0);

Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

@Test
@SuppressWarnings("all")
public void splitReadStreamExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockBigQueryRead.addException(exception);

try {
SplitReadStreamRequest request = SplitReadStreamRequest.newBuilder().build();

client.splitReadStream(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
}
@@ -16,16 +16,26 @@
package com.google.cloud.bigquery.storage.v1alpha2;

import com.google.api.gax.core.NoCredentialsProvider;
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.grpc.testing.LocalChannelProvider;
import com.google.api.gax.grpc.testing.MockGrpcService;
import com.google.api.gax.grpc.testing.MockServiceHelper;
import com.google.api.gax.grpc.testing.MockStreamObserver;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ApiStreamObserver;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.InvalidArgumentException;
import com.google.api.gax.rpc.StatusCode;
import com.google.cloud.bigquery.storage.v1alpha2.Storage.AppendRowsRequest;
import com.google.cloud.bigquery.storage.v1alpha2.Storage.AppendRowsResponse;
import com.google.cloud.bigquery.storage.v1alpha2.Storage.BatchCommitWriteStreamsRequest;
import com.google.cloud.bigquery.storage.v1alpha2.Storage.BatchCommitWriteStreamsResponse;
import com.google.cloud.bigquery.storage.v1alpha2.Storage.CreateWriteStreamRequest;
import com.google.cloud.bigquery.storage.v1alpha2.Storage.FinalizeWriteStreamRequest;
import com.google.cloud.bigquery.storage.v1alpha2.Storage.FinalizeWriteStreamResponse;
import com.google.cloud.bigquery.storage.v1alpha2.Storage.GetWriteStreamRequest;
import com.google.cloud.bigquery.storage.v1alpha2.Stream.WriteStream;
import com.google.protobuf.AbstractMessage;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import java.io.IOException;
@@ -78,6 +88,46 @@ public void tearDown() throws Exception {
client.close();
}

@Test
@SuppressWarnings("all")
public void createWriteStreamTest() {
String name = "name3373707";
String externalId = "externalId-1153075697";
WriteStream expectedResponse =
WriteStream.newBuilder().setName(name).setExternalId(externalId).build();
mockBigQueryWrite.addResponse(expectedResponse);

CreateWriteStreamRequest request = CreateWriteStreamRequest.newBuilder().build();

WriteStream actualResponse = client.createWriteStream(request);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockBigQueryWrite.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateWriteStreamRequest actualRequest = (CreateWriteStreamRequest) actualRequests.get(0);

Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

@Test
@SuppressWarnings("all")
public void createWriteStreamExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockBigQueryWrite.addException(exception);

try {
CreateWriteStreamRequest request = CreateWriteStreamRequest.newBuilder().build();

client.createWriteStream(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}

@Test
@SuppressWarnings("all")
public void appendRowsTest() throws Exception {
@@ -126,4 +176,122 @@ public void appendRowsExceptionTest() throws Exception {
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}

@Test
@SuppressWarnings("all")
public void getWriteStreamTest() {
String name = "name3373707";
String externalId = "externalId-1153075697";
WriteStream expectedResponse =
WriteStream.newBuilder().setName(name).setExternalId(externalId).build();
mockBigQueryWrite.addResponse(expectedResponse);

GetWriteStreamRequest request = GetWriteStreamRequest.newBuilder().build();

WriteStream actualResponse = client.getWriteStream(request);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockBigQueryWrite.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetWriteStreamRequest actualRequest = (GetWriteStreamRequest) actualRequests.get(0);

Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

@Test
@SuppressWarnings("all")
public void getWriteStreamExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockBigQueryWrite.addException(exception);

try {
GetWriteStreamRequest request = GetWriteStreamRequest.newBuilder().build();

client.getWriteStream(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}

@Test
@SuppressWarnings("all")
public void finalizeWriteStreamTest() {
long rowCount = 1340416618L;
FinalizeWriteStreamResponse expectedResponse =
FinalizeWriteStreamResponse.newBuilder().setRowCount(rowCount).build();
mockBigQueryWrite.addResponse(expectedResponse);

FinalizeWriteStreamRequest request = FinalizeWriteStreamRequest.newBuilder().build();

FinalizeWriteStreamResponse actualResponse = client.finalizeWriteStream(request);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockBigQueryWrite.getRequests();
Assert.assertEquals(1, actualRequests.size());
FinalizeWriteStreamRequest actualRequest = (FinalizeWriteStreamRequest) actualRequests.get(0);

Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

@Test
@SuppressWarnings("all")
public void finalizeWriteStreamExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockBigQueryWrite.addException(exception);

try {
FinalizeWriteStreamRequest request = FinalizeWriteStreamRequest.newBuilder().build();

client.finalizeWriteStream(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}

@Test
@SuppressWarnings("all")
public void batchCommitWriteStreamsTest() {
BatchCommitWriteStreamsResponse expectedResponse =
BatchCommitWriteStreamsResponse.newBuilder().build();
mockBigQueryWrite.addResponse(expectedResponse);

BatchCommitWriteStreamsRequest request = BatchCommitWriteStreamsRequest.newBuilder().build();

BatchCommitWriteStreamsResponse actualResponse = client.batchCommitWriteStreams(request);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockBigQueryWrite.getRequests();
Assert.assertEquals(1, actualRequests.size());
BatchCommitWriteStreamsRequest actualRequest =
(BatchCommitWriteStreamsRequest) actualRequests.get(0);

Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

@Test
@SuppressWarnings("all")
public void batchCommitWriteStreamsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockBigQueryWrite.addException(exception);

try {
BatchCommitWriteStreamsRequest request = BatchCommitWriteStreamsRequest.newBuilder().build();

client.batchCommitWriteStreams(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
}

0 comments on commit 3631965

Please sign in to comment.