From a2f073b8f26001e7d305198411149fe153af37d7 Mon Sep 17 00:00:00 2001 From: PhongChuong Date: Tue, 23 Jul 2024 15:15:25 -0400 Subject: [PATCH] Fix lint issues --- .../cloud/bigquery/BigQueryImplTest.java | 33 +++++++++++-------- .../cloud/bigquery/it/ITBigQueryTest.java | 7 ++-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java index 6e544189c..88b8f6dbf 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java @@ -53,6 +53,7 @@ @RunWith(MockitoJUnitRunner.class) public class BigQueryImplTest { + private static final String PROJECT = "project"; private static final String LOCATION = "US"; private static final String OTHER_PROJECT = "otherProject"; @@ -1597,11 +1598,13 @@ public void testCreateJobFailureShouldRetry() { @Test public void testCreateJobWithBigQueryRetryConfigFailureShouldRetry() { // Validate create job with BigQueryRetryConfig that retries on rate limit error message. - JobOption bigQueryRetryConfigOption = JobOption.bigQueryRetryConfig(BigQueryRetryConfig.newBuilder() - .retryOnMessage(BigQueryErrorMessages.RATE_LIMIT_EXCEEDED_MSG) - .retryOnMessage(BigQueryErrorMessages.JOB_RATE_LIMIT_EXCEEDED_MSG) - .retryOnRegEx(BigQueryErrorMessages.RetryRegExPatterns.RATE_LIMIT_EXCEEDED_REGEX) - .build()); + JobOption bigQueryRetryConfigOption = + JobOption.bigQueryRetryConfig( + BigQueryRetryConfig.newBuilder() + .retryOnMessage(BigQueryErrorMessages.RATE_LIMIT_EXCEEDED_MSG) + .retryOnMessage(BigQueryErrorMessages.JOB_RATE_LIMIT_EXCEEDED_MSG) + .retryOnRegEx(BigQueryErrorMessages.RetryRegExPatterns.RATE_LIMIT_EXCEEDED_REGEX) + .build()); Map bigQueryRpcOptions = optionMap(bigQueryRetryConfigOption); when(bigqueryRpcMock.create(jobCapture.capture(), eq(bigQueryRpcOptions))) @@ -1619,21 +1622,20 @@ public void testCreateJobWithBigQueryRetryConfigFailureShouldRetry() { .build() .getService(); - ((BigQueryImpl) bigquery).create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), bigQueryRetryConfigOption); + ((BigQueryImpl) bigquery) + .create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), bigQueryRetryConfigOption); verify(bigqueryRpcMock, times(3)).create(jobCapture.capture(), eq(bigQueryRpcOptions)); } @Test public void testCreateJobWithBigQueryRetryConfigFailureShouldNotRetry() { // Validate create job with BigQueryRetryConfig that does not retry on rate limit error message. - JobOption bigQueryRetryConfigOption = JobOption.bigQueryRetryConfig(BigQueryRetryConfig.newBuilder() - .build()); + JobOption bigQueryRetryConfigOption = + JobOption.bigQueryRetryConfig(BigQueryRetryConfig.newBuilder().build()); Map bigQueryRpcOptions = optionMap(bigQueryRetryConfigOption); when(bigqueryRpcMock.create(jobCapture.capture(), eq(bigQueryRpcOptions))) - .thenThrow( - new BigQueryException( - 400, RATE_LIMIT_ERROR_MSG)); + .thenThrow(new BigQueryException(400, RATE_LIMIT_ERROR_MSG)); bigquery = options.getService(); bigquery = @@ -1644,7 +1646,8 @@ public void testCreateJobWithBigQueryRetryConfigFailureShouldNotRetry() { .getService(); try { - ((BigQueryImpl) bigquery).create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), bigQueryRetryConfigOption); + ((BigQueryImpl) bigquery) + .create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), bigQueryRetryConfigOption); fail("JobException expected"); } catch (BigQueryException e) { assertNotNull(e.getMessage()); @@ -1673,7 +1676,8 @@ public void testCreateJobWithRetryOptionsFailureShouldRetry() { .build() .getService(); - ((BigQueryImpl) bigquery).create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), retryOptions); + ((BigQueryImpl) bigquery) + .create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), retryOptions); verify(bigqueryRpcMock, times(4)).create(jobCapture.capture(), eq(bigQueryRpcOptions)); } @@ -1695,7 +1699,8 @@ public void testCreateJobWithRetryOptionsFailureShouldNotRetry() { .getService(); try { - ((BigQueryImpl) bigquery).create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), retryOptions); + ((BigQueryImpl) bigquery) + .create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), retryOptions); fail("JobException expected"); } catch (BigQueryException e) { assertNotNull(e.getMessage()); diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java index 40d405f61..9d1c23308 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java @@ -136,7 +136,6 @@ import com.google.cloud.bigquery.TimePartitioning.Type; import com.google.cloud.bigquery.ViewDefinition; import com.google.cloud.bigquery.WriteChannelConfiguration; -import com.google.cloud.bigquery.spi.v2.BigQueryRpc; import com.google.cloud.bigquery.testing.RemoteBigQueryHelper; import com.google.cloud.datacatalog.v1.CreatePolicyTagRequest; import com.google.cloud.datacatalog.v1.CreateTaxonomyRequest; @@ -5282,8 +5281,10 @@ public void testCreateAndGetJob() throws InterruptedException, TimeoutException } @Test - public void testCreateJobAndWaitForWithRetryOptions() throws InterruptedException, TimeoutException { - // Note: This only tests the non failure/retry case. For retry cases, see unit tests with mocked RPC calls. + public void testCreateJobAndWaitForWithRetryOptions() + throws InterruptedException, TimeoutException { + // Note: This only tests the non failure/retry case. For retry cases, see unit tests with mocked + // RPC calls. QueryJobConfiguration config = QueryJobConfiguration.newBuilder("SELECT CURRENT_TIMESTAMP() as ts") .setDefaultDataset(DATASET)