Skip to content

Commit 3631965

Browse files
feat: re-generated to pick up changes in the API or client library generator. (#70)
1 parent 2bbbb65 commit 3631965

File tree

12 files changed

+302
-27
lines changed

12 files changed

+302
-27
lines changed

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/BaseBigQueryReadSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@
5353
* <code>
5454
* BaseBigQueryReadSettings.Builder baseBigQueryReadSettingsBuilder =
5555
* BaseBigQueryReadSettings.newBuilder();
56-
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
57-
* .setTotalTimeout(Duration.ofSeconds(30));
56+
* baseBigQueryReadSettingsBuilder
57+
* .createReadSessionSettings()
58+
* .setRetrySettings(
59+
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
60+
* .setTotalTimeout(Duration.ofSeconds(30))
61+
* .build());
5862
* BaseBigQueryReadSettings baseBigQueryReadSettings = baseBigQueryReadSettingsBuilder.build();
5963
* </code>
6064
* </pre>

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/stub/BigQueryReadStubSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@
6868
* <code>
6969
* BigQueryReadStubSettings.Builder baseBigQueryReadSettingsBuilder =
7070
* BigQueryReadStubSettings.newBuilder();
71-
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
72-
* .setTotalTimeout(Duration.ofSeconds(30));
71+
* baseBigQueryReadSettingsBuilder
72+
* .createReadSessionSettings()
73+
* .setRetrySettings(
74+
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
75+
* .setTotalTimeout(Duration.ofSeconds(30))
76+
* .build());
7377
* BigQueryReadStubSettings baseBigQueryReadSettings = baseBigQueryReadSettingsBuilder.build();
7478
* </code>
7579
* </pre>

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1alpha2/BigQueryWriteSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@
6262
* <code>
6363
* BigQueryWriteSettings.Builder bigQueryWriteSettingsBuilder =
6464
* BigQueryWriteSettings.newBuilder();
65-
* bigQueryWriteSettingsBuilder.createWriteStreamSettings().getRetrySettings().toBuilder()
66-
* .setTotalTimeout(Duration.ofSeconds(30));
65+
* bigQueryWriteSettingsBuilder
66+
* .createWriteStreamSettings()
67+
* .setRetrySettings(
68+
* bigQueryWriteSettingsBuilder.createWriteStreamSettings().getRetrySettings().toBuilder()
69+
* .setTotalTimeout(Duration.ofSeconds(30))
70+
* .build());
6771
* BigQueryWriteSettings bigQueryWriteSettings = bigQueryWriteSettingsBuilder.build();
6872
* </code>
6973
* </pre>

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1alpha2/stub/BigQueryWriteStubSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@
7171
* <code>
7272
* BigQueryWriteStubSettings.Builder bigQueryWriteSettingsBuilder =
7373
* BigQueryWriteStubSettings.newBuilder();
74-
* bigQueryWriteSettingsBuilder.createWriteStreamSettings().getRetrySettings().toBuilder()
75-
* .setTotalTimeout(Duration.ofSeconds(30));
74+
* bigQueryWriteSettingsBuilder
75+
* .createWriteStreamSettings()
76+
* .setRetrySettings(
77+
* bigQueryWriteSettingsBuilder.createWriteStreamSettings().getRetrySettings().toBuilder()
78+
* .setTotalTimeout(Duration.ofSeconds(30))
79+
* .build());
7680
* BigQueryWriteStubSettings bigQueryWriteSettings = bigQueryWriteSettingsBuilder.build();
7781
* </code>
7882
* </pre>

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta1/BaseBigQueryStorageSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@
6363
* <code>
6464
* BaseBigQueryStorageSettings.Builder baseBigQueryStorageSettingsBuilder =
6565
* BaseBigQueryStorageSettings.newBuilder();
66-
* baseBigQueryStorageSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
67-
* .setTotalTimeout(Duration.ofSeconds(30));
66+
* baseBigQueryStorageSettingsBuilder
67+
* .createReadSessionSettings()
68+
* .setRetrySettings(
69+
* baseBigQueryStorageSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
70+
* .setTotalTimeout(Duration.ofSeconds(30))
71+
* .build());
6872
* BaseBigQueryStorageSettings baseBigQueryStorageSettings = baseBigQueryStorageSettingsBuilder.build();
6973
* </code>
7074
* </pre>

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta1/stub/BigQueryStorageStubSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@
7272
* <code>
7373
* BigQueryStorageStubSettings.Builder baseBigQueryStorageSettingsBuilder =
7474
* BigQueryStorageStubSettings.newBuilder();
75-
* baseBigQueryStorageSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
76-
* .setTotalTimeout(Duration.ofSeconds(30));
75+
* baseBigQueryStorageSettingsBuilder
76+
* .createReadSessionSettings()
77+
* .setRetrySettings(
78+
* baseBigQueryStorageSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
79+
* .setTotalTimeout(Duration.ofSeconds(30))
80+
* .build());
7781
* BigQueryStorageStubSettings baseBigQueryStorageSettings = baseBigQueryStorageSettingsBuilder.build();
7882
* </code>
7983
* </pre>

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta2/BaseBigQueryReadSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@
5353
* <code>
5454
* BaseBigQueryReadSettings.Builder baseBigQueryReadSettingsBuilder =
5555
* BaseBigQueryReadSettings.newBuilder();
56-
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
57-
* .setTotalTimeout(Duration.ofSeconds(30));
56+
* baseBigQueryReadSettingsBuilder
57+
* .createReadSessionSettings()
58+
* .setRetrySettings(
59+
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
60+
* .setTotalTimeout(Duration.ofSeconds(30))
61+
* .build());
5862
* BaseBigQueryReadSettings baseBigQueryReadSettings = baseBigQueryReadSettingsBuilder.build();
5963
* </code>
6064
* </pre>

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta2/stub/BigQueryReadStubSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@
6868
* <code>
6969
* BigQueryReadStubSettings.Builder baseBigQueryReadSettingsBuilder =
7070
* BigQueryReadStubSettings.newBuilder();
71-
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
72-
* .setTotalTimeout(Duration.ofSeconds(30));
71+
* baseBigQueryReadSettingsBuilder
72+
* .createReadSessionSettings()
73+
* .setRetrySettings(
74+
* baseBigQueryReadSettingsBuilder.createReadSessionSettings().getRetrySettings().toBuilder()
75+
* .setTotalTimeout(Duration.ofSeconds(30))
76+
* .build());
7377
* BigQueryReadStubSettings baseBigQueryReadSettings = baseBigQueryReadSettingsBuilder.build();
7478
* </code>
7579
* </pre>

google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/BaseBigQueryReadClientTest.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,41 @@ public void readRowsExceptionTest() throws Exception {
163163
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
164164
}
165165
}
166+
167+
@Test
168+
@SuppressWarnings("all")
169+
public void splitReadStreamTest() {
170+
SplitReadStreamResponse expectedResponse = SplitReadStreamResponse.newBuilder().build();
171+
mockBigQueryRead.addResponse(expectedResponse);
172+
173+
SplitReadStreamRequest request = SplitReadStreamRequest.newBuilder().build();
174+
175+
SplitReadStreamResponse actualResponse = client.splitReadStream(request);
176+
Assert.assertEquals(expectedResponse, actualResponse);
177+
178+
List<AbstractMessage> actualRequests = mockBigQueryRead.getRequests();
179+
Assert.assertEquals(1, actualRequests.size());
180+
SplitReadStreamRequest actualRequest = (SplitReadStreamRequest) actualRequests.get(0);
181+
182+
Assert.assertTrue(
183+
channelProvider.isHeaderSent(
184+
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
185+
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
186+
}
187+
188+
@Test
189+
@SuppressWarnings("all")
190+
public void splitReadStreamExceptionTest() throws Exception {
191+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
192+
mockBigQueryRead.addException(exception);
193+
194+
try {
195+
SplitReadStreamRequest request = SplitReadStreamRequest.newBuilder().build();
196+
197+
client.splitReadStream(request);
198+
Assert.fail("No exception raised");
199+
} catch (InvalidArgumentException e) {
200+
// Expected exception
201+
}
202+
}
166203
}

google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1alpha2/BigQueryWriteClientTest.java

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,26 @@
1616
package com.google.cloud.bigquery.storage.v1alpha2;
1717

1818
import com.google.api.gax.core.NoCredentialsProvider;
19+
import com.google.api.gax.grpc.GaxGrpcProperties;
1920
import com.google.api.gax.grpc.testing.LocalChannelProvider;
2021
import com.google.api.gax.grpc.testing.MockGrpcService;
2122
import com.google.api.gax.grpc.testing.MockServiceHelper;
2223
import com.google.api.gax.grpc.testing.MockStreamObserver;
24+
import com.google.api.gax.rpc.ApiClientHeaderProvider;
2325
import com.google.api.gax.rpc.ApiStreamObserver;
2426
import com.google.api.gax.rpc.BidiStreamingCallable;
2527
import com.google.api.gax.rpc.InvalidArgumentException;
2628
import com.google.api.gax.rpc.StatusCode;
2729
import com.google.cloud.bigquery.storage.v1alpha2.Storage.AppendRowsRequest;
2830
import com.google.cloud.bigquery.storage.v1alpha2.Storage.AppendRowsResponse;
31+
import com.google.cloud.bigquery.storage.v1alpha2.Storage.BatchCommitWriteStreamsRequest;
32+
import com.google.cloud.bigquery.storage.v1alpha2.Storage.BatchCommitWriteStreamsResponse;
33+
import com.google.cloud.bigquery.storage.v1alpha2.Storage.CreateWriteStreamRequest;
34+
import com.google.cloud.bigquery.storage.v1alpha2.Storage.FinalizeWriteStreamRequest;
35+
import com.google.cloud.bigquery.storage.v1alpha2.Storage.FinalizeWriteStreamResponse;
36+
import com.google.cloud.bigquery.storage.v1alpha2.Storage.GetWriteStreamRequest;
37+
import com.google.cloud.bigquery.storage.v1alpha2.Stream.WriteStream;
38+
import com.google.protobuf.AbstractMessage;
2939
import io.grpc.Status;
3040
import io.grpc.StatusRuntimeException;
3141
import java.io.IOException;
@@ -78,6 +88,46 @@ public void tearDown() throws Exception {
7888
client.close();
7989
}
8090

91+
@Test
92+
@SuppressWarnings("all")
93+
public void createWriteStreamTest() {
94+
String name = "name3373707";
95+
String externalId = "externalId-1153075697";
96+
WriteStream expectedResponse =
97+
WriteStream.newBuilder().setName(name).setExternalId(externalId).build();
98+
mockBigQueryWrite.addResponse(expectedResponse);
99+
100+
CreateWriteStreamRequest request = CreateWriteStreamRequest.newBuilder().build();
101+
102+
WriteStream actualResponse = client.createWriteStream(request);
103+
Assert.assertEquals(expectedResponse, actualResponse);
104+
105+
List<AbstractMessage> actualRequests = mockBigQueryWrite.getRequests();
106+
Assert.assertEquals(1, actualRequests.size());
107+
CreateWriteStreamRequest actualRequest = (CreateWriteStreamRequest) actualRequests.get(0);
108+
109+
Assert.assertTrue(
110+
channelProvider.isHeaderSent(
111+
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
112+
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
113+
}
114+
115+
@Test
116+
@SuppressWarnings("all")
117+
public void createWriteStreamExceptionTest() throws Exception {
118+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
119+
mockBigQueryWrite.addException(exception);
120+
121+
try {
122+
CreateWriteStreamRequest request = CreateWriteStreamRequest.newBuilder().build();
123+
124+
client.createWriteStream(request);
125+
Assert.fail("No exception raised");
126+
} catch (InvalidArgumentException e) {
127+
// Expected exception
128+
}
129+
}
130+
81131
@Test
82132
@SuppressWarnings("all")
83133
public void appendRowsTest() throws Exception {
@@ -126,4 +176,122 @@ public void appendRowsExceptionTest() throws Exception {
126176
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
127177
}
128178
}
179+
180+
@Test
181+
@SuppressWarnings("all")
182+
public void getWriteStreamTest() {
183+
String name = "name3373707";
184+
String externalId = "externalId-1153075697";
185+
WriteStream expectedResponse =
186+
WriteStream.newBuilder().setName(name).setExternalId(externalId).build();
187+
mockBigQueryWrite.addResponse(expectedResponse);
188+
189+
GetWriteStreamRequest request = GetWriteStreamRequest.newBuilder().build();
190+
191+
WriteStream actualResponse = client.getWriteStream(request);
192+
Assert.assertEquals(expectedResponse, actualResponse);
193+
194+
List<AbstractMessage> actualRequests = mockBigQueryWrite.getRequests();
195+
Assert.assertEquals(1, actualRequests.size());
196+
GetWriteStreamRequest actualRequest = (GetWriteStreamRequest) actualRequests.get(0);
197+
198+
Assert.assertTrue(
199+
channelProvider.isHeaderSent(
200+
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
201+
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
202+
}
203+
204+
@Test
205+
@SuppressWarnings("all")
206+
public void getWriteStreamExceptionTest() throws Exception {
207+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
208+
mockBigQueryWrite.addException(exception);
209+
210+
try {
211+
GetWriteStreamRequest request = GetWriteStreamRequest.newBuilder().build();
212+
213+
client.getWriteStream(request);
214+
Assert.fail("No exception raised");
215+
} catch (InvalidArgumentException e) {
216+
// Expected exception
217+
}
218+
}
219+
220+
@Test
221+
@SuppressWarnings("all")
222+
public void finalizeWriteStreamTest() {
223+
long rowCount = 1340416618L;
224+
FinalizeWriteStreamResponse expectedResponse =
225+
FinalizeWriteStreamResponse.newBuilder().setRowCount(rowCount).build();
226+
mockBigQueryWrite.addResponse(expectedResponse);
227+
228+
FinalizeWriteStreamRequest request = FinalizeWriteStreamRequest.newBuilder().build();
229+
230+
FinalizeWriteStreamResponse actualResponse = client.finalizeWriteStream(request);
231+
Assert.assertEquals(expectedResponse, actualResponse);
232+
233+
List<AbstractMessage> actualRequests = mockBigQueryWrite.getRequests();
234+
Assert.assertEquals(1, actualRequests.size());
235+
FinalizeWriteStreamRequest actualRequest = (FinalizeWriteStreamRequest) actualRequests.get(0);
236+
237+
Assert.assertTrue(
238+
channelProvider.isHeaderSent(
239+
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
240+
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
241+
}
242+
243+
@Test
244+
@SuppressWarnings("all")
245+
public void finalizeWriteStreamExceptionTest() throws Exception {
246+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
247+
mockBigQueryWrite.addException(exception);
248+
249+
try {
250+
FinalizeWriteStreamRequest request = FinalizeWriteStreamRequest.newBuilder().build();
251+
252+
client.finalizeWriteStream(request);
253+
Assert.fail("No exception raised");
254+
} catch (InvalidArgumentException e) {
255+
// Expected exception
256+
}
257+
}
258+
259+
@Test
260+
@SuppressWarnings("all")
261+
public void batchCommitWriteStreamsTest() {
262+
BatchCommitWriteStreamsResponse expectedResponse =
263+
BatchCommitWriteStreamsResponse.newBuilder().build();
264+
mockBigQueryWrite.addResponse(expectedResponse);
265+
266+
BatchCommitWriteStreamsRequest request = BatchCommitWriteStreamsRequest.newBuilder().build();
267+
268+
BatchCommitWriteStreamsResponse actualResponse = client.batchCommitWriteStreams(request);
269+
Assert.assertEquals(expectedResponse, actualResponse);
270+
271+
List<AbstractMessage> actualRequests = mockBigQueryWrite.getRequests();
272+
Assert.assertEquals(1, actualRequests.size());
273+
BatchCommitWriteStreamsRequest actualRequest =
274+
(BatchCommitWriteStreamsRequest) actualRequests.get(0);
275+
276+
Assert.assertTrue(
277+
channelProvider.isHeaderSent(
278+
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
279+
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
280+
}
281+
282+
@Test
283+
@SuppressWarnings("all")
284+
public void batchCommitWriteStreamsExceptionTest() throws Exception {
285+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
286+
mockBigQueryWrite.addException(exception);
287+
288+
try {
289+
BatchCommitWriteStreamsRequest request = BatchCommitWriteStreamsRequest.newBuilder().build();
290+
291+
client.batchCommitWriteStreams(request);
292+
Assert.fail("No exception raised");
293+
} catch (InvalidArgumentException e) {
294+
// Expected exception
295+
}
296+
}
129297
}

0 commit comments

Comments
 (0)