diff --git a/google-cloud-bigquery/pom.xml b/google-cloud-bigquery/pom.xml
index 5e86e77fd..174bb9cb3 100644
--- a/google-cloud-bigquery/pom.xml
+++ b/google-cloud-bigquery/pom.xml
@@ -162,8 +162,18 @@
test
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.mockito
+ mockito-junit-jupiter
test
@@ -207,6 +217,20 @@
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 3.5.2
+
+
+ org.apache.maven.surefire
+ surefire-junit-platform
+ ${surefire.version}
+
+
+
org.codehaus.mojo
diff --git a/google-cloud-bigquery/src/test/java/MetadataCacheStatsTest.java b/google-cloud-bigquery/src/test/java/MetadataCacheStatsTest.java
index d1cfa86e9..d417bfc7f 100644
--- a/google-cloud-bigquery/src/test/java/MetadataCacheStatsTest.java
+++ b/google-cloud-bigquery/src/test/java/MetadataCacheStatsTest.java
@@ -16,16 +16,16 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.api.services.bigquery.model.MetadataCacheStatistics;
import com.google.common.collect.ImmutableList;
import com.google.common.truth.Truth;
import java.util.List;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class MetadataCacheStatsTest {
+class MetadataCacheStatsTest {
private static List
TABLE_METADATA_CACHE_USAGE_PB_LIST =
ImmutableList.of(
@@ -44,7 +44,7 @@ public class MetadataCacheStatsTest {
new MetadataCacheStatistics().setTableMetadataCacheUsage(TABLE_METADATA_CACHE_USAGE_PB_LIST);
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
assertEquals(METADATA_CACHE_STATISTICS_PB, METADATA_CACHE_STATS.toPb());
compareMetadataCacheStats(
METADATA_CACHE_STATS, MetadataCacheStats.fromPb(METADATA_CACHE_STATISTICS_PB));
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AclTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AclTest.java
index 0b53f32ff..f7bed53ba 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AclTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AclTest.java
@@ -16,7 +16,7 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.api.services.bigquery.model.Dataset;
import com.google.cloud.bigquery.Acl.DatasetAclEntity;
@@ -31,12 +31,12 @@
import com.google.cloud.bigquery.Acl.View;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class AclTest {
+class AclTest {
@Test
- public void testDatasetEntity() {
+ void testDatasetEntity() {
DatasetId datasetId = DatasetId.of("dataset");
List targetTypes = ImmutableList.of("VIEWS");
DatasetAclEntity entity = new DatasetAclEntity(datasetId, targetTypes);
@@ -47,7 +47,7 @@ public void testDatasetEntity() {
}
@Test
- public void testDomainEntity() {
+ void testDomainEntity() {
Domain entity = new Domain("d1");
assertEquals("d1", entity.getDomain());
assertEquals(Type.DOMAIN, entity.getType());
@@ -56,7 +56,7 @@ public void testDomainEntity() {
}
@Test
- public void testGroupEntity() {
+ void testGroupEntity() {
Group entity = new Group("g1");
assertEquals("g1", entity.getIdentifier());
assertEquals(Type.GROUP, entity.getType());
@@ -65,7 +65,7 @@ public void testGroupEntity() {
}
@Test
- public void testSpecialGroupEntity() {
+ void testSpecialGroupEntity() {
Group entity = Group.ofAllAuthenticatedUsers();
assertEquals("allAuthenticatedUsers", entity.getIdentifier());
Dataset.Access pb = entity.toPb();
@@ -85,7 +85,7 @@ public void testSpecialGroupEntity() {
}
@Test
- public void testUserEntity() {
+ void testUserEntity() {
User entity = new User("u1");
assertEquals("u1", entity.getEmail());
assertEquals(Type.USER, entity.getType());
@@ -94,7 +94,7 @@ public void testUserEntity() {
}
@Test
- public void testViewEntity() {
+ void testViewEntity() {
TableId viewId = TableId.of("project", "dataset", "view");
View entity = new View(viewId);
assertEquals(viewId, entity.getId());
@@ -104,7 +104,7 @@ public void testViewEntity() {
}
@Test
- public void testRoutineEntity() {
+ void testRoutineEntity() {
RoutineId routineId = RoutineId.of("project", "dataset", "routine");
Acl.Routine entity = new Acl.Routine(routineId);
assertEquals(routineId, entity.getId());
@@ -114,7 +114,7 @@ public void testRoutineEntity() {
}
@Test
- public void testIamMemberEntity() {
+ void testIamMemberEntity() {
IamMember entity = new IamMember("member1");
assertEquals("member1", entity.getIamMember());
Dataset.Access pb = entity.toPb();
@@ -122,7 +122,7 @@ public void testIamMemberEntity() {
}
@Test
- public void testOf() {
+ void testOf() {
Acl acl = Acl.of(Group.ofAllAuthenticatedUsers(), Role.READER);
assertEquals(Group.ofAllAuthenticatedUsers(), acl.getEntity());
assertEquals(Role.READER, acl.getRole());
@@ -139,7 +139,7 @@ public void testOf() {
}
@Test
- public void testOfWithCondition() {
+ void testOfWithCondition() {
Expr expr = new Expr("expression", "title", "description", "location");
Acl acl = Acl.of(Group.ofAllAuthenticatedUsers(), Role.READER, expr);
Dataset.Access pb = acl.toPb();
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AnnotationsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AnnotationsTest.java
index aa3dd9fde..ad475c7dc 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AnnotationsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AnnotationsTest.java
@@ -17,17 +17,17 @@
package com.google.cloud.bigquery;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.api.client.util.Data;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class AnnotationsTest {
@Test
- public void testFromUser() {
+ void testFromUser() {
assertThat(Annotations.fromUser(null).userMap()).isNull();
HashMap user = new HashMap<>();
@@ -43,7 +43,7 @@ public void testFromUser() {
}
@Test
- public void testFromToPb() {
+ void testFromToPb() {
assertThat(Annotations.fromPb(null).toPb()).isNull();
HashMap pb = new HashMap<>();
@@ -60,17 +60,13 @@ public void testFromToPb() {
}
@Test
- public void testNullKey() {
- try {
- Annotations.fromUser(Collections.singletonMap((String) null, "foo"));
- fail("null key shouldn't work");
- } catch (IllegalArgumentException e) {
- }
+ void testNullKey() {
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Annotations.fromUser(Collections.singletonMap((String) null, "foo")));
- try {
- Annotations.fromPb(Collections.singletonMap((String) null, "foo"));
- fail("null key shouldn't work");
- } catch (IllegalArgumentException e) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Annotations.fromPb(Collections.singletonMap((String) null, "foo")));
}
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AvroOptionsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AvroOptionsTest.java
index f40660fd7..840ae24ba 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AvroOptionsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/AvroOptionsTest.java
@@ -16,9 +16,9 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class AvroOptionsTest {
@@ -27,7 +27,7 @@ public class AvroOptionsTest {
AvroOptions.newBuilder().setUseAvroLogicalTypes(USE_AVRO_LOGICAL_TYPES).build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareAvroOptions(AVRO_OPTIONS, AVRO_OPTIONS.toBuilder().build());
AvroOptions avroOptions = AVRO_OPTIONS.toBuilder().setUseAvroLogicalTypes(false).build();
assertEquals(false, avroOptions.useAvroLogicalTypes());
@@ -36,13 +36,13 @@ public void testToBuilder() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(FormatOptions.AVRO, AVRO_OPTIONS.getType());
assertEquals(USE_AVRO_LOGICAL_TYPES, AVRO_OPTIONS.useAvroLogicalTypes());
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareAvroOptions(AVRO_OPTIONS, AvroOptions.fromPb(AVRO_OPTIONS.toPb()));
AvroOptions avroOptions =
AvroOptions.newBuilder().setUseAvroLogicalTypes(USE_AVRO_LOGICAL_TYPES).build();
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigLakeConfigurationTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigLakeConfigurationTest.java
index afb2b5b10..66fcd7c6b 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigLakeConfigurationTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigLakeConfigurationTest.java
@@ -16,11 +16,11 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class BigLakeConfigurationTest {
+class BigLakeConfigurationTest {
private static final String STORAGE_URI = "gs://storage-uri";
private static final String FILE_FORMAT = "PARQUET";
@@ -43,7 +43,7 @@ public class BigLakeConfigurationTest {
.setConnectionId(CONNECTION_ID);
@Test
- public void testToBuilder() {
+ void testToBuilder() {
assertEquals(STORAGE_URI, BIG_LAKE_CONFIGURATION.getStorageUri());
assertEquals(FILE_FORMAT, BIG_LAKE_CONFIGURATION.getFileFormat());
assertEquals(TABLE_FORMAT, BIG_LAKE_CONFIGURATION.getTableFormat());
@@ -51,12 +51,12 @@ public void testToBuilder() {
}
@Test
- public void testToPb() {
+ void testToPb() {
assertBigLakeConfiguration(BIG_LAKE_CONFIGURATION_PB, BIG_LAKE_CONFIGURATION.toPb());
}
@Test
- public void testFromPb() {
+ void testFromPb() {
assertBigLakeConfiguration(
BIG_LAKE_CONFIGURATION, BigLakeConfiguration.fromPb(BIG_LAKE_CONFIGURATION_PB));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryErrorTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryErrorTest.java
index 7cd737cf4..d618214e2 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryErrorTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryErrorTest.java
@@ -16,9 +16,9 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class BigQueryErrorTest {
@@ -32,7 +32,7 @@ public class BigQueryErrorTest {
new BigQueryError(REASON, LOCATION, MESSAGE);
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(REASON, ERROR.getReason());
assertEquals(LOCATION, ERROR.getLocation());
assertEquals(DEBUG_INFO, ERROR.getDebugInfo());
@@ -44,7 +44,7 @@ public void testConstructor() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareBigQueryError(ERROR, BigQueryError.fromPb(ERROR.toPb()));
compareBigQueryError(ERROR_INCOMPLETE, BigQueryError.fromPb(ERROR_INCOMPLETE.toPb()));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryExceptionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryExceptionTest.java
index 8a2094b55..7254ede1b 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryExceptionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryExceptionTest.java
@@ -16,11 +16,11 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -40,15 +40,15 @@
import java.net.SocketTimeoutException;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class BigQueryExceptionTest {
@Test
- public void testBigQueryException() {
+ void testBigQueryException() {
BigQueryException exception = new BigQueryException(500, "message");
assertEquals(500, exception.getCode());
assertEquals("message", exception.getMessage());
@@ -137,7 +137,7 @@ public void testBigQueryException() {
}
@Test
- public void testTranslateAndThrow() throws Exception {
+ void testTranslateAndThrow() throws Exception {
Exception cause = new BigQueryException(503, "message");
RetryHelperException exceptionMock = mock(RetryHelperException.class);
when(exceptionMock.getCause()).thenReturn(cause);
@@ -168,7 +168,7 @@ public void testTranslateAndThrow() throws Exception {
}
@Test
- public void testDefaultExceptionHandler() throws java.io.IOException {
+ void testDefaultExceptionHandler() throws java.io.IOException {
BigQueryOptions defaultOptions =
BigQueryOptions.newBuilder().setProjectId("project-id").build();
DatasetInfo info = DatasetInfo.newBuilder("dataset").build();
@@ -198,7 +198,7 @@ public void testDefaultExceptionHandler() throws java.io.IOException {
}
@Test
- public void testCustomExceptionHandler() throws java.io.IOException {
+ void testCustomExceptionHandler() throws java.io.IOException {
BigQueryOptions defaultOptions =
BigQueryOptions.newBuilder()
.setProjectId("project-id")
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 393455e36..20a6ef679 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
@@ -20,12 +20,33 @@
import static com.google.cloud.bigquery.BigQuery.JobField.USER_EMAIL;
import static com.google.cloud.bigquery.BigQueryImpl.optionMap;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import com.google.api.gax.paging.Page;
-import com.google.api.services.bigquery.model.*;
+import com.google.api.services.bigquery.model.ErrorProto;
+import com.google.api.services.bigquery.model.GetQueryResultsResponse;
+import com.google.api.services.bigquery.model.JobConfigurationQuery;
import com.google.api.services.bigquery.model.JobStatistics;
+import com.google.api.services.bigquery.model.QueryRequest;
+import com.google.api.services.bigquery.model.TableCell;
+import com.google.api.services.bigquery.model.TableDataInsertAllRequest;
+import com.google.api.services.bigquery.model.TableDataInsertAllResponse;
+import com.google.api.services.bigquery.model.TableDataList;
+import com.google.api.services.bigquery.model.TableRow;
import com.google.cloud.Policy;
import com.google.cloud.RetryOption;
import com.google.cloud.ServiceOptions;
@@ -39,7 +60,11 @@
import com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
-import com.google.common.collect.*;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import java.io.IOException;
import java.math.BigInteger;
import java.net.ConnectException;
@@ -47,16 +72,18 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
public class BigQueryImplTest {
private static final String PROJECT = "project";
@@ -537,8 +564,8 @@ private BigQueryOptions createBigQueryOptionsForProjectWithLocation(
.build();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
rpcFactoryMock = mock(BigQueryRpcFactory.class);
bigqueryRpcMock = mock(HttpBigQueryRpc.class);
when(rpcFactoryMock.create(any(BigQueryOptions.class))).thenReturn(bigqueryRpcMock);
@@ -546,13 +573,13 @@ public void setUp() {
}
@Test
- public void testGetOptions() {
+ void testGetOptions() {
bigquery = options.getService();
assertSame(options, bigquery.getOptions());
}
@Test
- public void testCreateDataset() throws IOException {
+ void testCreateDataset() throws IOException {
DatasetInfo datasetInfo = DATASET_INFO.setProjectId(OTHER_PROJECT);
when(bigqueryRpcMock.createSkipExceptionTranslation(datasetInfo.toPb(), EMPTY_RPC_OPTIONS))
.thenReturn(datasetInfo.toPb());
@@ -565,7 +592,7 @@ public void testCreateDataset() throws IOException {
}
@Test
- public void testCreateDatasetWithSelectedFields() throws IOException {
+ void testCreateDatasetWithSelectedFields() throws IOException {
when(bigqueryRpcMock.createSkipExceptionTranslation(
eq(DATASET_INFO_WITH_PROJECT.toPb()), capturedOptions.capture()))
.thenReturn(DATASET_INFO_WITH_PROJECT.toPb());
@@ -584,7 +611,7 @@ public void testCreateDatasetWithSelectedFields() throws IOException {
}
@Test
- public void testCreateDatasetWithAccessPolicy() throws IOException {
+ void testCreateDatasetWithAccessPolicy() throws IOException {
DatasetInfo datasetInfo = DATASET_INFO.setProjectId(OTHER_PROJECT);
DatasetOption datasetOption = DatasetOption.accessPolicyVersion(3);
when(bigqueryRpcMock.createSkipExceptionTranslation(
@@ -600,7 +627,7 @@ public void testCreateDatasetWithAccessPolicy() throws IOException {
}
@Test
- public void testGetDataset() throws IOException {
+ void testGetDataset() throws IOException {
when(bigqueryRpcMock.getDatasetSkipExceptionTranslation(PROJECT, DATASET, EMPTY_RPC_OPTIONS))
.thenReturn(DATASET_INFO_WITH_PROJECT.toPb());
bigquery = options.getService();
@@ -611,7 +638,7 @@ public void testGetDataset() throws IOException {
}
@Test
- public void testGetDatasetNotFoundWhenThrowIsDisabled() throws IOException {
+ void testGetDatasetNotFoundWhenThrowIsDisabled() throws IOException {
when(bigqueryRpcMock.getDatasetSkipExceptionTranslation(PROJECT, DATASET, EMPTY_RPC_OPTIONS))
.thenReturn(DATASET_INFO_WITH_PROJECT.toPb());
options.setThrowNotFound(false);
@@ -623,24 +650,22 @@ public void testGetDatasetNotFoundWhenThrowIsDisabled() throws IOException {
}
@Test
- public void testGetDatasetNotFoundWhenThrowIsEnabled() throws IOException {
+ void testGetDatasetNotFoundWhenThrowIsEnabled() throws IOException {
when(bigqueryRpcMock.getDatasetSkipExceptionTranslation(
PROJECT, "dataset-not-found", EMPTY_RPC_OPTIONS))
.thenThrow(new BigQueryException(404, "Dataset not found"));
options.setThrowNotFound(true);
bigquery = options.getService();
- try {
- bigquery.getDataset("dataset-not-found");
- Assert.fail();
- } catch (BigQueryException ex) {
- Assert.assertNotNull(ex.getMessage());
- }
+ BigQueryException ex =
+ Assertions.assertThrows(
+ BigQueryException.class, () -> bigquery.getDataset("dataset-not-found"));
+ Assertions.assertNotNull(ex.getMessage());
verify(bigqueryRpcMock)
.getDatasetSkipExceptionTranslation(PROJECT, "dataset-not-found", EMPTY_RPC_OPTIONS);
}
@Test
- public void testGetDatasetFromDatasetId() throws IOException {
+ void testGetDatasetFromDatasetId() throws IOException {
when(bigqueryRpcMock.getDatasetSkipExceptionTranslation(PROJECT, DATASET, EMPTY_RPC_OPTIONS))
.thenReturn(DATASET_INFO_WITH_PROJECT.toPb());
bigquery = options.getService();
@@ -651,7 +676,7 @@ public void testGetDatasetFromDatasetId() throws IOException {
}
@Test
- public void testGetDatasetFromDatasetIdWithProject() throws IOException {
+ void testGetDatasetFromDatasetIdWithProject() throws IOException {
DatasetInfo datasetInfo = DATASET_INFO.setProjectId(OTHER_PROJECT);
DatasetId datasetId = DatasetId.of(OTHER_PROJECT, DATASET);
when(bigqueryRpcMock.getDatasetSkipExceptionTranslation(
@@ -665,7 +690,7 @@ public void testGetDatasetFromDatasetIdWithProject() throws IOException {
}
@Test
- public void testGetDatasetWithSelectedFields() throws IOException {
+ void testGetDatasetWithSelectedFields() throws IOException {
when(bigqueryRpcMock.getDatasetSkipExceptionTranslation(
eq(PROJECT), eq(DATASET), capturedOptions.capture()))
.thenReturn(DATASET_INFO_WITH_PROJECT.toPb());
@@ -683,7 +708,7 @@ public void testGetDatasetWithSelectedFields() throws IOException {
}
@Test
- public void testListDatasets() throws IOException {
+ void testListDatasets() throws IOException {
bigquery = options.getService();
ImmutableList datasetList =
ImmutableList.of(
@@ -701,7 +726,7 @@ public void testListDatasets() throws IOException {
}
@Test
- public void testListDatasetsWithProjects() throws IOException {
+ void testListDatasetsWithProjects() throws IOException {
bigquery = options.getService();
ImmutableList datasetList =
ImmutableList.of(
@@ -719,7 +744,7 @@ public void testListDatasetsWithProjects() throws IOException {
}
@Test
- public void testListEmptyDatasets() throws IOException {
+ void testListEmptyDatasets() throws IOException {
ImmutableList datasets = ImmutableList.of();
Tuple> result =
Tuple.>of(null, datasets);
@@ -734,7 +759,7 @@ public void testListEmptyDatasets() throws IOException {
}
@Test
- public void testListDatasetsWithOptions() throws IOException {
+ void testListDatasetsWithOptions() throws IOException {
bigquery = options.getService();
ImmutableList datasetList =
ImmutableList.of(
@@ -753,7 +778,7 @@ public void testListDatasetsWithOptions() throws IOException {
}
@Test
- public void testDeleteDataset() throws IOException {
+ void testDeleteDataset() throws IOException {
when(bigqueryRpcMock.deleteDatasetSkipExceptionTranslation(PROJECT, DATASET, EMPTY_RPC_OPTIONS))
.thenReturn(true);
bigquery = options.getService();
@@ -763,7 +788,7 @@ public void testDeleteDataset() throws IOException {
}
@Test
- public void testDeleteDatasetFromDatasetId() throws IOException {
+ void testDeleteDatasetFromDatasetId() throws IOException {
when(bigqueryRpcMock.deleteDatasetSkipExceptionTranslation(PROJECT, DATASET, EMPTY_RPC_OPTIONS))
.thenReturn(true);
bigquery = options.getService();
@@ -773,7 +798,7 @@ public void testDeleteDatasetFromDatasetId() throws IOException {
}
@Test
- public void testDeleteDatasetFromDatasetIdWithProject() throws IOException {
+ void testDeleteDatasetFromDatasetIdWithProject() throws IOException {
DatasetId datasetId = DatasetId.of(OTHER_PROJECT, DATASET);
when(bigqueryRpcMock.deleteDatasetSkipExceptionTranslation(
OTHER_PROJECT, DATASET, EMPTY_RPC_OPTIONS))
@@ -785,7 +810,7 @@ public void testDeleteDatasetFromDatasetIdWithProject() throws IOException {
}
@Test
- public void testDeleteDatasetWithOptions() throws IOException {
+ void testDeleteDatasetWithOptions() throws IOException {
when(bigqueryRpcMock.deleteDatasetSkipExceptionTranslation(
PROJECT, DATASET, DATASET_DELETE_OPTIONS))
.thenReturn(true);
@@ -796,7 +821,7 @@ public void testDeleteDatasetWithOptions() throws IOException {
}
@Test
- public void testUpdateDataset() throws IOException {
+ void testUpdateDataset() throws IOException {
DatasetInfo updatedDatasetInfo =
DATASET_INFO.setProjectId(OTHER_PROJECT).toBuilder()
.setDescription("newDescription")
@@ -812,7 +837,7 @@ public void testUpdateDataset() throws IOException {
}
@Test
- public void testUpdateDatasetWithSelectedFields() throws IOException {
+ void testUpdateDatasetWithSelectedFields() throws IOException {
DatasetInfo updatedDatasetInfo =
DATASET_INFO.toBuilder().setDescription("newDescription").build();
DatasetInfo updatedDatasetInfoWithProject =
@@ -835,7 +860,7 @@ public void testUpdateDatasetWithSelectedFields() throws IOException {
}
@Test
- public void testCreateTable() throws IOException {
+ void testCreateTable() throws IOException {
TableInfo tableInfo = TABLE_INFO.setProjectId(OTHER_PROJECT);
when(bigqueryRpcMock.createSkipExceptionTranslation(tableInfo.toPb(), EMPTY_RPC_OPTIONS))
.thenReturn(tableInfo.toPb());
@@ -848,7 +873,7 @@ public void testCreateTable() throws IOException {
}
@Test
- public void tesCreateExternalTable() throws IOException {
+ void tesCreateExternalTable() throws IOException {
TableInfo createTableInfo =
TableInfo.of(TABLE_ID, ExternalTableDefinition.newBuilder().setSchema(TABLE_SCHEMA).build())
.setProjectId(OTHER_PROJECT);
@@ -867,7 +892,7 @@ public void tesCreateExternalTable() throws IOException {
}
@Test
- public void testCreateTableWithoutProject() throws IOException {
+ void testCreateTableWithoutProject() throws IOException {
TableInfo tableInfo = TABLE_INFO.setProjectId(PROJECT);
TableId tableId = TableId.of("", TABLE_ID.getDataset(), TABLE_ID.getTable());
tableInfo.toBuilder().setTableId(tableId);
@@ -881,7 +906,7 @@ public void testCreateTableWithoutProject() throws IOException {
}
@Test
- public void testCreateTableWithSelectedFields() throws IOException {
+ void testCreateTableWithSelectedFields() throws IOException {
when(bigqueryRpcMock.createSkipExceptionTranslation(
eq(TABLE_INFO_WITH_PROJECT.toPb()), capturedOptions.capture()))
.thenReturn(TABLE_INFO_WITH_PROJECT.toPb());
@@ -899,7 +924,7 @@ public void testCreateTableWithSelectedFields() throws IOException {
}
@Test
- public void testGetTable() throws IOException {
+ void testGetTable() throws IOException {
when(bigqueryRpcMock.getTableSkipExceptionTranslation(
PROJECT, DATASET, TABLE, EMPTY_RPC_OPTIONS))
.thenReturn(TABLE_INFO_WITH_PROJECT.toPb());
@@ -911,7 +936,7 @@ public void testGetTable() throws IOException {
}
@Test
- public void testGetModel() throws IOException {
+ void testGetModel() throws IOException {
when(bigqueryRpcMock.getModelSkipExceptionTranslation(
PROJECT, DATASET, MODEL, EMPTY_RPC_OPTIONS))
.thenReturn(MODEL_INFO_WITH_PROJECT.toPb());
@@ -923,7 +948,7 @@ public void testGetModel() throws IOException {
}
@Test
- public void testGetModelNotFoundWhenThrowIsEnabled() throws IOException {
+ void testGetModelNotFoundWhenThrowIsEnabled() throws IOException {
String expected = "Model not found";
when(bigqueryRpcMock.getModelSkipExceptionTranslation(
PROJECT, DATASET, MODEL, EMPTY_RPC_OPTIONS))
@@ -940,7 +965,7 @@ public void testGetModelNotFoundWhenThrowIsEnabled() throws IOException {
}
@Test
- public void testListPartition() throws IOException {
+ void testListPartition() throws IOException {
when(bigqueryRpcMock.getTableSkipExceptionTranslation(
PROJECT, DATASET, "table$__PARTITIONS_SUMMARY__", EMPTY_RPC_OPTIONS))
.thenReturn(TABLE_INFO_PARTITIONS.toPb());
@@ -958,7 +983,7 @@ public void testListPartition() throws IOException {
}
@Test
- public void testGetTableNotFoundWhenThrowIsDisabled() throws IOException {
+ void testGetTableNotFoundWhenThrowIsDisabled() throws IOException {
when(bigqueryRpcMock.getTableSkipExceptionTranslation(
PROJECT, DATASET, TABLE, EMPTY_RPC_OPTIONS))
.thenReturn(TABLE_INFO_WITH_PROJECT.toPb());
@@ -971,7 +996,7 @@ public void testGetTableNotFoundWhenThrowIsDisabled() throws IOException {
}
@Test
- public void testGetTableNotFoundWhenThrowIsEnabled() throws IOException {
+ void testGetTableNotFoundWhenThrowIsEnabled() throws IOException {
when(bigqueryRpcMock.getTableSkipExceptionTranslation(
PROJECT, DATASET, "table-not-found", EMPTY_RPC_OPTIONS))
.thenThrow(new BigQueryException(404, "Table not found"));
@@ -979,16 +1004,16 @@ public void testGetTableNotFoundWhenThrowIsEnabled() throws IOException {
bigquery = options.getService();
try {
bigquery.getTable(DATASET, "table-not-found");
- Assert.fail();
+ Assertions.fail();
} catch (BigQueryException ex) {
- Assert.assertNotNull(ex.getMessage());
+ Assertions.assertNotNull(ex.getMessage());
}
verify(bigqueryRpcMock)
.getTableSkipExceptionTranslation(PROJECT, DATASET, "table-not-found", EMPTY_RPC_OPTIONS);
}
@Test
- public void testGetTableFromTableId() throws IOException {
+ void testGetTableFromTableId() throws IOException {
when(bigqueryRpcMock.getTableSkipExceptionTranslation(
PROJECT, DATASET, TABLE, EMPTY_RPC_OPTIONS))
.thenReturn(TABLE_INFO_WITH_PROJECT.toPb());
@@ -1000,7 +1025,7 @@ public void testGetTableFromTableId() throws IOException {
}
@Test
- public void testGetTableFromTableIdWithProject() throws IOException {
+ void testGetTableFromTableIdWithProject() throws IOException {
TableInfo tableInfo = TABLE_INFO.setProjectId(OTHER_PROJECT);
TableId tableId = TABLE_ID.setProjectId(OTHER_PROJECT);
when(bigqueryRpcMock.getTableSkipExceptionTranslation(
@@ -1016,7 +1041,7 @@ public void testGetTableFromTableIdWithProject() throws IOException {
}
@Test
- public void testGetTableFromTableIdWithoutProject() throws IOException {
+ void testGetTableFromTableIdWithoutProject() throws IOException {
TableInfo tableInfo = TABLE_INFO.setProjectId(PROJECT);
TableId tableId = TableId.of("", TABLE_ID.getDataset(), TABLE_ID.getTable());
when(bigqueryRpcMock.getTableSkipExceptionTranslation(
@@ -1031,7 +1056,7 @@ public void testGetTableFromTableIdWithoutProject() throws IOException {
}
@Test
- public void testGetTableWithSelectedFields() throws IOException {
+ void testGetTableWithSelectedFields() throws IOException {
when(bigqueryRpcMock.getTableSkipExceptionTranslation(
eq(PROJECT), eq(DATASET), eq(TABLE), capturedOptions.capture()))
.thenReturn(TABLE_INFO_WITH_PROJECT.toPb());
@@ -1049,7 +1074,7 @@ public void testGetTableWithSelectedFields() throws IOException {
}
@Test
- public void testListTables() throws IOException {
+ void testListTables() throws IOException {
bigquery = options.getService();
ImmutableList tableList =
ImmutableList.of(
@@ -1067,7 +1092,7 @@ public void testListTables() throws IOException {
}
@Test
- public void testListTablesReturnedParameters() throws IOException {
+ void testListTablesReturnedParameters() throws IOException {
bigquery = options.getService();
ImmutableList tableList =
ImmutableList.of(
@@ -1084,7 +1109,7 @@ public void testListTablesReturnedParameters() throws IOException {
}
@Test
- public void testListTablesReturnedParametersNullType() throws IOException {
+ void testListTablesReturnedParametersNullType() throws IOException {
bigquery = options.getService();
ImmutableList tableList =
ImmutableList.of(
@@ -1101,7 +1126,7 @@ public void testListTablesReturnedParametersNullType() throws IOException {
}
@Test
- public void testListTablesWithRangePartitioning() throws IOException {
+ void testListTablesWithRangePartitioning() throws IOException {
bigquery = options.getService();
ImmutableList tableList =
ImmutableList.of(
@@ -1118,7 +1143,7 @@ public void testListTablesWithRangePartitioning() throws IOException {
}
@Test
- public void testListTablesFromDatasetId() throws IOException {
+ void testListTablesFromDatasetId() throws IOException {
bigquery = options.getService();
ImmutableList tableList =
ImmutableList.of(
@@ -1135,7 +1160,7 @@ public void testListTablesFromDatasetId() throws IOException {
}
@Test
- public void testListTablesFromDatasetIdWithProject() throws IOException {
+ void testListTablesFromDatasetIdWithProject() throws IOException {
bigquery = options.getService();
ImmutableList tableList =
ImmutableList.of(
@@ -1153,7 +1178,7 @@ public void testListTablesFromDatasetIdWithProject() throws IOException {
}
@Test
- public void testListTablesWithLabels() throws IOException {
+ void testListTablesWithLabels() throws IOException {
bigquery = options.getService();
ImmutableList tableList =
ImmutableList.of(
@@ -1170,7 +1195,7 @@ public void testListTablesWithLabels() throws IOException {
}
@Test
- public void testListTablesWithOptions() throws IOException {
+ void testListTablesWithOptions() throws IOException {
bigquery = options.getService();
ImmutableList tableList =
ImmutableList.of(
@@ -1188,7 +1213,7 @@ public void testListTablesWithOptions() throws IOException {
}
@Test
- public void testListModels() throws IOException {
+ void testListModels() throws IOException {
bigquery = options.getService();
ImmutableList modelList =
ImmutableList.of(
@@ -1205,7 +1230,7 @@ public void testListModels() throws IOException {
}
@Test
- public void testListModelsWithModelId() throws IOException {
+ void testListModelsWithModelId() throws IOException {
bigquery = options.getService();
ImmutableList modelList =
ImmutableList.of(
@@ -1222,7 +1247,7 @@ public void testListModelsWithModelId() throws IOException {
}
@Test
- public void testDeleteTable() throws IOException {
+ void testDeleteTable() throws IOException {
when(bigqueryRpcMock.deleteTableSkipExceptionTranslation(PROJECT, DATASET, TABLE))
.thenReturn(true);
bigquery = options.getService();
@@ -1231,7 +1256,7 @@ public void testDeleteTable() throws IOException {
}
@Test
- public void testDeleteTableFromTableId() throws IOException {
+ void testDeleteTableFromTableId() throws IOException {
when(bigqueryRpcMock.deleteTableSkipExceptionTranslation(PROJECT, DATASET, TABLE))
.thenReturn(true);
bigquery = options.getService();
@@ -1240,7 +1265,7 @@ public void testDeleteTableFromTableId() throws IOException {
}
@Test
- public void testDeleteTableFromTableIdWithProject() throws IOException {
+ void testDeleteTableFromTableIdWithProject() throws IOException {
TableId tableId = TABLE_ID.setProjectId(OTHER_PROJECT);
when(bigqueryRpcMock.deleteTableSkipExceptionTranslation(OTHER_PROJECT, DATASET, TABLE))
.thenReturn(true);
@@ -1252,7 +1277,7 @@ public void testDeleteTableFromTableIdWithProject() throws IOException {
}
@Test
- public void testDeleteTableFromTableIdWithoutProject() throws IOException {
+ void testDeleteTableFromTableIdWithoutProject() throws IOException {
TableId tableId = TableId.of("", TABLE_ID.getDataset(), TABLE_ID.getTable());
when(bigqueryRpcMock.deleteTableSkipExceptionTranslation(PROJECT, DATASET, TABLE))
.thenReturn(true);
@@ -1263,7 +1288,7 @@ public void testDeleteTableFromTableIdWithoutProject() throws IOException {
}
@Test
- public void testDeleteModel() throws IOException {
+ void testDeleteModel() throws IOException {
when(bigqueryRpcMock.deleteModelSkipExceptionTranslation(PROJECT, DATASET, MODEL))
.thenReturn(true);
bigquery = options.getService();
@@ -1272,7 +1297,7 @@ public void testDeleteModel() throws IOException {
}
@Test
- public void testUpdateModel() throws IOException {
+ void testUpdateModel() throws IOException {
ModelInfo updateModelInfo =
MODEL_INFO_WITH_PROJECT.setProjectId(OTHER_PROJECT).toBuilder()
.setDescription("newDescription")
@@ -1289,7 +1314,7 @@ public void testUpdateModel() throws IOException {
}
@Test
- public void testUpdateTable() throws IOException {
+ void testUpdateTable() throws IOException {
TableInfo updatedTableInfo =
TABLE_INFO.setProjectId(OTHER_PROJECT).toBuilder().setDescription("newDescription").build();
when(bigqueryRpcMock.patchSkipExceptionTranslation(updatedTableInfo.toPb(), EMPTY_RPC_OPTIONS))
@@ -1304,7 +1329,7 @@ public void testUpdateTable() throws IOException {
}
@Test
- public void testUpdateExternalTableWithNewSchema() throws IOException {
+ void testUpdateExternalTableWithNewSchema() throws IOException {
TableInfo updatedTableInfo =
TableInfo.of(TABLE_ID, ExternalTableDefinition.newBuilder().setSchema(TABLE_SCHEMA).build())
.setProjectId(OTHER_PROJECT);
@@ -1323,7 +1348,7 @@ public void testUpdateExternalTableWithNewSchema() throws IOException {
}
@Test
- public void testUpdateTableWithoutProject() throws IOException {
+ void testUpdateTableWithoutProject() throws IOException {
TableInfo tableInfo = TABLE_INFO.setProjectId(PROJECT);
TableId tableId = TableId.of("", TABLE_ID.getDataset(), TABLE_ID.getTable());
tableInfo.toBuilder().setTableId(tableId);
@@ -1337,7 +1362,7 @@ public void testUpdateTableWithoutProject() throws IOException {
}
@Test
- public void testUpdateTableWithSelectedFields() throws IOException {
+ void testUpdateTableWithSelectedFields() throws IOException {
TableInfo updatedTableInfo = TABLE_INFO.toBuilder().setDescription("newDescription").build();
TableInfo updatedTableInfoWithProject =
TABLE_INFO_WITH_PROJECT.toBuilder().setDescription("newDescription").build();
@@ -1359,7 +1384,7 @@ public void testUpdateTableWithSelectedFields() throws IOException {
}
@Test
- public void testUpdateTableWithAutoDetectSchema() throws IOException {
+ void testUpdateTableWithAutoDetectSchema() throws IOException {
TableInfo updatedTableInfo = TABLE_INFO.toBuilder().setDescription("newDescription").build();
TableInfo updatedTableInfoWithProject =
TABLE_INFO_WITH_PROJECT.toBuilder().setDescription("newDescription").build();
@@ -1379,7 +1404,7 @@ public void testUpdateTableWithAutoDetectSchema() throws IOException {
}
@Test
- public void testInsertAllWithRowIdShouldRetry() throws IOException {
+ void testInsertAllWithRowIdShouldRetry() throws IOException {
Map row1 = ImmutableMap.of("field", "value1");
Map row2 = ImmutableMap.of("field", "value2");
List rows =
@@ -1432,7 +1457,7 @@ public TableDataInsertAllRequest.Rows apply(RowToInsert rowToInsert) {
}
@Test
- public void testInsertAllWithoutRowIdShouldNotRetry() {
+ void testInsertAllWithoutRowIdShouldNotRetry() {
Map row1 = ImmutableMap.of("field", "value1");
Map row2 = ImmutableMap.of("field", "value2");
List rows = ImmutableList.of(RowToInsert.of(row1), RowToInsert.of(row2));
@@ -1468,15 +1493,15 @@ public TableDataInsertAllRequest.Rows apply(RowToInsert rowToInsert) {
.getService();
try {
bigquery.insertAll(request);
- Assert.fail();
+ Assertions.fail();
} catch (BigQueryException ex) {
- Assert.assertNotNull(ex.getMessage());
+ Assertions.assertNotNull(ex.getMessage());
}
verify(bigqueryRpcMock).insertAll(PROJECT, DATASET, TABLE, requestPb);
}
@Test
- public void testInsertAllWithProject() throws IOException {
+ void testInsertAllWithProject() throws IOException {
Map row1 = ImmutableMap.of("field", "value1");
Map row2 = ImmutableMap.of("field", "value2");
List rows =
@@ -1528,7 +1553,7 @@ public TableDataInsertAllRequest.Rows apply(RowToInsert rowToInsert) {
}
@Test
- public void testInsertAllWithProjectInTable() throws IOException {
+ void testInsertAllWithProjectInTable() throws IOException {
Map row1 = ImmutableMap.of("field", "value1");
Map row2 = ImmutableMap.of("field", "value2");
List rows =
@@ -1581,7 +1606,7 @@ public TableDataInsertAllRequest.Rows apply(RowToInsert rowToInsert) {
}
@Test
- public void testListTableData() throws IOException {
+ void testListTableData() throws IOException {
when(bigqueryRpcMock.listTableDataSkipExceptionTranslation(
PROJECT, DATASET, TABLE, EMPTY_RPC_OPTIONS))
.thenReturn(TABLE_DATA_PB);
@@ -1594,7 +1619,7 @@ public void testListTableData() throws IOException {
}
@Test
- public void testListTableDataFromTableId() throws IOException {
+ void testListTableDataFromTableId() throws IOException {
when(bigqueryRpcMock.listTableDataSkipExceptionTranslation(
PROJECT, DATASET, TABLE, EMPTY_RPC_OPTIONS))
.thenReturn(TABLE_DATA_PB);
@@ -1607,7 +1632,7 @@ public void testListTableDataFromTableId() throws IOException {
}
@Test
- public void testListTableDataFromTableIdWithProject() throws IOException {
+ void testListTableDataFromTableIdWithProject() throws IOException {
TableId tableId = TABLE_ID.setProjectId(OTHER_PROJECT);
when(bigqueryRpcMock.listTableDataSkipExceptionTranslation(
OTHER_PROJECT, DATASET, TABLE, EMPTY_RPC_OPTIONS))
@@ -1622,7 +1647,7 @@ public void testListTableDataFromTableIdWithProject() throws IOException {
}
@Test
- public void testListTableDataWithOptions() throws IOException {
+ void testListTableDataWithOptions() throws IOException {
when(bigqueryRpcMock.listTableDataSkipExceptionTranslation(
PROJECT, DATASET, TABLE, TABLE_DATA_LIST_OPTIONS))
.thenReturn(TABLE_DATA_PB);
@@ -1641,7 +1666,7 @@ public void testListTableDataWithOptions() throws IOException {
}
@Test
- public void testListTableDataWithNextPage() throws IOException {
+ void testListTableDataWithNextPage() throws IOException {
doReturn(TABLE_DATA_PB)
.when(bigqueryRpcMock)
.listTableDataSkipExceptionTranslation(PROJECT, DATASET, TABLE, TABLE_DATA_LIST_OPTIONS);
@@ -1687,7 +1712,7 @@ private static com.google.api.services.bigquery.model.Job newJobPb() {
}
@Test
- public void testCreateJobSuccess() throws IOException {
+ void testCreateJobSuccess() throws IOException {
String id = "testCreateJobSuccess-id";
JobId jobId = JobId.of(id);
String query = "SELECT * in FOO";
@@ -1704,7 +1729,7 @@ public void testCreateJobSuccess() throws IOException {
}
@Test
- public void testCreateJobFailureShouldRetryExceptionHandlerExceptions() throws IOException {
+ void testCreateJobFailureShouldRetryExceptionHandlerExceptions() throws IOException {
when(bigqueryRpcMock.createSkipExceptionTranslation(
jobCapture.capture(), eq(EMPTY_RPC_OPTIONS)))
.thenThrow(new UnknownHostException())
@@ -1724,7 +1749,7 @@ public void testCreateJobFailureShouldRetryExceptionHandlerExceptions() throws I
}
@Test
- public void testCreateJobFailureShouldRetry() throws IOException {
+ void testCreateJobFailureShouldRetry() throws IOException {
when(bigqueryRpcMock.createSkipExceptionTranslation(
jobCapture.capture(), eq(EMPTY_RPC_OPTIONS)))
.thenThrow(new BigQueryException(500, "InternalError"))
@@ -1749,7 +1774,7 @@ public void testCreateJobFailureShouldRetry() throws IOException {
}
@Test
- public void testCreateJobWithBigQueryRetryConfigFailureShouldRetry() throws IOException {
+ void testCreateJobWithBigQueryRetryConfigFailureShouldRetry() throws IOException {
// Validate create job with BigQueryRetryConfig that retries on rate limit error message.
JobOption bigQueryRetryConfigOption =
JobOption.bigQueryRetryConfig(
@@ -1782,7 +1807,7 @@ public void testCreateJobWithBigQueryRetryConfigFailureShouldRetry() throws IOEx
}
@Test
- public void testCreateJobWithBigQueryRetryConfigFailureShouldNotRetry() throws IOException {
+ void testCreateJobWithBigQueryRetryConfigFailureShouldNotRetry() throws IOException {
// Validate create job with BigQueryRetryConfig that does not retry on rate limit error message.
JobOption bigQueryRetryConfigOption =
JobOption.bigQueryRetryConfig(BigQueryRetryConfig.newBuilder().build());
@@ -1795,7 +1820,7 @@ public void testCreateJobWithBigQueryRetryConfigFailureShouldNotRetry() throws I
// Job create will attempt to retrieve the job even in the case when the job is created in a
// returned failure.
when(bigqueryRpcMock.getJobSkipExceptionTranslation(
- nullable(String.class), nullable(String.class), nullable(String.class), Mockito.any()))
+ nullable(String.class), nullable(String.class), nullable(String.class), any()))
.thenThrow(new BigQueryException(500, "InternalError"));
bigquery = options.getService();
@@ -1805,13 +1830,15 @@ public void testCreateJobWithBigQueryRetryConfigFailureShouldNotRetry() throws I
.build()
.getService();
- try {
- ((BigQueryImpl) bigquery)
- .create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), bigQueryRetryConfigOption);
- fail("JobException expected");
- } catch (BigQueryException e) {
- assertNotNull(e.getMessage());
- }
+ BigQueryException e =
+ Assertions.assertThrows(
+ BigQueryException.class,
+ () ->
+ ((BigQueryImpl) bigquery)
+ .create(
+ JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY),
+ bigQueryRetryConfigOption));
+ assertNotNull(e.getMessage());
// Verify that getQueryResults is attempted only once and not retried since the error message
// does not match.
verify(bigqueryRpcMock, times(1))
@@ -1819,7 +1846,7 @@ public void testCreateJobWithBigQueryRetryConfigFailureShouldNotRetry() throws I
}
@Test
- public void testCreateJobWithRetryOptionsFailureShouldRetry() throws IOException {
+ void testCreateJobWithRetryOptionsFailureShouldRetry() throws IOException {
// Validate create job with RetryOptions.
JobOption retryOptions = JobOption.retryOptions(RetryOption.maxAttempts(4));
Map bigQueryRpcOptions = optionMap(retryOptions);
@@ -1844,7 +1871,7 @@ public void testCreateJobWithRetryOptionsFailureShouldRetry() throws IOException
}
@Test
- public void testCreateJobWithRetryOptionsFailureShouldNotRetry() throws IOException {
+ void testCreateJobWithRetryOptionsFailureShouldNotRetry() throws IOException {
// Validate create job with RetryOptions that only attempts once (no retry).
JobOption retryOptions = JobOption.retryOptions(RetryOption.maxAttempts(1));
Map bigQueryRpcOptions = optionMap(retryOptions);
@@ -1856,7 +1883,7 @@ public void testCreateJobWithRetryOptionsFailureShouldNotRetry() throws IOExcept
// Job create will attempt to retrieve the job even in the case when the job is created in a
// returned failure.
when(bigqueryRpcMock.getJobSkipExceptionTranslation(
- nullable(String.class), nullable(String.class), nullable(String.class), Mockito.any()))
+ nullable(String.class), nullable(String.class), nullable(String.class), any()))
.thenThrow(new BigQueryException(500, "InternalError"));
bigquery = options.getService();
@@ -1866,19 +1893,19 @@ public void testCreateJobWithRetryOptionsFailureShouldNotRetry() throws IOExcept
.build()
.getService();
- try {
- ((BigQueryImpl) bigquery)
- .create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), retryOptions);
- fail("JobException expected");
- } catch (BigQueryException e) {
- assertNotNull(e.getMessage());
- }
+ BigQueryException e =
+ Assertions.assertThrows(
+ BigQueryException.class,
+ () ->
+ ((BigQueryImpl) bigquery)
+ .create(JobInfo.of(QUERY_JOB_CONFIGURATION_FOR_DMLQUERY), retryOptions));
+ assertNotNull(e.getMessage());
verify(bigqueryRpcMock, times(1))
.createSkipExceptionTranslation(jobCapture.capture(), eq(bigQueryRpcOptions));
}
@Test
- public void testCreateJobWithSelectedFields() throws IOException {
+ void testCreateJobWithSelectedFields() throws IOException {
when(bigqueryRpcMock.createSkipExceptionTranslation(
any(com.google.api.services.bigquery.model.Job.class), capturedOptions.capture()))
.thenReturn(newJobPb());
@@ -1899,7 +1926,7 @@ public void testCreateJobWithSelectedFields() throws IOException {
}
@Test
- public void testCreateJobNoGet() throws IOException {
+ void testCreateJobNoGet() throws IOException {
String id = "testCreateJobNoGet-id";
JobId jobId = JobId.of(id);
String query = "SELECT * in FOO";
@@ -1909,18 +1936,17 @@ public void testCreateJobNoGet() throws IOException {
.thenThrow(new BigQueryException(409, "already exists, for some reason"));
bigquery = options.getService();
- try {
- bigquery.create(JobInfo.of(jobId, QueryJobConfiguration.of(query)));
- fail("should throw");
- } catch (BigQueryException e) {
- assertThat(jobCapture.getValue().getJobReference().getJobId()).isEqualTo(id);
- }
+ BigQueryException e =
+ Assertions.assertThrows(
+ BigQueryException.class,
+ () -> bigquery.create(JobInfo.of(jobId, QueryJobConfiguration.of(query))));
+ assertThat(jobCapture.getValue().getJobReference().getJobId()).isEqualTo(id);
verify(bigqueryRpcMock)
.createSkipExceptionTranslation(jobCapture.capture(), eq(EMPTY_RPC_OPTIONS));
}
@Test
- public void testCreateJobTryGet() throws IOException {
+ void testCreateJobTryGet() throws IOException {
final String id = "testCreateJobTryGet-id";
String query = "SELECT * in FOO";
Supplier idProvider =
@@ -1949,7 +1975,7 @@ public JobId get() {
}
@Test
- public void testCreateJobTryGetNotRandom() throws IOException {
+ void testCreateJobTryGetNotRandom() throws IOException {
Map withStatisticOption = optionMap(JobOption.fields(STATISTICS));
final String id = "testCreateJobTryGet-id";
String query = "SELECT * in FOO";
@@ -1981,7 +2007,7 @@ public void testCreateJobTryGetNotRandom() throws IOException {
}
@Test
- public void testCreateJobWithProjectId() throws IOException {
+ void testCreateJobWithProjectId() throws IOException {
JobInfo jobInfo =
JobInfo.newBuilder(QUERY_JOB_CONFIGURATION.setProjectId(OTHER_PROJECT))
.setJobId(JobId.of(OTHER_PROJECT, JOB))
@@ -2004,7 +2030,7 @@ public void testCreateJobWithProjectId() throws IOException {
}
@Test
- public void testDeleteJob() throws IOException {
+ void testDeleteJob() throws IOException {
JobId jobId = JobId.newBuilder().setJob(JOB).setProject(PROJECT).setLocation(LOCATION).build();
when(bigqueryRpcMock.deleteJobSkipExceptionTranslation(PROJECT, JOB, LOCATION))
.thenReturn(true);
@@ -2014,7 +2040,7 @@ public void testDeleteJob() throws IOException {
}
@Test
- public void testGetJob() throws IOException {
+ void testGetJob() throws IOException {
when(bigqueryRpcMock.getJobSkipExceptionTranslation(PROJECT, JOB, null, EMPTY_RPC_OPTIONS))
.thenReturn(COMPLETE_COPY_JOB.toPb());
bigquery = options.getService();
@@ -2024,7 +2050,7 @@ public void testGetJob() throws IOException {
}
@Test
- public void testGetJobWithLocation() throws IOException {
+ void testGetJobWithLocation() throws IOException {
when(bigqueryRpcMock.getJobSkipExceptionTranslation(PROJECT, JOB, LOCATION, EMPTY_RPC_OPTIONS))
.thenReturn(COMPLETE_COPY_JOB.toPb());
BigQueryOptions options = createBigQueryOptionsForProjectWithLocation(PROJECT, rpcFactoryMock);
@@ -2036,7 +2062,7 @@ public void testGetJobWithLocation() throws IOException {
}
@Test
- public void testGetJobNotFoundWhenThrowIsDisabled() throws IOException {
+ void testGetJobNotFoundWhenThrowIsDisabled() throws IOException {
when(bigqueryRpcMock.getJobSkipExceptionTranslation(PROJECT, JOB, null, EMPTY_RPC_OPTIONS))
.thenReturn(COMPLETE_COPY_JOB.toPb());
options.setThrowNotFound(false);
@@ -2047,24 +2073,21 @@ public void testGetJobNotFoundWhenThrowIsDisabled() throws IOException {
}
@Test
- public void testGetJobNotFoundWhenThrowIsEnabled() throws IOException {
+ void testGetJobNotFoundWhenThrowIsEnabled() throws IOException {
when(bigqueryRpcMock.getJobSkipExceptionTranslation(
PROJECT, "job-not-found", null, EMPTY_RPC_OPTIONS))
.thenThrow(new IOException("Job not found"));
options.setThrowNotFound(true);
bigquery = options.getService();
- try {
- bigquery.getJob("job-not-found");
- Assert.fail();
- } catch (BigQueryException ex) {
- Assert.assertNotNull(ex.getMessage());
- }
+ BigQueryException ex =
+ Assertions.assertThrows(BigQueryException.class, () -> bigquery.getJob("job-not-found"));
+ Assertions.assertNotNull(ex.getMessage());
verify(bigqueryRpcMock)
.getJobSkipExceptionTranslation(PROJECT, "job-not-found", null, EMPTY_RPC_OPTIONS);
}
@Test
- public void testGetJobFromJobId() throws IOException {
+ void testGetJobFromJobId() throws IOException {
when(bigqueryRpcMock.getJobSkipExceptionTranslation(PROJECT, JOB, null, EMPTY_RPC_OPTIONS))
.thenReturn(COMPLETE_COPY_JOB.toPb());
bigquery = options.getService();
@@ -2074,7 +2097,7 @@ public void testGetJobFromJobId() throws IOException {
}
@Test
- public void testGetJobFromJobIdWithLocation() throws IOException {
+ void testGetJobFromJobIdWithLocation() throws IOException {
when(bigqueryRpcMock.getJobSkipExceptionTranslation(PROJECT, JOB, LOCATION, EMPTY_RPC_OPTIONS))
.thenReturn(COMPLETE_COPY_JOB.toPb());
BigQueryOptions options = createBigQueryOptionsForProjectWithLocation(PROJECT, rpcFactoryMock);
@@ -2086,7 +2109,7 @@ public void testGetJobFromJobIdWithLocation() throws IOException {
}
@Test
- public void testGetJobFromJobIdWithProject() throws IOException {
+ void testGetJobFromJobIdWithProject() throws IOException {
JobId jobId = JobId.of(OTHER_PROJECT, JOB);
JobInfo jobInfo = COPY_JOB.setProjectId(OTHER_PROJECT);
when(bigqueryRpcMock.getJobSkipExceptionTranslation(
@@ -2100,7 +2123,7 @@ public void testGetJobFromJobIdWithProject() throws IOException {
}
@Test
- public void testGetJobFromJobIdWithProjectWithLocation() throws IOException {
+ void testGetJobFromJobIdWithProjectWithLocation() throws IOException {
JobId jobId = JobId.of(OTHER_PROJECT, JOB);
JobInfo jobInfo = COPY_JOB.setProjectId(OTHER_PROJECT);
when(bigqueryRpcMock.getJobSkipExceptionTranslation(
@@ -2115,7 +2138,7 @@ public void testGetJobFromJobIdWithProjectWithLocation() throws IOException {
}
@Test
- public void testListJobs() throws IOException {
+ void testListJobs() throws IOException {
bigquery = options.getService();
ImmutableList jobList =
ImmutableList.of(
@@ -2141,7 +2164,7 @@ public com.google.api.services.bigquery.model.Job apply(Job job) {
}
@Test
- public void testListJobsWithOptions() throws IOException {
+ void testListJobsWithOptions() throws IOException {
bigquery = options.getService();
ImmutableList jobList =
ImmutableList.of(
@@ -2169,7 +2192,7 @@ public com.google.api.services.bigquery.model.Job apply(Job job) {
}
@Test
- public void testListJobsWithSelectedFields() throws IOException {
+ void testListJobsWithSelectedFields() throws IOException {
bigquery = options.getService();
ImmutableList jobList =
ImmutableList.of(
@@ -2205,7 +2228,7 @@ public com.google.api.services.bigquery.model.Job apply(Job job) {
}
@Test
- public void testCancelJob() throws IOException {
+ void testCancelJob() throws IOException {
when(bigqueryRpcMock.cancelSkipExceptionTranslation(PROJECT, JOB, null)).thenReturn(true);
bigquery = options.getService();
assertTrue(bigquery.cancel(JOB));
@@ -2213,7 +2236,7 @@ public void testCancelJob() throws IOException {
}
@Test
- public void testCancelJobFromJobId() throws IOException {
+ void testCancelJobFromJobId() throws IOException {
when(bigqueryRpcMock.cancelSkipExceptionTranslation(PROJECT, JOB, null)).thenReturn(true);
bigquery = options.getService();
assertTrue(bigquery.cancel(JobId.of(PROJECT, JOB)));
@@ -2221,7 +2244,7 @@ public void testCancelJobFromJobId() throws IOException {
}
@Test
- public void testCancelJobFromJobIdWithProject() throws IOException {
+ void testCancelJobFromJobIdWithProject() throws IOException {
JobId jobId = JobId.of(OTHER_PROJECT, JOB);
when(bigqueryRpcMock.cancelSkipExceptionTranslation(OTHER_PROJECT, JOB, null)).thenReturn(true);
bigquery = options.getService();
@@ -2230,7 +2253,7 @@ public void testCancelJobFromJobIdWithProject() throws IOException {
}
@Test
- public void testQueryRequestCompleted() throws InterruptedException, IOException {
+ void testQueryRequestCompleted() throws InterruptedException, IOException {
JobId queryJob = JobId.of(PROJECT, JOB);
com.google.api.services.bigquery.model.Job jobResponsePb =
new com.google.api.services.bigquery.model.Job()
@@ -2285,7 +2308,7 @@ PROJECT, JOB, null, optionMap(Job.DEFAULT_QUERY_WAIT_OPTIONS)))
}
@Test
- public void testFastQueryRequestCompleted() throws InterruptedException, IOException {
+ void testFastQueryRequestCompleted() throws InterruptedException, IOException {
com.google.api.services.bigquery.model.QueryResponse queryResponsePb =
new com.google.api.services.bigquery.model.QueryResponse()
.setCacheHit(false)
@@ -2325,7 +2348,7 @@ public void testFastQueryRequestCompleted() throws InterruptedException, IOExcep
}
@Test
- public void testFastQueryRequestCompletedWithLocation() throws InterruptedException, IOException {
+ void testFastQueryRequestCompletedWithLocation() throws InterruptedException, IOException {
com.google.api.services.bigquery.model.QueryResponse queryResponsePb =
new com.google.api.services.bigquery.model.QueryResponse()
.setCacheHit(false)
@@ -2366,7 +2389,7 @@ public void testFastQueryRequestCompletedWithLocation() throws InterruptedExcept
}
@Test
- public void testFastQueryMultiplePages() throws InterruptedException, IOException {
+ void testFastQueryMultiplePages() throws InterruptedException, IOException {
JobId queryJob = JobId.of(PROJECT, JOB);
com.google.api.services.bigquery.model.Job responseJob =
new com.google.api.services.bigquery.model.Job()
@@ -2422,7 +2445,7 @@ PROJECT, DATASET, TABLE, optionMap(BigQuery.TableDataListOption.pageToken(CURSOR
}
@Test
- public void testFastQuerySlowDdl() throws InterruptedException, IOException {
+ void testFastQuerySlowDdl() throws InterruptedException, IOException {
// mock new fast query path response when running a query that takes more than 10s
JobId queryJob = JobId.of(PROJECT, JOB);
com.google.api.services.bigquery.model.QueryResponse queryResponsePb =
@@ -2488,7 +2511,7 @@ PROJECT, JOB, null, optionMap(Job.DEFAULT_QUERY_WAIT_OPTIONS)))
}
@Test
- public void testQueryRequestCompletedOptions() throws InterruptedException, IOException {
+ void testQueryRequestCompletedOptions() throws InterruptedException, IOException {
JobId queryJob = JobId.of(PROJECT, JOB);
com.google.api.services.bigquery.model.Job jobResponsePb =
new com.google.api.services.bigquery.model.Job()
@@ -2546,7 +2569,7 @@ PROJECT, JOB, null, optionMap(Job.DEFAULT_QUERY_WAIT_OPTIONS)))
}
@Test
- public void testQueryRequestCompletedOnSecondAttempt() throws InterruptedException, IOException {
+ void testQueryRequestCompletedOnSecondAttempt() throws InterruptedException, IOException {
JobId queryJob = JobId.of(PROJECT, JOB);
com.google.api.services.bigquery.model.Job jobResponsePb1 =
new com.google.api.services.bigquery.model.Job()
@@ -2611,7 +2634,7 @@ PROJECT, JOB, null, optionMap(Job.DEFAULT_QUERY_WAIT_OPTIONS)))
}
@Test
- public void testQueryWithTimeoutSetsTimeout() throws InterruptedException, IOException {
+ void testQueryWithTimeoutSetsTimeout() throws InterruptedException, IOException {
com.google.api.services.bigquery.model.QueryResponse queryResponsePb =
new com.google.api.services.bigquery.model.QueryResponse()
.setCacheHit(false)
@@ -2634,7 +2657,7 @@ public void testQueryWithTimeoutSetsTimeout() throws InterruptedException, IOExc
}
@Test
- public void testGetQueryResults() throws IOException {
+ void testGetQueryResults() throws IOException {
JobId queryJob = JobId.of(JOB);
GetQueryResultsResponse responsePb =
new GetQueryResultsResponse()
@@ -2658,7 +2681,7 @@ public void testGetQueryResults() throws IOException {
}
@Test
- public void testGetQueryResultsRetry() throws IOException {
+ void testGetQueryResultsRetry() throws IOException {
JobId queryJob = JobId.of(JOB);
GetQueryResultsResponse responsePb =
new GetQueryResultsResponse()
@@ -2702,7 +2725,7 @@ public void testGetQueryResultsRetry() throws IOException {
}
@Test
- public void testGetQueryResultsWithProject() throws IOException {
+ void testGetQueryResultsWithProject() throws IOException {
JobId queryJob = JobId.of(OTHER_PROJECT, JOB);
GetQueryResultsResponse responsePb =
new GetQueryResultsResponse()
@@ -2726,7 +2749,7 @@ public void testGetQueryResultsWithProject() throws IOException {
}
@Test
- public void testGetQueryResultsWithOptions() throws IOException {
+ void testGetQueryResultsWithOptions() throws IOException {
JobId queryJob = JobId.of(PROJECT, JOB);
GetQueryResultsResponse responsePb =
new GetQueryResultsResponse()
@@ -2755,7 +2778,7 @@ public void testGetQueryResultsWithOptions() throws IOException {
}
@Test
- public void testGetDatasetRetryableException() throws IOException {
+ void testGetDatasetRetryableException() throws IOException {
when(bigqueryRpcMock.getDatasetSkipExceptionTranslation(PROJECT, DATASET, EMPTY_RPC_OPTIONS))
.thenThrow(new BigQueryException(500, "InternalError"))
.thenReturn(DATASET_INFO_WITH_PROJECT.toPb());
@@ -2772,7 +2795,7 @@ public void testGetDatasetRetryableException() throws IOException {
}
@Test
- public void testNonRetryableException() throws IOException {
+ void testNonRetryableException() throws IOException {
String exceptionMessage = "Not Implemented";
when(bigqueryRpcMock.getDatasetSkipExceptionTranslation(PROJECT, DATASET, EMPTY_RPC_OPTIONS))
.thenThrow(new BigQueryException(501, exceptionMessage));
@@ -2781,17 +2804,15 @@ public void testNonRetryableException() throws IOException {
.setRetrySettings(ServiceOptions.getDefaultRetrySettings())
.build()
.getService();
- try {
- bigquery.getDataset(DatasetId.of(DATASET));
- Assert.fail();
- } catch (BigQueryException ex) {
- Assert.assertEquals(exceptionMessage, ex.getMessage());
- }
+ BigQueryException ex =
+ Assertions.assertThrows(
+ BigQueryException.class, () -> bigquery.getDataset(DatasetId.of(DATASET)));
+ assertEquals(exceptionMessage, ex.getMessage());
verify(bigqueryRpcMock).getDatasetSkipExceptionTranslation(PROJECT, DATASET, EMPTY_RPC_OPTIONS);
}
@Test
- public void testRuntimeException() throws IOException {
+ void testRuntimeException() throws IOException {
String exceptionMessage = "Artificial runtime exception";
when(bigqueryRpcMock.getDatasetSkipExceptionTranslation(PROJECT, DATASET, EMPTY_RPC_OPTIONS))
.thenThrow(new RuntimeException(exceptionMessage));
@@ -2800,32 +2821,29 @@ public void testRuntimeException() throws IOException {
.setRetrySettings(ServiceOptions.getDefaultRetrySettings())
.build()
.getService();
- try {
- bigquery.getDataset(DATASET);
- Assert.fail();
- } catch (BigQueryException ex) {
- Assert.assertTrue(ex.getMessage().endsWith(exceptionMessage));
- }
+ BigQueryException ex =
+ Assertions.assertThrows(BigQueryException.class, () -> bigquery.getDataset(DATASET));
+ assertTrue(ex.getMessage().endsWith(exceptionMessage));
verify(bigqueryRpcMock).getDatasetSkipExceptionTranslation(PROJECT, DATASET, EMPTY_RPC_OPTIONS);
}
@Test
- public void testQueryDryRun() throws Exception {
+ void testQueryDryRun() throws Exception {
// https://github.com/googleapis/google-cloud-java/issues/2479
- try {
- options.toBuilder()
- .setRetrySettings(ServiceOptions.getDefaultRetrySettings())
- .build()
- .getService()
- .query(QueryJobConfiguration.newBuilder("foo").setDryRun(true).build());
- Assert.fail();
- } catch (UnsupportedOperationException ex) {
- Assert.assertNotNull(ex.getMessage());
- }
+ UnsupportedOperationException ex =
+ Assertions.assertThrows(
+ UnsupportedOperationException.class,
+ () ->
+ options.toBuilder()
+ .setRetrySettings(ServiceOptions.getDefaultRetrySettings())
+ .build()
+ .getService()
+ .query(QueryJobConfiguration.newBuilder("foo").setDryRun(true).build()));
+ Assertions.assertNotNull(ex.getMessage());
}
@Test
- public void testFastQuerySQLShouldRetry() throws Exception {
+ void testFastQuerySQLShouldRetry() throws Exception {
com.google.api.services.bigquery.model.QueryResponse responsePb =
new com.google.api.services.bigquery.model.QueryResponse()
.setCacheHit(false)
@@ -2866,7 +2884,7 @@ public void testFastQuerySQLShouldRetry() throws Exception {
}
@Test
- public void testFastQueryDMLShouldRetry() throws Exception {
+ void testFastQueryDMLShouldRetry() throws Exception {
com.google.api.services.bigquery.model.QueryResponse responsePb =
new com.google.api.services.bigquery.model.QueryResponse()
.setCacheHit(false)
@@ -2907,7 +2925,7 @@ public void testFastQueryDMLShouldRetry() throws Exception {
}
@Test
- public void testFastQueryRateLimitIdempotency() throws Exception {
+ void testFastQueryRateLimitIdempotency() throws Exception {
com.google.api.services.bigquery.model.QueryResponse responsePb =
new com.google.api.services.bigquery.model.QueryResponse()
.setCacheHit(false)
@@ -2955,7 +2973,7 @@ public void testFastQueryRateLimitIdempotency() throws Exception {
}
@Test
- public void testRateLimitRegEx() throws Exception {
+ void testRateLimitRegEx() throws Exception {
String msg2 =
"Job eceeded rate limits: Your table exceeded quota for table update operations. For more information, see https://cloud.google.com/bigquery/docs/troubleshoot-quotas";
String msg3 = "exceeded rate exceeded quota for table update";
@@ -2979,7 +2997,7 @@ public void testRateLimitRegEx() throws Exception {
}
@Test
- public void testFastQueryDDLShouldRetry() throws Exception {
+ void testFastQueryDDLShouldRetry() throws Exception {
com.google.api.services.bigquery.model.QueryResponse responsePb =
new com.google.api.services.bigquery.model.QueryResponse()
.setCacheHit(false)
@@ -3019,7 +3037,7 @@ public void testFastQueryDDLShouldRetry() throws Exception {
}
@Test
- public void testFastQueryBigQueryException() throws InterruptedException, IOException {
+ void testFastQueryBigQueryException() throws InterruptedException, IOException {
List errorProtoList =
ImmutableList.of(
new ErrorProto()
@@ -3040,12 +3058,10 @@ public void testFastQueryBigQueryException() throws InterruptedException, IOExce
.thenReturn(responsePb);
bigquery = options.getService();
- try {
- bigquery.query(QUERY_JOB_CONFIGURATION_FOR_QUERY);
- fail("BigQueryException expected");
- } catch (BigQueryException ex) {
- assertEquals(Lists.transform(errorProtoList, BigQueryError.FROM_PB_FUNCTION), ex.getErrors());
- }
+ BigQueryException ex =
+ Assertions.assertThrows(
+ BigQueryException.class, () -> bigquery.query(QUERY_JOB_CONFIGURATION_FOR_QUERY));
+ assertEquals(Lists.transform(errorProtoList, BigQueryError.FROM_PB_FUNCTION), ex.getErrors());
QueryRequest requestPb = requestPbCapture.getValue();
assertEquals(QUERY_JOB_CONFIGURATION_FOR_QUERY.getQuery(), requestPb.getQuery());
@@ -3058,7 +3074,7 @@ public void testFastQueryBigQueryException() throws InterruptedException, IOExce
}
@Test
- public void testCreateRoutine() throws IOException {
+ void testCreateRoutine() throws IOException {
RoutineInfo routineInfo = ROUTINE_INFO.setProjectId(OTHER_PROJECT);
when(bigqueryRpcMock.createSkipExceptionTranslation(routineInfo.toPb(), EMPTY_RPC_OPTIONS))
.thenReturn(routineInfo.toPb());
@@ -3071,7 +3087,7 @@ public void testCreateRoutine() throws IOException {
}
@Test
- public void testGetRoutine() throws IOException {
+ void testGetRoutine() throws IOException {
when(bigqueryRpcMock.getRoutineSkipExceptionTranslation(
PROJECT, DATASET, ROUTINE, EMPTY_RPC_OPTIONS))
.thenReturn(ROUTINE_INFO.toPb());
@@ -3083,7 +3099,7 @@ public void testGetRoutine() throws IOException {
}
@Test
- public void testGetRoutineWithRountineId() throws IOException {
+ void testGetRoutineWithRountineId() throws IOException {
when(bigqueryRpcMock.getRoutineSkipExceptionTranslation(
PROJECT, DATASET, ROUTINE, EMPTY_RPC_OPTIONS))
.thenReturn(ROUTINE_INFO.toPb());
@@ -3095,24 +3111,21 @@ public void testGetRoutineWithRountineId() throws IOException {
}
@Test
- public void testGetRoutineWithEnabledThrowNotFoundException() throws IOException {
+ void testGetRoutineWithEnabledThrowNotFoundException() throws IOException {
when(bigqueryRpcMock.getRoutineSkipExceptionTranslation(
PROJECT, DATASET, ROUTINE, EMPTY_RPC_OPTIONS))
.thenThrow(new BigQueryException(404, "Routine not found"));
options.setThrowNotFound(true);
bigquery = options.getService();
- try {
- bigquery.getRoutine(ROUTINE_ID);
- fail();
- } catch (BigQueryException ex) {
- assertEquals("Routine not found", ex.getMessage());
- }
+ BigQueryException ex =
+ Assertions.assertThrows(BigQueryException.class, () -> bigquery.getRoutine(ROUTINE_ID));
+ assertEquals("Routine not found", ex.getMessage());
verify(bigqueryRpcMock)
.getRoutineSkipExceptionTranslation(PROJECT, DATASET, ROUTINE, EMPTY_RPC_OPTIONS);
}
@Test
- public void testUpdateRoutine() throws IOException {
+ void testUpdateRoutine() throws IOException {
RoutineInfo updatedRoutineInfo =
ROUTINE_INFO.setProjectId(OTHER_PROJECT).toBuilder()
.setDescription("newDescription")
@@ -3130,7 +3143,7 @@ public void testUpdateRoutine() throws IOException {
}
@Test
- public void testListRoutines() throws IOException {
+ void testListRoutines() throws IOException {
bigquery = options.getService();
ImmutableList routineList =
ImmutableList.of(new Routine(bigquery, new RoutineInfo.BuilderImpl(ROUTINE_INFO)));
@@ -3146,7 +3159,7 @@ public void testListRoutines() throws IOException {
}
@Test
- public void testListRoutinesWithDatasetId() throws IOException {
+ void testListRoutinesWithDatasetId() throws IOException {
bigquery = options.getService();
ImmutableList routineList =
ImmutableList.of(new Routine(bigquery, new RoutineInfo.BuilderImpl(ROUTINE_INFO)));
@@ -3162,7 +3175,7 @@ public void testListRoutinesWithDatasetId() throws IOException {
}
@Test
- public void testDeleteRoutine() throws IOException {
+ void testDeleteRoutine() throws IOException {
when(bigqueryRpcMock.deleteRoutineSkipExceptionTranslation(PROJECT, DATASET, ROUTINE))
.thenReturn(true);
bigquery = options.getService();
@@ -3171,7 +3184,7 @@ public void testDeleteRoutine() throws IOException {
}
@Test
- public void testWriteWithJob() throws IOException {
+ void testWriteWithJob() throws IOException {
bigquery = options.getService();
Job job = new Job(bigquery, new JobInfo.BuilderImpl(JOB_INFO));
when(bigqueryRpcMock.openSkipExceptionTranslation(
@@ -3197,7 +3210,7 @@ public void testWriteWithJob() throws IOException {
}
@Test
- public void testWriteChannel() throws IOException {
+ void testWriteChannel() throws IOException {
bigquery = options.getService();
Job job = new Job(bigquery, new JobInfo.BuilderImpl(JOB_INFO));
when(bigqueryRpcMock.openSkipExceptionTranslation(
@@ -3223,7 +3236,7 @@ public void testWriteChannel() throws IOException {
}
@Test
- public void testGetIamPolicy() throws IOException {
+ void testGetIamPolicy() throws IOException {
final String resourceId =
String.format("projects/%s/datasets/%s/tables/%s", PROJECT, DATASET, TABLE);
final com.google.api.services.bigquery.model.Policy apiPolicy =
@@ -3237,7 +3250,7 @@ public void testGetIamPolicy() throws IOException {
}
@Test
- public void testSetIamPolicy() throws IOException {
+ void testSetIamPolicy() throws IOException {
final String resourceId =
String.format("projects/%s/datasets/%s/tables/%s", PROJECT, DATASET, TABLE);
final com.google.api.services.bigquery.model.Policy apiPolicy =
@@ -3253,7 +3266,7 @@ public void testSetIamPolicy() throws IOException {
}
@Test
- public void testTestIamPermissions() throws IOException {
+ void testTestIamPermissions() throws IOException {
final String resourceId =
String.format("projects/%s/datasets/%s/tables/%s", PROJECT, DATASET, TABLE);
final List checkedPermissions = ImmutableList.of("foo", "bar", "baz");
@@ -3273,7 +3286,7 @@ public void testTestIamPermissions() throws IOException {
}
@Test
- public void testTestIamPermissionsWhenNoPermissionsGranted() throws IOException {
+ void testTestIamPermissionsWhenNoPermissionsGranted() throws IOException {
final String resourceId =
String.format("projects/%s/datasets/%s/tables/%s", PROJECT, DATASET, TABLE);
final List checkedPermissions = ImmutableList.of("foo", "bar", "baz");
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryOptionsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryOptionsTest.java
index e77d7936a..050deba4a 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryOptionsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryOptionsTest.java
@@ -16,33 +16,34 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.cloud.TransportOptions;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class BigQueryOptionsTest {
@Test
- public void testInvalidTransport() {
- try {
- BigQueryOptions.newBuilder().setTransportOptions(Mockito.mock(TransportOptions.class));
- Assert.fail();
- } catch (IllegalArgumentException expected) {
- Assert.assertNotNull(expected.getMessage());
- }
+ void testInvalidTransport() {
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ BigQueryOptions.newBuilder()
+ .setTransportOptions(Mockito.mock(TransportOptions.class)));
+ assertNotNull(expected.getMessage());
}
@Test
- public void dataFormatOptions_createdByDefault() {
+ void dataFormatOptions_createdByDefault() {
BigQueryOptions options = BigQueryOptions.newBuilder().setProjectId("project-id").build();
assertNotNull(options.getDataFormatOptions());
@@ -53,7 +54,7 @@ public void dataFormatOptions_createdByDefault() {
}
@Test
- public void nonBuilderSetUseInt64Timestamp_capturedInDataFormatOptions() {
+ void nonBuilderSetUseInt64Timestamp_capturedInDataFormatOptions() {
BigQueryOptions options =
BigQueryOptions.newBuilder()
.setDataFormatOptions(DataFormatOptions.newBuilder().useInt64Timestamp(false).build())
@@ -65,7 +66,7 @@ public void nonBuilderSetUseInt64Timestamp_capturedInDataFormatOptions() {
}
@Test
- public void nonBuilderSetUseInt64Timestamp_overridesEverything() {
+ void nonBuilderSetUseInt64Timestamp_overridesEverything() {
BigQueryOptions options = BigQueryOptions.newBuilder().setProjectId("project-id").build();
options.setUseInt64Timestamps(true);
@@ -73,7 +74,7 @@ public void nonBuilderSetUseInt64Timestamp_overridesEverything() {
}
@Test
- public void noDataFormatOptions_capturesUseInt64TimestampSetInBuilder() {
+ void noDataFormatOptions_capturesUseInt64TimestampSetInBuilder() {
BigQueryOptions options =
BigQueryOptions.newBuilder().setUseInt64Timestamps(true).setProjectId("project-id").build();
@@ -81,7 +82,7 @@ public void noDataFormatOptions_capturesUseInt64TimestampSetInBuilder() {
}
@Test
- public void dataFormatOptionsSetterHasPrecedence() {
+ void dataFormatOptionsSetterHasPrecedence() {
BigQueryOptions options =
BigQueryOptions.newBuilder()
.setProjectId("project-id")
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryResultImplTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryResultImplTest.java
index ca150eb1b..54d0b8e4e 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryResultImplTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryResultImplTest.java
@@ -37,9 +37,9 @@
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import org.apache.arrow.vector.util.Text;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class BigQueryResultImplTest {
+class BigQueryResultImplTest {
private static final Schema SCHEMA =
Schema.of(
@@ -97,7 +97,7 @@ public class BigQueryResultImplTest {
private static final int BUFFER_SIZE = 10;
@Test
- public void testResultSetFieldValueList() throws InterruptedException, SQLException {
+ void testResultSetFieldValueList() throws InterruptedException, SQLException {
BlockingQueue> buffer = new LinkedBlockingDeque<>(BUFFER_SIZE);
FieldValueList fieldValues =
FieldValueList.of(
@@ -199,7 +199,7 @@ public void testResultSetFieldValueList() throws InterruptedException, SQLExcept
}
@Test
- public void testResultSetReadApi() throws InterruptedException, SQLException {
+ void testResultSetReadApi() throws InterruptedException, SQLException {
BlockingQueue buffer = new LinkedBlockingDeque<>(BUFFER_SIZE);
Map rowValues = new HashMap<>();
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigtableOptionsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigtableOptionsTest.java
index 88fa1595e..a11d9b923 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigtableOptionsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigtableOptionsTest.java
@@ -18,8 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class BigtableOptionsTest {
@@ -55,7 +55,7 @@ public class BigtableOptionsTest {
.build();
@Test
- public void testConstructors() {
+ void testConstructors() {
// column
assertThat(COL1.getQualifierEncoded()).isEqualTo("aaa");
assertThat(COL1.getFieldName()).isEqualTo("field1");
@@ -80,41 +80,36 @@ public void testConstructors() {
}
@Test
- public void testNullPointerException() {
- try {
- BigtableColumnFamily.newBuilder().setFamilyID(null).build();
- Assert.fail();
- } catch (NullPointerException ex) {
- assertThat(ex.getMessage()).isNotNull();
- }
- try {
- BigtableColumnFamily.newBuilder().setColumns(null).build();
- Assert.fail();
- } catch (NullPointerException ex) {
- assertThat(ex.getMessage()).isNotNull();
- }
- try {
- BigtableColumnFamily.newBuilder().setEncoding(null).build();
- Assert.fail();
- } catch (NullPointerException ex) {
- assertThat(ex.getMessage()).isNotNull();
- }
- try {
- BigtableColumnFamily.newBuilder().setOnlyReadLatest(null).build();
- Assert.fail();
- } catch (NullPointerException ex) {
- assertThat(ex.getMessage()).isNotNull();
- }
- try {
- BigtableColumnFamily.newBuilder().setType(null).build();
- Assert.fail();
- } catch (NullPointerException ex) {
- assertThat(ex.getMessage()).isNotNull();
- }
+ void testNullPointerException() {
+ NullPointerException ex =
+ Assertions.assertThrows(
+ NullPointerException.class,
+ () -> BigtableColumnFamily.newBuilder().setFamilyID(null).build());
+ assertThat(ex.getMessage()).isNotNull();
+ ex =
+ Assertions.assertThrows(
+ NullPointerException.class,
+ () -> BigtableColumnFamily.newBuilder().setColumns(null).build());
+ assertThat(ex.getMessage()).isNotNull();
+ ex =
+ Assertions.assertThrows(
+ NullPointerException.class,
+ () -> BigtableColumnFamily.newBuilder().setEncoding(null).build());
+ assertThat(ex.getMessage()).isNotNull();
+ ex =
+ Assertions.assertThrows(
+ NullPointerException.class,
+ () -> BigtableColumnFamily.newBuilder().setOnlyReadLatest(null).build());
+ assertThat(ex.getMessage()).isNotNull();
+ ex =
+ Assertions.assertThrows(
+ NullPointerException.class,
+ () -> BigtableColumnFamily.newBuilder().setType(null).build());
+ assertThat(ex.getMessage()).isNotNull();
}
@Test
- public void testIllegalStateException() {
+ void testIllegalStateException() {
try {
BigtableColumnFamily.newBuilder().build();
} catch (IllegalStateException ex) {
@@ -123,14 +118,14 @@ public void testIllegalStateException() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareBigtableColumn(COL1, BigtableColumn.fromPb(COL1.toPb()));
compareBigtableColumnFamily(TESTFAMILY, BigtableColumnFamily.fromPb(TESTFAMILY.toPb()));
compareBigtableOptions(OPTIONS, BigtableOptions.fromPb(OPTIONS.toPb()));
}
@Test
- public void testEquals() {
+ void testEquals() {
compareBigtableColumn(COL1, COL1);
compareBigtableColumnFamily(TESTFAMILY, TESTFAMILY);
assertThat(TESTFAMILY.equals(TESTFAMILY)).isTrue();
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CloneDefinitionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CloneDefinitionTest.java
index 33bcf5f40..1a319c947 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CloneDefinitionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CloneDefinitionTest.java
@@ -16,10 +16,10 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class CloneDefinitionTest {
private static final TableId BASE_TABLE_ID = TableId.of("DATASET_NAME", "BASE_TABLE_NAME");
@@ -28,7 +28,7 @@ public class CloneDefinitionTest {
CloneDefinition.newBuilder().setBaseTableId(BASE_TABLE_ID).setCloneTime(CLONE_TIME).build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareCloneTableDefinition(CLONETABLE_DEFINITION, CLONETABLE_DEFINITION.toBuilder().build());
CloneDefinition cloneTableDefinition =
CLONETABLE_DEFINITION.toBuilder().setCloneTime("2021-05-20T11:32:26.553Z").build();
@@ -36,7 +36,7 @@ public void testToBuilder() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(BASE_TABLE_ID, CLONETABLE_DEFINITION.getBaseTableId());
assertEquals(CLONE_TIME, CLONETABLE_DEFINITION.getCloneTime());
CloneDefinition cloneDefinition =
@@ -45,7 +45,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
CloneDefinition cloneDefinition = CLONETABLE_DEFINITION.toBuilder().build();
assertTrue(CloneDefinition.fromPb(cloneDefinition.toPb()) instanceof CloneDefinition);
compareCloneTableDefinition(cloneDefinition, CloneDefinition.fromPb(cloneDefinition.toPb()));
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ColumnReferenceTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ColumnReferenceTest.java
index 0cc680ddd..0c7c75306 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ColumnReferenceTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ColumnReferenceTest.java
@@ -16,10 +16,10 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ColumnReferenceTest {
private static final ColumnReference COLUMN_REFERENCE =
@@ -29,7 +29,7 @@ public class ColumnReferenceTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareColumnReferenceDefinition(COLUMN_REFERENCE, COLUMN_REFERENCE.toBuilder().build());
ColumnReference columnReference =
COLUMN_REFERENCE.toBuilder()
@@ -41,7 +41,7 @@ public void testToBuilder() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals("column1", COLUMN_REFERENCE.getReferencingColumn());
assertEquals("column2", COLUMN_REFERENCE.getReferencedColumn());
ColumnReference columnReference =
@@ -54,7 +54,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
ColumnReference columnReference = COLUMN_REFERENCE.toBuilder().build();
assertTrue(ColumnReference.fromPb(columnReference.toPb()) instanceof ColumnReference);
compareColumnReferenceDefinition(
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionImplTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionImplTest.java
index 4edc6f05d..54f9b7a33 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionImplTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionImplTest.java
@@ -16,14 +16,26 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
-import com.google.api.services.bigquery.model.*;
+import com.google.api.services.bigquery.model.GetQueryResultsResponse;
+import com.google.api.services.bigquery.model.QueryParameter;
+import com.google.api.services.bigquery.model.QueryParameterType;
+import com.google.api.services.bigquery.model.QueryRequest;
import com.google.api.services.bigquery.model.QueryResponse;
+import com.google.api.services.bigquery.model.TableCell;
+import com.google.api.services.bigquery.model.TableDataList;
+import com.google.api.services.bigquery.model.TableRow;
+import com.google.api.services.bigquery.model.TableSchema;
import com.google.cloud.ServiceOptions;
import com.google.cloud.Tuple;
import com.google.cloud.bigquery.spi.BigQueryRpcFactory;
@@ -41,14 +53,14 @@
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingDeque;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
-public class ConnectionImplTest {
+@ExtendWith(MockitoExtension.class)
+class ConnectionImplTest {
private BigQueryOptions options;
private BigQueryRpcFactory rpcFactoryMock;
private HttpBigQueryRpc bigqueryRpcMock;
@@ -140,8 +152,8 @@ private BigQueryOptions createBigQueryOptionsForProject(
.build();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
rpcFactoryMock = mock(BigQueryRpcFactory.class);
bigqueryRpcMock = mock(HttpBigQueryRpc.class);
connectionMock = mock(Connection.class);
@@ -164,7 +176,7 @@ public void setUp() {
}
@Test
- public void testFastQuerySinglePage() throws BigQuerySQLException, IOException {
+ void testFastQuerySinglePage() throws BigQuerySQLException, IOException {
com.google.api.services.bigquery.model.QueryResponse mockQueryRes =
new QueryResponse().setSchema(FAST_QUERY_TABLESCHEMA).setJobComplete(true);
when(bigqueryRpcMock.queryRpcSkipExceptionTranslation(
@@ -186,7 +198,7 @@ public void testFastQuerySinglePage() throws BigQuerySQLException, IOException {
@Test
// NOTE: This doesn't truly paginates. Returns a response while mocking
// processQueryResponseResults
- public void testFastQueryMultiplePages() throws BigQuerySQLException, IOException {
+ void testFastQueryMultiplePages() throws BigQuerySQLException, IOException {
com.google.api.services.bigquery.model.QueryResponse mockQueryRes =
new QueryResponse()
.setSchema(FAST_QUERY_TABLESCHEMA)
@@ -211,13 +223,13 @@ public void testFastQueryMultiplePages() throws BigQuerySQLException, IOExceptio
}
@Test
- public void testClose() throws BigQuerySQLException {
+ void testClose() throws BigQuerySQLException {
boolean cancelled = connection.close();
assertTrue(cancelled);
}
@Test
- public void testQueryDryRun() throws BigQuerySQLException, IOException {
+ void testQueryDryRun() throws BigQuerySQLException, IOException {
List queryParametersMock =
ImmutableList.of(
new QueryParameter().setParameterType(new QueryParameterType().setType("STRING")));
@@ -251,7 +263,7 @@ public void testQueryDryRun() throws BigQuerySQLException, IOException {
}
@Test
- public void testQueryDryRunNoQueryParameters() throws BigQuerySQLException, IOException {
+ void testQueryDryRunNoQueryParameters() throws BigQuerySQLException, IOException {
com.google.api.services.bigquery.model.JobStatistics2 queryMock =
new com.google.api.services.bigquery.model.JobStatistics2()
.setSchema(FAST_QUERY_TABLESCHEMA);
@@ -281,7 +293,7 @@ public void testQueryDryRunNoQueryParameters() throws BigQuerySQLException, IOEx
}
@Test
- public void testParseDataTask() throws InterruptedException {
+ void testParseDataTask() throws InterruptedException {
BlockingQueue, Boolean>> pageCache =
new LinkedBlockingDeque<>(2);
BlockingQueue> rpcResponseQueue = new LinkedBlockingDeque<>(2);
@@ -306,7 +318,7 @@ public void testParseDataTask() throws InterruptedException {
}
@Test
- public void testPopulateBuffer() throws InterruptedException {
+ void testPopulateBuffer() throws InterruptedException {
BlockingQueue, Boolean>> pageCache =
new LinkedBlockingDeque<>(2);
@@ -341,7 +353,7 @@ public void testPopulateBuffer() throws InterruptedException {
}
@Test
- public void testNextPageTask() throws InterruptedException {
+ void testNextPageTask() throws InterruptedException {
BlockingQueue> rpcResponseQueue = new LinkedBlockingDeque<>(2);
TableDataList mockTabledataList =
new TableDataList()
@@ -364,7 +376,7 @@ public void testNextPageTask() throws InterruptedException {
}
@Test
- public void testGetQueryResultsFirstPage() throws IOException {
+ void testGetQueryResultsFirstPage() throws IOException {
when(bigqueryRpcMock.getQueryResultsWithRowLimitSkipExceptionTranslation(
any(String.class),
any(String.class),
@@ -386,7 +398,7 @@ public void testGetQueryResultsFirstPage() throws IOException {
// calls executeSelect with a nonFast query and exercises createQueryJob
@Test
- public void testLegacyQuerySinglePage() throws BigQuerySQLException, IOException {
+ void testLegacyQuerySinglePage() throws BigQuerySQLException, IOException {
ConnectionImpl connectionSpy = Mockito.spy(connection);
com.google.api.services.bigquery.model.Job jobResponseMock =
new com.google.api.services.bigquery.model.Job()
@@ -419,7 +431,7 @@ public void testLegacyQuerySinglePage() throws BigQuerySQLException, IOException
// calls executeSelect with a nonFast query where the query returns an empty result.
@Test
- public void testLegacyQuerySinglePageEmptyResults() throws SQLException, IOException {
+ void testLegacyQuerySinglePageEmptyResults() throws SQLException, IOException {
ConnectionImpl connectionSpy = Mockito.spy(connection);
com.google.api.services.bigquery.model.Job jobResponseMock =
new com.google.api.services.bigquery.model.Job()
@@ -448,7 +460,7 @@ public void testLegacyQuerySinglePageEmptyResults() throws SQLException, IOExcep
// exercises getSubsequentQueryResultsWithJob for fast running queries
@Test
- public void testFastQueryLongRunning() throws SQLException, IOException {
+ void testFastQueryLongRunning() throws SQLException, IOException {
ConnectionImpl connectionSpy = Mockito.spy(connection);
// emulating a fast query
doReturn(true).when(connectionSpy).isFastQuerySupported();
@@ -479,7 +491,7 @@ public void testFastQueryLongRunning() throws SQLException, IOException {
}
@Test
- public void testFastQueryLongRunningAsync()
+ void testFastQueryLongRunningAsync()
throws SQLException, ExecutionException, InterruptedException, IOException {
ConnectionImpl connectionSpy = Mockito.spy(connection);
// emulating a fast query
@@ -515,7 +527,7 @@ public void testFastQueryLongRunningAsync()
}
@Test
- public void testFastQuerySinglePageAsync()
+ void testFastQuerySinglePageAsync()
throws BigQuerySQLException, ExecutionException, InterruptedException, IOException {
com.google.api.services.bigquery.model.QueryResponse mockQueryRes =
new QueryResponse().setSchema(FAST_QUERY_TABLESCHEMA).setJobComplete(true);
@@ -540,7 +552,7 @@ public void testFastQuerySinglePageAsync()
}
@Test
- public void testExecuteSelectSlowWithParamsAsync()
+ void testExecuteSelectSlowWithParamsAsync()
throws BigQuerySQLException, ExecutionException, InterruptedException {
ConnectionImpl connectionSpy = Mockito.spy(connection);
List parameters = new ArrayList<>();
@@ -584,7 +596,7 @@ public void testExecuteSelectSlowWithParamsAsync()
}
@Test
- public void testFastQueryMultiplePagesAsync()
+ void testFastQueryMultiplePagesAsync()
throws BigQuerySQLException, ExecutionException, InterruptedException, IOException {
com.google.api.services.bigquery.model.QueryResponse mockQueryRes =
new QueryResponse()
@@ -616,7 +628,7 @@ public void testFastQueryMultiplePagesAsync()
@Test
// Emulates first page response using getQueryResultsFirstPage(jobId) and then subsequent pages
// using getQueryResultsFirstPage(jobId) getSubsequentQueryResultsWithJob(
- public void testLegacyQueryMultiplePages() throws SQLException, IOException {
+ void testLegacyQueryMultiplePages() throws SQLException, IOException {
ConnectionImpl connectionSpy = Mockito.spy(connection);
com.google.api.services.bigquery.model.JobStatistics jobStatistics =
new com.google.api.services.bigquery.model.JobStatistics();
@@ -649,7 +661,7 @@ public void testLegacyQueryMultiplePages() throws SQLException, IOException {
}
@Test
- public void testExecuteSelectSlow() throws BigQuerySQLException {
+ void testExecuteSelectSlow() throws BigQuerySQLException {
ConnectionImpl connectionSpy = Mockito.spy(connection);
doReturn(false).when(connectionSpy).isFastQuerySupported();
com.google.api.services.bigquery.model.JobStatistics jobStatistics =
@@ -686,7 +698,7 @@ public void testExecuteSelectSlow() throws BigQuerySQLException {
}
@Test
- public void testExecuteSelectSlowWithParams() throws BigQuerySQLException {
+ void testExecuteSelectSlowWithParams() throws BigQuerySQLException {
ConnectionImpl connectionSpy = Mockito.spy(connection);
List parameters = new ArrayList<>();
Map labels = new HashMap<>();
@@ -725,7 +737,7 @@ public void testExecuteSelectSlowWithParams() throws BigQuerySQLException {
}
@Test
- public void testGetSubsequentQueryResultsWithJob() {
+ void testGetSubsequentQueryResultsWithJob() {
ConnectionImpl connectionSpy = Mockito.spy(connection);
JobId jobId = mock(JobId.class);
BigQueryResultStats bqRsStats = mock(BigQueryResultStats.class);
@@ -749,7 +761,7 @@ public void testGetSubsequentQueryResultsWithJob() {
}
@Test
- public void testUseReadApi() {
+ void testUseReadApi() {
ConnectionSettings connectionSettingsSpy = Mockito.spy(ConnectionSettings.class);
doReturn(true).when(connectionSettingsSpy).getUseReadAPI();
doReturn(2).when(connectionSettingsSpy).getTotalToPageRowCountRatio();
@@ -775,7 +787,7 @@ public void testUseReadApi() {
}
@Test
- public void testGetPageCacheSize() {
+ void testGetPageCacheSize() {
ConnectionImpl connectionSpy = Mockito.spy(connection);
// number of cached pages should be within a range
assertTrue(connectionSpy.getPageCacheSize(10000, QUERY_SCHEMA) >= 3);
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionPropertyTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionPropertyTest.java
index 9177720e8..bc5def560 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionPropertyTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionPropertyTest.java
@@ -18,7 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ConnectionPropertyTest {
@@ -28,7 +28,7 @@ public class ConnectionPropertyTest {
ConnectionProperty.newBuilder().setKey(KEY).setValue(VALUE).build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareConnectionProperty(CONNECTION_PROPERTY, CONNECTION_PROPERTY.toBuilder().build());
ConnectionProperty property = CONNECTION_PROPERTY.toBuilder().setKey("time-zone").build();
assertThat(property.getKey()).isEqualTo("time-zone");
@@ -37,19 +37,19 @@ public void testToBuilder() {
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
ConnectionProperty connectionProperty = ConnectionProperty.of(KEY, VALUE);
compareConnectionProperty(connectionProperty, connectionProperty.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertThat(CONNECTION_PROPERTY.getKey()).isEqualTo(KEY);
assertThat(CONNECTION_PROPERTY.getValue()).isEqualTo(VALUE);
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareConnectionProperty(
CONNECTION_PROPERTY, ConnectionProperty.fromPb(CONNECTION_PROPERTY.toPb()));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionSettingsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionSettingsTest.java
index 8523825bc..29c29ed55 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionSettingsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionSettingsTest.java
@@ -16,7 +16,7 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.cloud.bigquery.JobInfo.CreateDisposition;
import com.google.cloud.bigquery.JobInfo.SchemaUpdateOption;
@@ -26,9 +26,9 @@
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ConnectionSettingsTest {
+class ConnectionSettingsTest {
private static final String TEST_PROJECT_ID = "test-project-id";
private static final DatasetId DATASET_ID = DatasetId.of("dataset");
private static final TableId TABLE_ID = TableId.of("dataset", "table");
@@ -116,19 +116,19 @@ public class ConnectionSettingsTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareConnectionSettings(CONNECTION_SETTINGS, CONNECTION_SETTINGS.toBuilder().build());
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
ConnectionSettings connectionSettings =
ConnectionSettings.newBuilder().setDefaultDataset(DATASET_ID).build();
compareConnectionSettings(connectionSettings, connectionSettings.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(REQUEST_TIMEOUT, CONNECTION_SETTINGS.getRequestTimeout());
assertEquals(NUM_BUFFERED_ROWS, CONNECTION_SETTINGS.getNumBufferedRows());
assertEquals(MAX_RESULTS, CONNECTION_SETTINGS.getMaxResults());
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CopyJobConfigurationTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CopyJobConfigurationTest.java
index 3f21bf1c0..97538f299 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CopyJobConfigurationTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CopyJobConfigurationTest.java
@@ -16,9 +16,9 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.cloud.bigquery.JobInfo.CreateDisposition;
import com.google.cloud.bigquery.JobInfo.WriteDisposition;
@@ -28,9 +28,9 @@
import com.google.common.collect.Lists;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class CopyJobConfigurationTest {
+class CopyJobConfigurationTest {
private static final String TEST_PROJECT_ID = "test-project-id";
private static final TableId SOURCE_TABLE = TableId.of("dataset", "sourceTable");
@@ -64,7 +64,7 @@ public class CopyJobConfigurationTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareCopyJobConfiguration(COPY_JOB_CONFIGURATION, COPY_JOB_CONFIGURATION.toBuilder().build());
compareCopyJobConfiguration(
COPY_JOB_CONFIGURATION_MULTIPLE_TABLES,
@@ -79,7 +79,7 @@ public void testToBuilder() {
}
@Test
- public void testOf() {
+ void testOf() {
CopyJobConfiguration job = CopyJobConfiguration.of(DESTINATION_TABLE, SOURCE_TABLES);
assertEquals(DESTINATION_TABLE, job.getDestinationTable());
assertEquals(SOURCE_TABLES, job.getSourceTables());
@@ -89,14 +89,14 @@ public void testOf() {
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
CopyJobConfiguration jobConfiguration =
CopyJobConfiguration.of(DESTINATION_TABLE, SOURCE_TABLES);
compareCopyJobConfiguration(jobConfiguration, jobConfiguration.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(DESTINATION_TABLE, COPY_JOB_CONFIGURATION_MULTIPLE_TABLES.getDestinationTable());
assertEquals(SOURCE_TABLES, COPY_JOB_CONFIGURATION_MULTIPLE_TABLES.getSourceTables());
assertEquals(CREATE_DISPOSITION, COPY_JOB_CONFIGURATION_MULTIPLE_TABLES.getCreateDisposition());
@@ -110,7 +110,7 @@ public void testBuilder() {
}
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
assertNotNull(COPY_JOB_CONFIGURATION.toPb().getCopy());
assertNull(COPY_JOB_CONFIGURATION.toPb().getExtract());
assertNull(COPY_JOB_CONFIGURATION.toPb().getLoad());
@@ -133,7 +133,7 @@ public void testToPbAndFromPb() {
}
@Test
- public void testSetProjectId() {
+ void testSetProjectId() {
CopyJobConfiguration configuration =
COPY_JOB_CONFIGURATION_MULTIPLE_TABLES.setProjectId(TEST_PROJECT_ID);
assertEquals(TEST_PROJECT_ID, configuration.getDestinationTable().getProject());
@@ -143,7 +143,7 @@ public void testSetProjectId() {
}
@Test
- public void testSetProjectIdDoNotOverride() {
+ void testSetProjectIdDoNotOverride() {
CopyJobConfiguration configuration =
COPY_JOB_CONFIGURATION_MULTIPLE_TABLES.toBuilder()
.setSourceTables(
@@ -165,7 +165,7 @@ public TableId apply(TableId tableId) {
}
@Test
- public void testGetType() {
+ void testGetType() {
assertEquals(JobConfiguration.Type.COPY, COPY_JOB_CONFIGURATION.getType());
assertEquals(JobConfiguration.Type.COPY, COPY_JOB_CONFIGURATION_MULTIPLE_TABLES.getType());
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CsvOptionsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CsvOptionsTest.java
index fb0293a97..1c31540fc 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CsvOptionsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CsvOptionsTest.java
@@ -16,11 +16,11 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class CsvOptionsTest {
@@ -46,7 +46,7 @@ public class CsvOptionsTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareCsvOptions(CSV_OPTIONS, CSV_OPTIONS.toBuilder().build());
CsvOptions csvOptions = CSV_OPTIONS.toBuilder().setFieldDelimiter(";").build();
assertEquals(";", csvOptions.getFieldDelimiter());
@@ -55,13 +55,13 @@ public void testToBuilder() {
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
CsvOptions csvOptions = CsvOptions.newBuilder().setFieldDelimiter("|").build();
assertEquals(csvOptions, csvOptions.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(FormatOptions.CSV, CSV_OPTIONS.getType());
assertEquals(ALLOW_JAGGED_ROWS, CSV_OPTIONS.allowJaggedRows());
assertEquals(ALLOW_QUOTED_NEWLINE, CSV_OPTIONS.allowQuotedNewLines());
@@ -75,7 +75,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareCsvOptions(CSV_OPTIONS, CsvOptions.fromPb(CSV_OPTIONS.toPb()));
CsvOptions csvOptions = CsvOptions.newBuilder().setAllowJaggedRows(ALLOW_JAGGED_ROWS).build();
compareCsvOptions(csvOptions, CsvOptions.fromPb(csvOptions.toPb()));
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetIdTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetIdTest.java
index bacf7b2b0..dc2ba2899 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetIdTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetIdTest.java
@@ -16,17 +16,17 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class DatasetIdTest {
+class DatasetIdTest {
private static final DatasetId DATASET = DatasetId.of("dataset");
private static final DatasetId DATASET_COMPLETE = DatasetId.of("project", "dataset");
@Test
- public void testOf() {
+ void testOf() {
assertEquals(null, DATASET.getProject());
assertEquals("dataset", DATASET.getDataset());
assertEquals("project", DATASET_COMPLETE.getProject());
@@ -34,19 +34,19 @@ public void testOf() {
}
@Test
- public void testEquals() {
+ void testEquals() {
compareDatasetIds(DATASET, DatasetId.of("dataset"));
compareDatasetIds(DATASET_COMPLETE, DatasetId.of("project", "dataset"));
}
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
compareDatasetIds(DATASET, DatasetId.fromPb(DATASET.toPb()));
compareDatasetIds(DATASET_COMPLETE, DatasetId.fromPb(DATASET_COMPLETE.toPb()));
}
@Test
- public void testSetProjectId() {
+ void testSetProjectId() {
assertEquals(DATASET_COMPLETE, DATASET.setProjectId("project"));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetInfoTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetInfoTest.java
index 1b75195ce..cb9768de4 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetInfoTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetInfoTest.java
@@ -16,16 +16,16 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class DatasetInfoTest {
@@ -104,7 +104,7 @@ public class DatasetInfoTest {
DATASET_INFO.toBuilder().setMaxTimeTravelHours(MAX_TIME_TRAVEL_HOURS_5_DAYS).build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareDatasets(DATASET_INFO, DATASET_INFO.toBuilder().build());
compareDatasets(
DATASET_INFO_COMPLETE_WITH_IAM_MEMBER,
@@ -122,13 +122,13 @@ public void testToBuilder() {
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
DatasetInfo datasetInfo = DatasetInfo.newBuilder(DATASET_ID).build();
assertEquals(datasetInfo, datasetInfo.toBuilder().build());
}
@Test
- public void testToBuilderWithExternalDatasetReference() {
+ void testToBuilderWithExternalDatasetReference() {
compareDatasets(
DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE,
DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE.toBuilder().build());
@@ -149,7 +149,7 @@ public void testToBuilderWithExternalDatasetReference() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertNull(DATASET_INFO.getDatasetId().getProject());
assertEquals(DATASET_ID, DATASET_INFO.getDatasetId());
assertEquals(ACCESS_RULES, DATASET_INFO.getAcl());
@@ -189,7 +189,7 @@ public void testBuilder() {
}
@Test
- public void testOf() {
+ void testOf() {
DatasetInfo datasetInfo = DatasetInfo.of(DATASET_ID.getDataset());
assertEquals(DATASET_ID, datasetInfo.getDatasetId());
assertNull(datasetInfo.getAcl());
@@ -230,7 +230,7 @@ public void testOf() {
}
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
compareDatasets(DATASET_INFO_COMPLETE, DatasetInfo.fromPb(DATASET_INFO_COMPLETE.toPb()));
compareDatasets(
DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE,
@@ -240,12 +240,12 @@ public void testToPbAndFromPb() {
}
@Test
- public void testSetProjectId() {
+ void testSetProjectId() {
assertEquals(DATASET_INFO_COMPLETE, DATASET_INFO.setProjectId("project"));
}
@Test
- public void testSetMaxTimeTravelHours() {
+ void testSetMaxTimeTravelHours() {
assertNotEquals(
DATASET_INFO_WITH_MAX_TIME_TRAVEL_5_DAYS.getMaxTimeTravelHours(),
DATASET_INFO.getMaxTimeTravelHours());
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetTest.java
index d138e3cb5..5e19e8c82 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetTest.java
@@ -16,13 +16,13 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -35,15 +35,13 @@
import com.google.common.collect.Iterables;
import java.util.List;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.mockito.junit.MockitoRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
-public class DatasetTest {
+@ExtendWith(MockitoExtension.class)
+class DatasetTest {
private static final DatasetId DATASET_ID = DatasetId.of("dataset");
private static final List ACCESS_RULES =
@@ -95,15 +93,13 @@ public class DatasetTest {
.setConnection("connection")
.build();
- @Rule public MockitoRule rule;
-
private BigQuery bigquery;
private BigQueryOptions mockOptions;
private Dataset expectedDataset;
private Dataset dataset;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
bigquery = mock(BigQuery.class);
mockOptions = mock(BigQueryOptions.class);
when(bigquery.getOptions()).thenReturn(mockOptions);
@@ -112,7 +108,7 @@ public void setUp() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
Dataset builtDataset =
new Dataset.Builder(bigquery, DATASET_ID)
.setAcl(ACCESS_RULES)
@@ -148,12 +144,12 @@ public void testBuilder() {
}
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareDataset(expectedDataset, expectedDataset.toBuilder().build());
}
@Test
- public void testExists_True() {
+ void testExists_True() {
BigQuery.DatasetOption[] expectedOptions = {BigQuery.DatasetOption.fields()};
when(bigquery.getDataset(DATASET_INFO.getDatasetId(), expectedOptions))
.thenReturn(expectedDataset);
@@ -162,7 +158,7 @@ public void testExists_True() {
}
@Test
- public void testExists_False() {
+ void testExists_False() {
BigQuery.DatasetOption[] expectedOptions = {BigQuery.DatasetOption.fields()};
when(bigquery.getDataset(DATASET_INFO.getDatasetId(), expectedOptions)).thenReturn(null);
assertFalse(dataset.exists());
@@ -170,7 +166,7 @@ public void testExists_False() {
}
@Test
- public void testReload() {
+ void testReload() {
DatasetInfo updatedInfo = DATASET_INFO.toBuilder().setDescription("Description").build();
Dataset expectedDataset = new Dataset(bigquery, new DatasetInfo.BuilderImpl(updatedInfo));
when(bigquery.getDataset(DATASET_INFO.getDatasetId().getDataset())).thenReturn(expectedDataset);
@@ -180,14 +176,14 @@ public void testReload() {
}
@Test
- public void testReloadNull() {
+ void testReloadNull() {
when(bigquery.getDataset(DATASET_INFO.getDatasetId().getDataset())).thenReturn(null);
assertNull(dataset.reload());
verify(bigquery).getDataset(DATASET_INFO.getDatasetId().getDataset());
}
@Test
- public void testReloadWithOptions() {
+ void testReloadWithOptions() {
DatasetInfo updatedInfo = DATASET_INFO.toBuilder().setDescription("Description").build();
Dataset expectedDataset = new Dataset(bigquery, new DatasetInfo.BuilderImpl(updatedInfo));
when(bigquery.getDataset(
@@ -200,7 +196,7 @@ public void testReloadWithOptions() {
}
@Test
- public void testUpdate() {
+ void testUpdate() {
Dataset expectedUpdatedDataset =
expectedDataset.toBuilder().setDescription("Description").build();
when(bigquery.update(eq(expectedDataset))).thenReturn(expectedUpdatedDataset);
@@ -210,7 +206,7 @@ public void testUpdate() {
}
@Test
- public void testUpdateWithOptions() {
+ void testUpdateWithOptions() {
Dataset expectedUpdatedDataset =
expectedDataset.toBuilder().setDescription("Description").build();
when(bigquery.update(eq(expectedDataset), eq(BigQuery.DatasetOption.fields())))
@@ -221,21 +217,21 @@ public void testUpdateWithOptions() {
}
@Test
- public void testDeleteTrue() {
+ void testDeleteTrue() {
when(bigquery.delete(DATASET_INFO.getDatasetId())).thenReturn(true);
assertTrue(dataset.delete());
verify(bigquery).delete(DATASET_INFO.getDatasetId());
}
@Test
- public void testDeleteFalse() {
+ void testDeleteFalse() {
when(bigquery.delete(DATASET_INFO.getDatasetId())).thenReturn(false);
assertFalse(dataset.delete());
verify(bigquery).delete(DATASET_INFO.getDatasetId());
}
@Test
- public void testList() {
+ void testList() {
List tableResults =
ImmutableList.of(
new Table(bigquery, new Table.BuilderImpl(TABLE_INFO1)),
@@ -251,7 +247,7 @@ public void testList() {
}
@Test
- public void testListWithOptions() {
+ void testListWithOptions() {
List tableResults =
ImmutableList.of(
new Table(bigquery, new Table.BuilderImpl(TABLE_INFO1)),
@@ -269,7 +265,7 @@ public void testListWithOptions() {
}
@Test
- public void testGet() {
+ void testGet() {
Table expectedTable = new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO1));
when(bigquery.getTable(TABLE_INFO1.getTableId())).thenReturn(expectedTable);
Table table = dataset.get(TABLE_INFO1.getTableId().getTable());
@@ -279,7 +275,7 @@ public void testGet() {
}
@Test
- public void testGetTableWithNewProjectId() {
+ void testGetTableWithNewProjectId() {
Table expectedTable = new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO4));
when(bigquery.getTable(TABLE_ID1, null)).thenReturn(expectedTable);
Table table = bigquery.getTable(TABLE_ID1, null);
@@ -289,14 +285,14 @@ public void testGetTableWithNewProjectId() {
}
@Test
- public void testGetNull() {
+ void testGetNull() {
when(bigquery.getTable(TABLE_INFO1.getTableId())).thenReturn(null);
assertNull(dataset.get(TABLE_INFO1.getTableId().getTable()));
verify(bigquery).getTable(TABLE_INFO1.getTableId());
}
@Test
- public void testGetWithOptions() {
+ void testGetWithOptions() {
Table expectedTable = new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO1));
when(bigquery.getTable(TABLE_INFO1.getTableId(), BigQuery.TableOption.fields()))
.thenReturn(expectedTable);
@@ -307,7 +303,7 @@ public void testGetWithOptions() {
}
@Test
- public void testCreateTable() {
+ void testCreateTable() {
Table expectedTable = new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO1));
when(bigquery.create(TABLE_INFO1)).thenReturn(expectedTable);
Table table = dataset.create(TABLE_INFO1.getTableId().getTable(), TABLE_DEFINITION);
@@ -316,7 +312,7 @@ public void testCreateTable() {
}
@Test
- public void testCreateTableWithOptions() {
+ void testCreateTableWithOptions() {
Table expectedTable = new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO1));
when(bigquery.create(TABLE_INFO1, BigQuery.TableOption.fields())).thenReturn(expectedTable);
Table table =
@@ -327,17 +323,17 @@ public void testCreateTableWithOptions() {
}
@Test
- public void testBigQuery() {
+ void testBigQuery() {
assertSame(bigquery, expectedDataset.getBigQuery());
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareDataset(expectedDataset, Dataset.fromPb(bigquery, expectedDataset.toPb()));
}
@Test
- public void testExternalDatasetReference() {
+ void testExternalDatasetReference() {
Dataset datasetWithExternalDatasetReference =
new Dataset.Builder(bigquery, DATASET_ID)
.setAcl(ACCESS_RULES)
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatastoreBackupOptionsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatastoreBackupOptionsTest.java
index af1410803..010278119 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatastoreBackupOptionsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatastoreBackupOptionsTest.java
@@ -16,20 +16,20 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class DatastoreBackupOptionsTest {
+class DatastoreBackupOptionsTest {
private static final List PROJECTION_FIELDS = ImmutableList.of("field1", "field2");
private static final DatastoreBackupOptions BACKUP_OPTIONS =
DatastoreBackupOptions.newBuilder().setProjectionFields(PROJECTION_FIELDS).build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareDatastoreBackupOptions(BACKUP_OPTIONS, BACKUP_OPTIONS.toBuilder().build());
List fields = ImmutableList.of("field1", "field2");
DatastoreBackupOptions backupOptions =
@@ -40,14 +40,14 @@ public void testToBuilder() {
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
DatastoreBackupOptions backupOptions =
DatastoreBackupOptions.newBuilder().setProjectionFields(PROJECTION_FIELDS).build();
assertEquals(backupOptions, backupOptions.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(FormatOptions.DATASTORE_BACKUP, BACKUP_OPTIONS.getType());
assertEquals(PROJECTION_FIELDS, BACKUP_OPTIONS.getProjectionFields());
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DmlStatsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DmlStatsTest.java
index 48950831a..f165b60e3 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DmlStatsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DmlStatsTest.java
@@ -16,9 +16,9 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class DmlStatsTest {
@@ -33,14 +33,14 @@ public class DmlStatsTest {
.build();
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(DELETED_ROW_COUNT, DML_STATS.getDeletedRowCount());
assertEquals(UPDATED_ROW_COUNT, DML_STATS.getUpdatedRowCount());
assertEquals(INSERTED_ROW_COUNT, DML_STATS.getInsertedRowCount());
}
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
compareDmlStats(DML_STATS, DmlStats.fromPb(DML_STATS.toPb()));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalDatasetReferenceTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalDatasetReferenceTest.java
index 6d241948b..26dfcd5dc 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalDatasetReferenceTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalDatasetReferenceTest.java
@@ -16,10 +16,10 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ExternalDatasetReferenceTest {
private static final String EXTERNAL_SOURCE = "test_source";
@@ -31,7 +31,7 @@ public class ExternalDatasetReferenceTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareExternalDatasetReference(
EXTERNAL_DATASET_REFERENCE, EXTERNAL_DATASET_REFERENCE.toBuilder().build());
ExternalDatasetReference externalDatasetReference =
@@ -40,7 +40,7 @@ public void testToBuilder() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(EXTERNAL_SOURCE, EXTERNAL_DATASET_REFERENCE.getExternalSource());
assertEquals(CONNECTION, EXTERNAL_DATASET_REFERENCE.getConnection());
ExternalDatasetReference externalDatasetReference =
@@ -52,7 +52,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
ExternalDatasetReference externalDatasetReference =
EXTERNAL_DATASET_REFERENCE.toBuilder().build();
assertTrue(
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalTableDefinitionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalTableDefinitionTest.java
index cb7578c75..480b8a497 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalTableDefinitionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalTableDefinitionTest.java
@@ -16,16 +16,15 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import com.google.cloud.bigquery.ExternalTableDefinition.SourceColumnMatch;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ExternalTableDefinitionTest {
+class ExternalTableDefinitionTest {
private static final List SOURCE_URIS = ImmutableList.of("uri1", "uri2");
private static final List DECIMAL_TARGET_TYPES =
@@ -98,7 +97,7 @@ public class ExternalTableDefinitionTest {
ExternalTableDefinition.newBuilder(SOURCE_URIS, TABLE_SCHEMA, PARQUET_OPTIONS).build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareExternalTableDefinition(
EXTERNAL_TABLE_DEFINITION, EXTERNAL_TABLE_DEFINITION.toBuilder().build());
ExternalTableDefinition externalTableDefinition =
@@ -117,23 +116,21 @@ public void testToBuilder() {
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
ExternalTableDefinition externalTableDefinition =
ExternalTableDefinition.of(SOURCE_URIS, TABLE_SCHEMA, FormatOptions.json());
assertEquals(externalTableDefinition, externalTableDefinition.toBuilder().build());
}
@Test
- public void testTypeNullPointerException() {
- try {
- EXTERNAL_TABLE_DEFINITION.toBuilder().setType(null).build();
- } catch (NullPointerException ex) {
- assertNotNull(ex.getMessage());
- }
+ void testTypeNullPointerException() {
+ org.junit.jupiter.api.Assertions.assertThrows(
+ NullPointerException.class,
+ () -> EXTERNAL_TABLE_DEFINITION.toBuilder().setType(null).build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(TableDefinition.Type.EXTERNAL, EXTERNAL_TABLE_DEFINITION.getType());
assertEquals(COMPRESSION, EXTERNAL_TABLE_DEFINITION.getCompression());
assertEquals(CONNECTION_ID, EXTERNAL_TABLE_DEFINITION.getConnectionId());
@@ -157,7 +154,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareExternalTableDefinition(
EXTERNAL_TABLE_DEFINITION,
ExternalTableDefinition.fromPb(EXTERNAL_TABLE_DEFINITION.toPb()));
@@ -168,7 +165,7 @@ public void testToAndFromPb() {
}
@Test
- public void testToAndFromPbParquet() {
+ void testToAndFromPbParquet() {
compareExternalTableDefinition(
EXTERNAL_TABLE_DEFINITION_PARQUET,
ExternalTableDefinition.fromPb(EXTERNAL_TABLE_DEFINITION_PARQUET.toPb()));
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExtractJobConfigurationTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExtractJobConfigurationTest.java
index 2bf1e80a2..d7ce318f1 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExtractJobConfigurationTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExtractJobConfigurationTest.java
@@ -16,15 +16,15 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ExtractJobConfigurationTest {
@@ -88,7 +88,7 @@ public class ExtractJobConfigurationTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareExtractJobConfiguration(
EXTRACT_CONFIGURATION, EXTRACT_CONFIGURATION.toBuilder().build());
ExtractJobConfiguration job =
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldElementTypeTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldElementTypeTest.java
index cf217b25c..7821b9321 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldElementTypeTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldElementTypeTest.java
@@ -15,10 +15,10 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.api.services.bigquery.model.QueryParameterType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class FieldElementTypeTest {
private static final FieldElementType FIELD_ELEMENT_TYPE =
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldListTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldListTest.java
index 999bbf1b0..9f6371642 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldListTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldListTest.java
@@ -16,13 +16,14 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class FieldListTest {
+class FieldListTest {
private static final String FIELD_NAME1 = "StringField";
private static final String FIELD_NAME2 = "IntegerField";
private static final String FIELD_NAME3 = "RecordField";
@@ -63,7 +64,7 @@ public class FieldListTest {
private final FieldList fieldsSchema = FieldList.of(fieldSchema1, fieldSchema2, fieldSchema3);
@Test
- public void testGetByName() {
+ void testGetByName() {
assertEquals(fieldSchema1, fieldsSchema.get(FIELD_NAME1));
assertEquals(fieldSchema2, fieldsSchema.get(FIELD_NAME2));
assertEquals(fieldSchema3, fieldsSchema.get(FIELD_NAME3));
@@ -76,34 +77,26 @@ public void testGetByName() {
assertEquals(3, fieldsSchema.size());
- IllegalArgumentException exception = null;
- try {
- fieldsSchema.get(FIELD_NAME4);
- } catch (IllegalArgumentException e) {
- exception = e;
- }
+ IllegalArgumentException exception =
+ assertThrows(IllegalArgumentException.class, () -> fieldsSchema.get(FIELD_NAME4));
assertNotNull(exception);
}
@Test
- public void testGetByIndex() {
+ void testGetByIndex() {
assertEquals(fieldSchema1, fieldsSchema.get(0));
assertEquals(fieldSchema2, fieldsSchema.get(1));
assertEquals(fieldSchema3, fieldsSchema.get(2));
assertEquals(3, fieldsSchema.size());
- IndexOutOfBoundsException exception = null;
- try {
- fieldsSchema.get(4);
- } catch (IndexOutOfBoundsException e) {
- exception = e;
- }
+ IndexOutOfBoundsException exception =
+ assertThrows(IndexOutOfBoundsException.class, () -> fieldsSchema.get(4));
assertNotNull(exception);
}
@Test
- public void testGetRecordSchema() {
+ void testGetRecordSchema() {
assertEquals(2, fieldSchema3.getSubFields().size());
assertEquals(fieldSchema1, fieldSchema3.getSubFields().get(FIELD_NAME1));
assertEquals(fieldSchema2, fieldSchema3.getSubFields().get(FIELD_NAME2));
@@ -122,7 +115,7 @@ public void testGetRecordSchema() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
assertEquals(fieldsSchema, FieldList.of(fieldSchema1, fieldSchema2, fieldSchema3));
assertNotEquals(fieldsSchema, FieldList.of(fieldSchema1, fieldSchema3));
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldTest.java
index d7c5e25a2..72f8bb3e8 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldTest.java
@@ -16,15 +16,15 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class FieldTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueListTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueListTest.java
index 5ade7c229..dd5092b1c 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueListTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueListTest.java
@@ -16,9 +16,10 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.api.client.util.Data;
import com.google.api.services.bigquery.model.TableCell;
@@ -28,9 +29,9 @@
import com.google.common.io.BaseEncoding;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class FieldValueListTest {
+class FieldValueListTest {
private static final byte[] BYTES = {0xD, 0xE, 0xA, 0xD};
private static final String BYTES_BASE64 = BaseEncoding.base64().encode(BYTES);
private static final TableCell booleanPb = new TableCell().setV("false");
@@ -138,7 +139,7 @@ public class FieldValueListTest {
schemaLosslessTimestamp);
@Test
- public void testFromPb() {
+ void testFromPb() {
assertEquals(fieldValues, FieldValueList.fromPb(fieldValuesPb, schema));
// Schema does not influence values equality
assertEquals(fieldValues, FieldValueList.fromPb(fieldValuesPb, null));
@@ -151,7 +152,7 @@ public void testFromPb() {
}
@Test
- public void testGetByIndex() {
+ void testGetByIndex() {
assertEquals(11, fieldValues.size());
assertEquals(booleanFv, fieldValues.get(0));
assertEquals(integerFv, fieldValues.get(1));
@@ -173,7 +174,7 @@ public void testGetByIndex() {
}
@Test
- public void testGetByName() {
+ void testGetByName() {
assertEquals(11, fieldValues.size());
assertEquals(booleanFv, fieldValues.get("first"));
assertEquals(integerFv, fieldValues.get("second"));
@@ -195,7 +196,7 @@ public void testGetByName() {
}
@Test
- public void testNullSchema() {
+ void testNullSchema() {
FieldValueList fieldValuesNoSchema =
FieldValueList.of(
ImmutableList.of(
@@ -213,25 +214,15 @@ public void testNullSchema() {
assertEquals(fieldValues, fieldValuesNoSchema);
- UnsupportedOperationException exception = null;
- try {
- fieldValuesNoSchema.get("first");
- } catch (UnsupportedOperationException e) {
- exception = e;
- }
-
+ UnsupportedOperationException exception =
+ assertThrows(UnsupportedOperationException.class, () -> fieldValuesNoSchema.get("first"));
assertNotNull(exception);
}
@Test
- public void testGetNonExistentField() {
- IllegalArgumentException exception = null;
- try {
- fieldValues.get("nonexistent");
- } catch (IllegalArgumentException e) {
- exception = e;
- }
-
+ void testGetNonExistentField() {
+ IllegalArgumentException exception =
+ assertThrows(IllegalArgumentException.class, () -> fieldValues.get("nonexistent"));
assertNotNull(exception);
}
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueTest.java
index 4ec527f7c..958e20659 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueTest.java
@@ -16,11 +16,11 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.api.client.util.Data;
import com.google.api.services.bigquery.model.TableCell;
@@ -33,7 +33,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.threeten.extra.PeriodDuration;
public class FieldValueTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ForeignKeyTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ForeignKeyTest.java
index 1ebd93ef4..2dfacda54 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ForeignKeyTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ForeignKeyTest.java
@@ -16,14 +16,14 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ForeignKeyTest {
+class ForeignKeyTest {
private static final TableId TABLE_ID = TableId.of("project", "dataset", "table");
private static final ColumnReference COLUMN_REFERENCE =
@@ -39,7 +39,7 @@ public class ForeignKeyTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareForeignKeyDefinition(FOREIGN_KEY, FOREIGN_KEY.toBuilder().build());
TableId referencedTable = TableId.of("project1", "dataset1", "table1");
ArrayList columnReferences = new ArrayList<>();
@@ -65,7 +65,7 @@ public void testToBuilder() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals("foreign_key", FOREIGN_KEY.getName());
assertEquals(TABLE_ID, FOREIGN_KEY.getReferencedTable());
assertEquals(Collections.singletonList(COLUMN_REFERENCE), FOREIGN_KEY.getColumnReferences());
@@ -80,7 +80,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
ForeignKey foreignKey = FOREIGN_KEY.toBuilder().build();
assertTrue(ForeignKey.fromPb(foreignKey.toPb()) instanceof ForeignKey);
compareForeignKeyDefinition(foreignKey, ForeignKey.fromPb(foreignKey.toPb()));
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FormatOptionsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FormatOptionsTest.java
index d3cfb6e33..e8642e86e 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FormatOptionsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FormatOptionsTest.java
@@ -16,9 +16,9 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class FormatOptionsTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/GoogleSheetsOptionsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/GoogleSheetsOptionsTest.java
index efbee79b6..7aae673d3 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/GoogleSheetsOptionsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/GoogleSheetsOptionsTest.java
@@ -18,7 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class GoogleSheetsOptionsTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/HivePartitioningOptionsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/HivePartitioningOptionsTest.java
index 51baf918b..401ab07b7 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/HivePartitioningOptionsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/HivePartitioningOptionsTest.java
@@ -20,9 +20,9 @@
import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class HivePartitioningOptionsTest {
+class HivePartitioningOptionsTest {
private static final String MODE = "STRING";
private static final String SOURCE_URI_PREFIX = "gs://bucket/path_to_table";
@@ -37,7 +37,7 @@ public class HivePartitioningOptionsTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareHivePartitioningOptions(
HIVE_PARTITIONING_OPTIONS, HIVE_PARTITIONING_OPTIONS.toBuilder().build());
HivePartitioningOptions options = HIVE_PARTITIONING_OPTIONS.toBuilder().setMode("AUTO").build();
@@ -47,13 +47,13 @@ public void testToBuilder() {
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
HivePartitioningOptions options = HivePartitioningOptions.newBuilder().build();
compareHivePartitioningOptions(options, options.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertThat(HIVE_PARTITIONING_OPTIONS.getMode()).isEqualTo(MODE);
assertThat(HIVE_PARTITIONING_OPTIONS.getRequirePartitionFilter())
.isEqualTo(REQUIRE_PARTITION_FILTER);
@@ -61,7 +61,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareHivePartitioningOptions(
HIVE_PARTITIONING_OPTIONS,
HivePartitioningOptions.fromPb(HIVE_PARTITIONING_OPTIONS.toPb()));
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/InsertAllRequestTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/InsertAllRequestTest.java
index 4ee1ca13f..d687e75b3 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/InsertAllRequestTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/InsertAllRequestTest.java
@@ -17,6 +17,7 @@
package com.google.cloud.bigquery;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -24,7 +25,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class InsertAllRequestTest {
@@ -214,11 +215,11 @@ public void testEquals() {
compareInsertAllRequest(INSERT_ALL_REQUEST11, INSERT_ALL_REQUEST11);
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testImmutable() {
- InsertAllRequest.RowToInsert row =
- InsertAllRequest.RowToInsert.of(new HashMap());
- row.getContent().put("zip", "zap");
+ InsertAllRequest.RowToInsert row = InsertAllRequest.RowToInsert.of(new HashMap<>());
+
+ assertThrows(UnsupportedOperationException.class, () -> row.getContent().put("zip", "zap"));
}
@Test
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/InsertAllResponseTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/InsertAllResponseTest.java
index b39066a6a..9b30e2586 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/InsertAllResponseTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/InsertAllResponseTest.java
@@ -16,16 +16,16 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class InsertAllResponseTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobIdTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobIdTest.java
index 05ae7cefe..7934ad120 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobIdTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobIdTest.java
@@ -16,17 +16,17 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class JobIdTest {
+class JobIdTest {
private static final JobId JOB = JobId.of("job");
private static final JobId JOB_COMPLETE = JobId.of("project", "job");
@Test
- public void testOf() {
+ void testOf() {
assertEquals(null, JOB.getProject());
assertEquals("job", JOB.getJob());
assertEquals("project", JOB_COMPLETE.getProject());
@@ -34,19 +34,19 @@ public void testOf() {
}
@Test
- public void testEquals() {
+ void testEquals() {
compareJobs(JOB, JobId.of("job"));
compareJobs(JOB_COMPLETE, JobId.of("project", "job"));
}
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
compareJobs(JOB, JobId.fromPb(JOB.toPb()));
compareJobs(JOB_COMPLETE, JobId.fromPb(JOB_COMPLETE.toPb()));
}
@Test
- public void testSetProjectId() {
+ void testSetProjectId() {
assertEquals(JOB_COMPLETE, JOB.setProjectId("project"));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobInfoTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobInfoTest.java
index 71825f0a5..6c7f9b245 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobInfoTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobInfoTest.java
@@ -16,10 +16,10 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.cloud.bigquery.JobInfo.CreateDisposition;
import com.google.cloud.bigquery.JobInfo.SchemaUpdateOption;
@@ -32,7 +32,7 @@
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class JobInfoTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobStatisticsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobStatisticsTest.java
index 2a1353f5d..289548113 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobStatisticsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobStatisticsTest.java
@@ -17,7 +17,7 @@
package com.google.cloud.bigquery;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.cloud.bigquery.JobStatistics.CopyStatistics;
import com.google.cloud.bigquery.JobStatistics.ExtractStatistics;
@@ -33,7 +33,7 @@
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class JobStatisticsTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobStatusTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobStatusTest.java
index bb463d1ce..1c20b7240 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobStatusTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobStatusTest.java
@@ -16,13 +16,13 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class JobStatusTest {
+class JobStatusTest {
private static final JobStatus.State STATE = JobStatus.State.DONE;
private static final BigQueryError ERROR =
@@ -36,7 +36,7 @@ public class JobStatusTest {
private static final JobStatus JOB_STATUS_INCOMPLETE2 = new JobStatus(STATE, null, null);
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(STATE, JOB_STATUS.getState());
assertEquals(ERROR, JOB_STATUS.getError());
assertEquals(ALL_ERRORS, JOB_STATUS.getExecutionErrors());
@@ -51,7 +51,7 @@ public void testConstructor() {
}
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
compareStatus(JOB_STATUS, JobStatus.fromPb(JOB_STATUS.toPb()));
compareStatus(JOB_STATUS_INCOMPLETE1, JobStatus.fromPb(JOB_STATUS_INCOMPLETE1.toPb()));
compareStatus(JOB_STATUS_INCOMPLETE2, JobStatus.fromPb(JOB_STATUS_INCOMPLETE2.toPb()));
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobTest.java
index e6d249af4..f85c2f76c 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobTest.java
@@ -18,14 +18,14 @@
import static com.google.common.collect.ObjectArrays.concat;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
@@ -42,16 +42,13 @@
import com.google.cloud.bigquery.JobStatus.State;
import com.google.common.collect.ImmutableList;
import java.time.Duration;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.mockito.junit.MockitoRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
-public class JobTest {
+@ExtendWith(MockitoExtension.class)
+class JobTest {
private static final JobId JOB_ID = JobId.of("project", "job");
private static final TableId TABLE_ID1 = TableId.of("dataset", "table1");
@@ -94,15 +91,13 @@ public class JobTest {
.retryOnMessage(BigQueryErrorMessages.RATE_LIMIT_EXCEEDED_MSG)
.build();
- @Rule public MockitoRule rule;
-
private BigQuery bigquery;
private BigQueryOptions mockOptions;
private Job expectedJob;
private Job job;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
bigquery = mock(BigQuery.class);
mockOptions = mock(BigQueryOptions.class);
when(bigquery.getOptions()).thenReturn(mockOptions);
@@ -111,7 +106,7 @@ public void setUp() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
Job builtJob =
new Job.Builder(bigquery, COPY_CONFIGURATION)
.setJobId(JOB_ID)
@@ -135,12 +130,12 @@ public void testBuilder() {
}
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareJob(expectedJob, expectedJob.toBuilder().build());
}
@Test
- public void testExists_True() {
+ void testExists_True() {
BigQuery.JobOption[] expectedOptions = {BigQuery.JobOption.fields()};
when(bigquery.getJob(JOB_INFO.getJobId(), expectedOptions)).thenReturn(expectedJob);
assertTrue(job.exists());
@@ -148,7 +143,7 @@ public void testExists_True() {
}
@Test
- public void testExists_False() {
+ void testExists_False() {
BigQuery.JobOption[] expectedOptions = {BigQuery.JobOption.fields()};
when(bigquery.getJob(JOB_INFO.getJobId(), expectedOptions)).thenReturn(null);
assertFalse(job.exists());
@@ -156,14 +151,14 @@ public void testExists_False() {
}
@Test
- public void testIsDone_True() {
+ void testIsDone_True() {
Job job = expectedJob.toBuilder().setStatus(new JobStatus(JobStatus.State.DONE)).build();
assertTrue(job.isDone());
verify(bigquery, times(0)).getJob(eq(JOB_INFO.getJobId()), any());
}
@Test
- public void testIsDone_False() {
+ void testIsDone_False() {
BigQuery.JobOption[] expectedOptions = {BigQuery.JobOption.fields(BigQuery.JobField.STATUS)};
Job job = expectedJob.toBuilder().setStatus(new JobStatus(JobStatus.State.RUNNING)).build();
when(bigquery.getJob(JOB_INFO.getJobId(), expectedOptions)).thenReturn(job);
@@ -172,7 +167,7 @@ public void testIsDone_False() {
}
@Test
- public void testIsDone_NotExists() {
+ void testIsDone_NotExists() {
BigQuery.JobOption[] expectedOptions = {BigQuery.JobOption.fields(BigQuery.JobField.STATUS)};
Job jobWithRunningState =
expectedJob.toBuilder().setStatus(new JobStatus(JobStatus.State.RUNNING)).build();
@@ -182,7 +177,7 @@ public void testIsDone_NotExists() {
}
@Test
- public void testWaitFor() throws InterruptedException {
+ void testWaitFor() throws InterruptedException {
BigQuery.JobOption[] expectedOptions = {BigQuery.JobOption.fields(BigQuery.JobField.STATUS)};
JobStatus status = mock(JobStatus.class);
when(status.getState()).thenReturn(JobStatus.State.DONE);
@@ -199,7 +194,7 @@ public void testWaitFor() throws InterruptedException {
}
@Test
- public void testWaitForAndGetQueryResultsEmpty() throws InterruptedException {
+ void testWaitForAndGetQueryResultsEmpty() throws InterruptedException {
QueryStatistics jobStatistics =
QueryStatistics.newBuilder()
.setCreationTimestamp(1L)
@@ -243,7 +238,7 @@ public void testWaitForAndGetQueryResultsEmpty() throws InterruptedException {
}
@Test
- public void testWaitForAndGetQueryResultsEmptyWithSchema() throws InterruptedException {
+ void testWaitForAndGetQueryResultsEmptyWithSchema() throws InterruptedException {
QueryStatistics jobStatistics =
QueryStatistics.newBuilder()
.setCreationTimestamp(1L)
@@ -288,7 +283,7 @@ public void testWaitForAndGetQueryResultsEmptyWithSchema() throws InterruptedExc
}
@Test
- public void testWaitForAndGetQueryResults() throws InterruptedException {
+ void testWaitForAndGetQueryResults() throws InterruptedException {
QueryStatistics jobStatistics =
QueryStatistics.newBuilder()
.setCreationTimestamp(1L)
@@ -340,17 +335,14 @@ public void testWaitForAndGetQueryResults() throws InterruptedException {
}
@Test
- public void testWaitForAndGetQueryResults_Unsupported() throws InterruptedException {
- try {
- job.getQueryResults();
- Assert.fail();
- } catch (UnsupportedOperationException expected) {
- Assert.assertNotNull(expected.getMessage());
- }
+ void testWaitForAndGetQueryResults_Unsupported() throws InterruptedException {
+ UnsupportedOperationException expected =
+ assertThrows(UnsupportedOperationException.class, () -> job.getQueryResults());
+ assertNotNull(expected.getMessage());
}
@Test
- public void testWaitFor_Null() throws InterruptedException {
+ void testWaitFor_Null() throws InterruptedException {
BigQuery.JobOption[] expectedOptions = {BigQuery.JobOption.fields(BigQuery.JobField.STATUS)};
when(mockOptions.getClock()).thenReturn(CurrentMillisClock.getDefaultClock());
when(bigquery.getJob(JOB_INFO.getJobId(), expectedOptions)).thenReturn(null);
@@ -359,7 +351,7 @@ public void testWaitFor_Null() throws InterruptedException {
}
@Test
- public void testWaitForWithCheckingPeriod() throws InterruptedException {
+ void testWaitForWithCheckingPeriod() throws InterruptedException {
BigQuery.JobOption[] expectedOptions = {BigQuery.JobOption.fields(BigQuery.JobField.STATUS)};
JobStatus status = mock(JobStatus.class);
when(status.getState()).thenReturn(JobStatus.State.RUNNING);
@@ -381,7 +373,7 @@ public void testWaitForWithCheckingPeriod() throws InterruptedException {
}
@Test
- public void testWaitForWithCheckingPeriod_Null() throws InterruptedException {
+ void testWaitForWithCheckingPeriod_Null() throws InterruptedException {
BigQuery.JobOption[] expectedOptions = {BigQuery.JobOption.fields(BigQuery.JobField.STATUS)};
when(mockOptions.getClock()).thenReturn(CurrentMillisClock.getDefaultClock());
Job runningJob =
@@ -394,24 +386,26 @@ public void testWaitForWithCheckingPeriod_Null() throws InterruptedException {
}
@Test
- public void testWaitForWithTimeout() throws InterruptedException {
+ void testWaitForWithTimeout() throws InterruptedException {
BigQuery.JobOption[] expectedOptions = {BigQuery.JobOption.fields(BigQuery.JobField.STATUS)};
when(mockOptions.getClock()).thenReturn(CurrentMillisClock.getDefaultClock());
Job runningJob =
expectedJob.toBuilder().setStatus(new JobStatus(JobStatus.State.RUNNING)).build();
when(bigquery.getJob(JOB_INFO.getJobId(), expectedOptions)).thenReturn(runningJob);
when(bigquery.getJob(JOB_INFO.getJobId(), expectedOptions)).thenReturn(runningJob);
- try {
- job.waitFor(
- concat(TEST_RETRY_OPTIONS, RetryOption.totalTimeoutDuration(Duration.ofMillis(3))));
- Assert.fail();
- } catch (BigQueryException expected) {
- Assert.assertNotNull(expected.getMessage());
- }
+ BigQueryException expected =
+ assertThrows(
+ BigQueryException.class,
+ () ->
+ job.waitFor(
+ concat(
+ TEST_RETRY_OPTIONS,
+ RetryOption.totalTimeoutDuration(Duration.ofMillis(3)))));
+ assertNotNull(expected.getMessage());
}
@Test
- public void testWaitForWithBigQueryRetryConfig() throws InterruptedException {
+ void testWaitForWithBigQueryRetryConfig() throws InterruptedException {
QueryStatistics jobStatistics =
QueryStatistics.newBuilder()
.setCreationTimestamp(1L)
@@ -453,7 +447,7 @@ public void testWaitForWithBigQueryRetryConfig() throws InterruptedException {
}
@Test
- public void testWaitForWithBigQueryRetryConfigShouldRetry() throws InterruptedException {
+ void testWaitForWithBigQueryRetryConfigShouldRetry() throws InterruptedException {
QueryStatistics jobStatistics =
QueryStatistics.newBuilder()
.setCreationTimestamp(1L)
@@ -504,7 +498,7 @@ public void testWaitForWithBigQueryRetryConfigShouldRetry() throws InterruptedEx
}
@Test
- public void testWaitForWithBigQueryRetryConfigErrorShouldNotRetry() throws InterruptedException {
+ void testWaitForWithBigQueryRetryConfigErrorShouldNotRetry() throws InterruptedException {
QueryStatistics jobStatistics =
QueryStatistics.newBuilder()
.setCreationTimestamp(1L)
@@ -542,19 +536,18 @@ public void testWaitForWithBigQueryRetryConfigErrorShouldNotRetry() throws Inter
.thenThrow(bigQueryException)
.thenReturn(completedQuery);
job = this.job.toBuilder().setConfiguration(DRL_QUERY_CONFIGURATION).build();
- try {
- job.waitFor(TEST_BIGQUERY_RETRY_CONFIG, TEST_RETRY_OPTIONS);
- fail("JobException expected");
- } catch (BigQueryException e) {
- assertNotNull(e.getErrors());
- }
+ BigQueryException e =
+ assertThrows(
+ BigQueryException.class,
+ () -> job.waitFor(TEST_BIGQUERY_RETRY_CONFIG, TEST_RETRY_OPTIONS));
+ assertNotNull(e.getErrors());
// Verify that getQueryResults is attempted only once and not retried since the error message
// does not match.
verify(bigquery, times(1)).getQueryResults(jobInfo.getJobId(), Job.DEFAULT_QUERY_WAIT_OPTIONS);
}
@Test
- public void testReload() {
+ void testReload() {
JobInfo updatedInfo = JOB_INFO.toBuilder().setEtag("etag").build();
Job expectedJob = new Job(bigquery, new JobInfo.BuilderImpl(updatedInfo));
when(bigquery.getJob(JOB_INFO.getJobId())).thenReturn(expectedJob);
@@ -564,7 +557,7 @@ public void testReload() {
}
@Test
- public void testReloadJobException() {
+ void testReloadJobException() {
JobInfo updatedInfo = JOB_INFO.toBuilder().setEtag("etag").build();
Job expectedJob = new Job(bigquery, new JobInfo.BuilderImpl(updatedInfo));
BigQueryError bigQueryError = new BigQueryError("invalidQuery", "US", "invalidQuery");
@@ -573,23 +566,19 @@ public void testReloadJobException() {
ImmutableList bigQueryErrorList = ImmutableList.of(bigQueryError);
BigQueryException bigQueryException = new BigQueryException(bigQueryErrorList);
when(bigquery.getJob(JOB_INFO.getJobId())).thenReturn(expectedJob).thenThrow(bigQueryException);
- try {
- job.reload();
- fail("JobException expected");
- } catch (BigQueryException e) {
- assertNotNull(e.getErrors());
- }
+ BigQueryException e = assertThrows(BigQueryException.class, () -> job.reload());
+ assertNotNull(e.getErrors());
}
@Test
- public void testReloadNull() {
+ void testReloadNull() {
when(bigquery.getJob(JOB_INFO.getJobId())).thenReturn(null);
assertNull(job.reload());
verify(bigquery).getJob(JOB_INFO.getJobId());
}
@Test
- public void testReloadWithOptions() {
+ void testReloadWithOptions() {
JobInfo updatedInfo = JOB_INFO.toBuilder().setEtag("etag").build();
Job expectedJob = new Job(bigquery, new JobInfo.BuilderImpl(updatedInfo));
when(bigquery.getJob(JOB_INFO.getJobId(), BigQuery.JobOption.fields())).thenReturn(expectedJob);
@@ -599,24 +588,24 @@ public void testReloadWithOptions() {
}
@Test
- public void testCancel() {
+ void testCancel() {
when(bigquery.cancel(JOB_INFO.getJobId())).thenReturn(true);
assertTrue(job.cancel());
verify(bigquery).cancel(JOB_INFO.getJobId());
}
@Test
- public void testBigQuery() {
+ void testBigQuery() {
assertSame(bigquery, expectedJob.getBigQuery());
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareJob(expectedJob, Job.fromPb(bigquery, expectedJob.toPb()));
}
@Test
- public void testToAndFromPbWithoutConfiguration() {
+ void testToAndFromPbWithoutConfiguration() {
assertNotEquals(expectedJob, bigquery);
compareJob(expectedJob, Job.fromPb(bigquery, expectedJob.toPb()));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/LoadJobConfigurationTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/LoadJobConfigurationTest.java
index d987eb28e..1a9db2995 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/LoadJobConfigurationTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/LoadJobConfigurationTest.java
@@ -16,7 +16,7 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.cloud.bigquery.JobInfo.CreateDisposition;
import com.google.cloud.bigquery.JobInfo.SchemaUpdateOption;
@@ -28,9 +28,9 @@
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class LoadJobConfigurationTest {
+class LoadJobConfigurationTest {
private static final String TEST_PROJECT_ID = "test-project-id";
private static final CsvOptions CSV_OPTIONS =
@@ -168,7 +168,7 @@ public class LoadJobConfigurationTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareLoadJobConfiguration(LOAD_CONFIGURATION_CSV, LOAD_CONFIGURATION_CSV.toBuilder().build());
LoadJobConfiguration configurationCSV =
LOAD_CONFIGURATION_CSV.toBuilder()
@@ -200,7 +200,7 @@ public void testToBuilder() {
}
@Test
- public void testOf() {
+ void testOf() {
LoadJobConfiguration configuration = LoadJobConfiguration.of(TABLE_ID, SOURCE_URIS);
assertEquals(TABLE_ID, configuration.getDestinationTable());
assertEquals(SOURCE_URIS, configuration.getSourceUris());
@@ -220,13 +220,13 @@ public void testOf() {
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
LoadJobConfiguration configuration = LoadJobConfiguration.of(TABLE_ID, SOURCE_URIS);
compareLoadJobConfiguration(configuration, configuration.toBuilder().build());
}
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
compareLoadJobConfiguration(
LOAD_CONFIGURATION_CSV, LoadJobConfiguration.fromPb(LOAD_CONFIGURATION_CSV.toPb()));
LoadJobConfiguration configuration = LoadJobConfiguration.of(TABLE_ID, SOURCE_URIS);
@@ -234,13 +234,13 @@ public void testToPbAndFromPb() {
}
@Test
- public void testSetProjectId() {
+ void testSetProjectId() {
LoadConfiguration configuration = LOAD_CONFIGURATION_CSV.setProjectId(TEST_PROJECT_ID);
assertEquals(TEST_PROJECT_ID, configuration.getDestinationTable().getProject());
}
@Test
- public void testSetProjectIdDoNotOverride() {
+ void testSetProjectIdDoNotOverride() {
LoadConfiguration configuration =
LOAD_CONFIGURATION_CSV.toBuilder()
.setDestinationTable(TABLE_ID.setProjectId(TEST_PROJECT_ID))
@@ -250,7 +250,7 @@ public void testSetProjectIdDoNotOverride() {
}
@Test
- public void testGetType() {
+ void testGetType() {
assertEquals(JobConfiguration.Type.LOAD, LOAD_CONFIGURATION_CSV.getType());
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/MaterializedViewDefinitionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/MaterializedViewDefinitionTest.java
index eef4324a0..00ac64937 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/MaterializedViewDefinitionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/MaterializedViewDefinitionTest.java
@@ -16,11 +16,11 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.ImmutableList;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class MaterializedViewDefinitionTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelIdTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelIdTest.java
index 266a754c4..98df2d5f2 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelIdTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelIdTest.java
@@ -16,17 +16,17 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ModelIdTest {
+class ModelIdTest {
public static final ModelId MODEL = ModelId.of("dataset", "model");
public static final ModelId MODEL_COMPLETE = ModelId.of("project", "dataset", "model");
@Test
- public void testOf() {
+ void testOf() {
assertEquals(null, MODEL.getProject());
assertEquals("dataset", MODEL.getDataset());
assertEquals("model", MODEL.getModel());
@@ -37,19 +37,19 @@ public void testOf() {
}
@Test
- public void testEquals() {
+ void testEquals() {
compareModelIds(MODEL, ModelId.of("dataset", "model"));
compareModelIds(MODEL_COMPLETE, ModelId.of("project", "dataset", "model"));
}
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
compareModelIds(MODEL, ModelId.fromPb(MODEL.toPb()));
compareModelIds(MODEL_COMPLETE, ModelId.fromPb(MODEL_COMPLETE.toPb()));
}
@Test
- public void testSetProjectId() {
+ void testSetProjectId() {
ModelId differentProjectTable = ModelId.of("differentProject", "dataset", "model");
assertEquals(differentProjectTable, MODEL.setProjectId("differentProject"));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelInfoTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelInfoTest.java
index 87fa8bbf5..be0e1ff23 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelInfoTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelInfoTest.java
@@ -15,16 +15,16 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.api.services.bigquery.model.TrainingOptions;
import com.google.api.services.bigquery.model.TrainingRun;
import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ModelInfoTest {
+class ModelInfoTest {
private static final ModelId MODEL_ID = ModelId.of("dataset", "model");
private static final String ETAG = "etag";
@@ -57,18 +57,18 @@ public class ModelInfoTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareModelInfo(MODEL_INFO, MODEL_INFO.toBuilder().build());
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
ModelInfo modelInfo = ModelInfo.of(MODEL_ID);
assertEquals(modelInfo, modelInfo.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(ETAG, MODEL_INFO.getEtag());
assertEquals(CREATION_TIME, MODEL_INFO.getCreationTime());
assertEquals(LAST_MODIFIED_TIME, MODEL_INFO.getLastModifiedTime());
@@ -81,7 +81,7 @@ public void testBuilder() {
}
@Test
- public void testOf() {
+ void testOf() {
ModelInfo modelInfo = ModelInfo.of(MODEL_ID);
assertEquals(MODEL_ID, modelInfo.getModelId());
assertNull(modelInfo.getEtag());
@@ -98,12 +98,12 @@ public void testOf() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareModelInfo(MODEL_INFO, ModelInfo.fromPb(MODEL_INFO.toPb()));
}
@Test
- public void testSetProjectId() {
+ void testSetProjectId() {
assertEquals("project", MODEL_INFO.setProjectId("project").getModelId().getProject());
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelTableDefinitionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelTableDefinitionTest.java
index 62b2cfe7d..444d47c09 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelTableDefinitionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelTableDefinitionTest.java
@@ -16,14 +16,14 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
-public class ModelTableDefinitionTest {
+class ModelTableDefinitionTest {
private static final String LOCATION = "US";
private static final Long NUM_BYTES = 14L;
@@ -52,34 +52,33 @@ public class ModelTableDefinitionTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareModelTableDefinition(MODEL_TABLE_DEFINITION, MODEL_TABLE_DEFINITION.toBuilder().build());
}
@Test
- public void testTypeNullPointerException() {
- try {
- MODEL_TABLE_DEFINITION.toBuilder().setType(null).build();
- fail();
- } catch (NullPointerException ex) {
- assertNotNull(ex.getMessage());
- }
+ void testTypeNullPointerException() {
+ NullPointerException ex =
+ Assertions.assertThrows(
+ NullPointerException.class,
+ () -> MODEL_TABLE_DEFINITION.toBuilder().setType(null).build());
+ assertNotNull(ex.getMessage());
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
ModelTableDefinition modelTableDefinition = ModelTableDefinition.newBuilder().build();
assertEquals(modelTableDefinition, modelTableDefinition.toBuilder().build());
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
assertEquals(
MODEL_TABLE_DEFINITION, ModelTableDefinition.fromPb(MODEL_TABLE_DEFINITION.toPb()));
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(MODEL_TABLE_DEFINITION.getSchema(), TABLE_SCHEMA);
assertEquals(MODEL_TABLE_DEFINITION.getType(), TableDefinition.Type.MODEL);
assertEquals(MODEL_TABLE_DEFINITION.getLocation(), LOCATION);
@@ -87,12 +86,12 @@ public void testBuilder() {
}
@Test
- public void testEquals() {
+ void testEquals() {
assertEquals(MODEL_TABLE_DEFINITION, MODEL_TABLE_DEFINITION);
}
@Test
- public void testNotEquals() {
+ void testNotEquals() {
assertNotEquals(MODEL_TABLE_DEFINITION, LOCATION);
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelTest.java
index 756277adc..acdbdfbfe 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ModelTest.java
@@ -16,25 +16,23 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.mockito.junit.MockitoRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
-public class ModelTest {
+@ExtendWith(MockitoExtension.class)
+class ModelTest {
private static final ModelId MODEL_ID = ModelId.of("dataset", "model");
private static final String ETAG = "etag";
@@ -54,15 +52,13 @@ public class ModelTest {
.setFriendlyName(FRIENDLY_NAME)
.build();
- @Rule public MockitoRule rule;
-
private BigQuery bigquery;
private BigQueryOptions mockOptions;
private Model expectedModel;
private Model model;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
bigquery = mock(BigQuery.class);
mockOptions = mock(BigQueryOptions.class);
when(bigquery.getOptions()).thenReturn(mockOptions);
@@ -71,7 +67,7 @@ public void setUp() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
Model builtModel =
new Model.Builder(bigquery, MODEL_ID)
.setEtag(ETAG)
@@ -86,12 +82,12 @@ public void testBuilder() {
}
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareModelInfo(expectedModel, expectedModel.toBuilder().build());
}
@Test
- public void testExists_True() {
+ void testExists_True() {
BigQuery.ModelOption[] expectedOptions = {BigQuery.ModelOption.fields()};
when(bigquery.getModel(MODEL_INFO.getModelId(), expectedOptions)).thenReturn(expectedModel);
assertTrue(model.exists());
@@ -99,7 +95,7 @@ public void testExists_True() {
}
@Test
- public void testExists_False() {
+ void testExists_False() {
BigQuery.ModelOption[] expectedOptions = {BigQuery.ModelOption.fields()};
when(bigquery.getModel(MODEL_INFO.getModelId(), expectedOptions)).thenReturn(null);
assertFalse(model.exists());
@@ -107,7 +103,7 @@ public void testExists_False() {
}
@Test
- public void testReload() {
+ void testReload() {
ModelInfo updatedInfo = MODEL_INFO.toBuilder().setDescription("Description").build();
Model expectedModel = new Model(bigquery, new ModelInfo.BuilderImpl(updatedInfo));
when(bigquery.getModel(MODEL_INFO.getModelId())).thenReturn(expectedModel);
@@ -117,14 +113,14 @@ public void testReload() {
}
@Test
- public void testReloadNull() {
+ void testReloadNull() {
when(bigquery.getModel(MODEL_INFO.getModelId())).thenReturn(null);
assertNull(model.reload());
verify(bigquery).getModel(MODEL_INFO.getModelId());
}
@Test
- public void testUpdate() {
+ void testUpdate() {
Model expectedUpdatedModel = expectedModel.toBuilder().setDescription("Description").build();
when(bigquery.update(eq(expectedModel))).thenReturn(expectedUpdatedModel);
Model actualUpdatedModel = model.update();
@@ -133,7 +129,7 @@ public void testUpdate() {
}
@Test
- public void testUpdateWithOptions() {
+ void testUpdateWithOptions() {
Model expectedUpdatedModel = expectedModel.toBuilder().setDescription("Description").build();
when(bigquery.update(eq(expectedModel), eq(BigQuery.ModelOption.fields())))
.thenReturn(expectedUpdatedModel);
@@ -143,14 +139,14 @@ public void testUpdateWithOptions() {
}
@Test
- public void testDeleteTrue() {
+ void testDeleteTrue() {
when(bigquery.delete(MODEL_INFO.getModelId())).thenReturn(true);
assertTrue(model.delete());
verify(bigquery).delete(MODEL_INFO.getModelId());
}
@Test
- public void testDeleteFalse() {
+ void testDeleteFalse() {
when(bigquery.delete(MODEL_INFO.getModelId())).thenReturn(false);
assertFalse(model.delete());
verify(bigquery).delete(MODEL_INFO.getModelId());
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/OptionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/OptionTest.java
index 58f314866..b25f06706 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/OptionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/OptionTest.java
@@ -16,13 +16,13 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.cloud.bigquery.spi.v2.BigQueryRpc;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class OptionTest {
@@ -54,11 +54,6 @@ public void testConstructor() {
Option option = new Option(RPC_OPTION, null) {};
assertEquals(RPC_OPTION, option.getRpcOption());
assertNull(option.getValue());
- try {
- new Option(null, VALUE) {};
- Assert.fail();
- } catch (NullPointerException expected) {
-
- }
+ Assertions.assertThrows(NullPointerException.class, () -> new Option(null, VALUE) {});
}
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ParquetOptionsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ParquetOptionsTest.java
index c70ac3355..b5ace223f 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ParquetOptionsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ParquetOptionsTest.java
@@ -17,9 +17,9 @@
package com.google.cloud.bigquery;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ParquetOptionsTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PolicyHelperTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PolicyHelperTest.java
index 291df79fd..ac05a2c1f 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PolicyHelperTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PolicyHelperTest.java
@@ -15,16 +15,16 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.api.services.bigquery.model.Binding;
import com.google.cloud.Identity;
import com.google.cloud.Policy;
import com.google.cloud.Role;
import com.google.common.collect.ImmutableList;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class PolicyHelperTest {
+class PolicyHelperTest {
public static final String ETAG = "etag";
public static final String ROLE1 = "roles/bigquery.admin";
@@ -58,7 +58,7 @@ public class PolicyHelperTest {
Policy.newBuilder().setEtag(ETAG).setVersion(1).build();
@Test
- public void testConversionWithBindings() {
+ void testConversionWithBindings() {
assertEquals(IAM_POLICY, PolicyHelper.convertFromApiPolicy(API_POLICY));
assertEquals(API_POLICY, PolicyHelper.convertToApiPolicy(IAM_POLICY));
assertEquals(
@@ -68,7 +68,7 @@ public void testConversionWithBindings() {
}
@Test
- public void testConversionNoBindings() {
+ void testConversionNoBindings() {
assertEquals(IAM_POLICY_NO_BINDINGS, PolicyHelper.convertFromApiPolicy(API_POLICY_NO_BINDINGS));
assertEquals(API_POLICY_NO_BINDINGS, PolicyHelper.convertToApiPolicy(IAM_POLICY_NO_BINDINGS));
assertEquals(
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PolicyTagsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PolicyTagsTest.java
index f23cb36c2..a94e4324b 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PolicyTagsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PolicyTagsTest.java
@@ -16,13 +16,13 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class PolicyTagsTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PrimaryKeyTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PrimaryKeyTest.java
index 2de87a025..702ca5cb4 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PrimaryKeyTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/PrimaryKeyTest.java
@@ -16,19 +16,19 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class PrimaryKeyTest {
+class PrimaryKeyTest {
private static final List COLUMNS = Arrays.asList("column1", "column2");
private static final PrimaryKey PRIMARY_KEY = PrimaryKey.newBuilder().setColumns(COLUMNS).build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
comparePrimaryKeyDefinition(PRIMARY_KEY, PRIMARY_KEY.toBuilder().build());
PrimaryKey primaryKey =
PRIMARY_KEY.toBuilder().setColumns(Arrays.asList("col1", "col2", "col3")).build();
@@ -36,14 +36,14 @@ public void testToBuilder() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(COLUMNS, PRIMARY_KEY.getColumns());
PrimaryKey primaryKey = PRIMARY_KEY.newBuilder().setColumns(COLUMNS).build();
assertEquals(PRIMARY_KEY, primaryKey);
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
PrimaryKey primaryKey = PRIMARY_KEY.toBuilder().build();
assertTrue(PrimaryKey.fromPb(primaryKey.toPb()) instanceof PrimaryKey);
comparePrimaryKeyDefinition(primaryKey, PrimaryKey.fromPb(primaryKey.toPb()));
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryJobConfigurationTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryJobConfigurationTest.java
index f25aa47ed..7fe41daa0 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryJobConfigurationTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryJobConfigurationTest.java
@@ -16,9 +16,9 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.cloud.bigquery.JobInfo.CreateDisposition;
import com.google.cloud.bigquery.JobInfo.SchemaUpdateOption;
@@ -31,7 +31,7 @@
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class QueryJobConfigurationTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryParameterValueTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryParameterValueTest.java
index 25649388e..276234246 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryParameterValueTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryParameterValueTest.java
@@ -18,7 +18,7 @@
import static com.google.cloud.bigquery.QueryParameterValue.TIMESTAMP_FORMATTER;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.api.services.bigquery.model.QueryParameterType;
import com.google.common.collect.ImmutableMap;
@@ -32,8 +32,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.threeten.extra.PeriodDuration;
public class QueryParameterValueTest {
@@ -58,12 +57,11 @@ public void testBuilder() {
@Test
public void testTypeNullPointerException() {
- try {
- QUERY_PARAMETER_VALUE.toBuilder().setType(null).build();
- Assert.fail();
- } catch (NullPointerException ex) {
- assertThat(ex).isNotNull();
- }
+ NullPointerException ex =
+ assertThrows(
+ NullPointerException.class,
+ () -> QUERY_PARAMETER_VALUE.toBuilder().setType(null).build());
+ assertThat(ex).isNotNull();
}
@Test
@@ -407,10 +405,12 @@ public void testStandardDate() throws ParseException {
assertThat(value.getArrayValues()).isNull();
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testInvalidDate() {
// not supposed to have the time
- QueryParameterValue.date("2014-08-19 12:41:35.220000");
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> QueryParameterValue.date("2014-08-19 12:41:35.220000"));
}
@Test
@@ -422,10 +422,12 @@ public void testTime() {
assertThat(value.getArrayValues()).isNull();
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testInvalidTime() {
// not supposed to have the date
- QueryParameterValue.time("2014-08-19 12:41:35.220000");
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> QueryParameterValue.time("2014-08-19 12:41:35.220000"));
}
@Test
@@ -437,10 +439,10 @@ public void testDateTime() {
assertThat(value.getArrayValues()).isNull();
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testInvalidDateTime() {
// missing the time
- QueryParameterValue.dateTime("2014-08-19");
+ assertThrows(IllegalArgumentException.class, () -> QueryParameterValue.dateTime("2014-08-19"));
}
@Test
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryRequestInfoTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryRequestInfoTest.java
index 866134677..be1f0e198 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryRequestInfoTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryRequestInfoTest.java
@@ -16,10 +16,10 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.api.services.bigquery.model.QueryRequest;
import com.google.cloud.bigquery.JobInfo.CreateDisposition;
@@ -31,7 +31,7 @@
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class QueryRequestInfoTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryStageTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryStageTest.java
index bc7d6083b..30eeb90ad 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryStageTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/QueryStageTest.java
@@ -16,16 +16,16 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import com.google.api.services.bigquery.model.ExplainQueryStep;
import com.google.cloud.bigquery.QueryStage.QueryStep;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class QueryStageTest {
+class QueryStageTest {
private static final List SUBSTEPS1 = ImmutableList.of("substep1", "substep2");
private static final List SUBSTEPS2 = ImmutableList.of("substep3", "substep4");
@@ -96,7 +96,7 @@ public class QueryStageTest {
.build();
@Test
- public void testQueryStepConstructor() {
+ void testQueryStepConstructor() {
assertEquals("KIND", QUERY_STEP1.getName());
assertEquals("KIND", QUERY_STEP2.getName());
assertEquals(SUBSTEPS1, QUERY_STEP1.getSubsteps());
@@ -104,7 +104,7 @@ public void testQueryStepConstructor() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(COMPLETED_PARALLEL_INPUTS, QUERY_STAGE.getCompletedParallelInputs());
assertEquals(COMPUTE_MS_AVG, QUERY_STAGE.getComputeMsAvg());
assertEquals(COMPUTE_MS_MAX, QUERY_STAGE.getComputeMsMax());
@@ -138,7 +138,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareQueryStep(QUERY_STEP1, QueryStep.fromPb(QUERY_STEP1.toPb()));
compareQueryStep(QUERY_STEP2, QueryStep.fromPb(QUERY_STEP2.toPb()));
compareQueryStage(QUERY_STAGE, QueryStage.fromPb(QUERY_STAGE.toPb()));
@@ -149,14 +149,14 @@ public void testToAndFromPb() {
}
@Test
- public void testEquals() {
+ void testEquals() {
compareQueryStep(QUERY_STEP1, QUERY_STEP1);
compareQueryStep(QUERY_STEP2, QUERY_STEP2);
compareQueryStage(QUERY_STAGE, QUERY_STAGE);
}
@Test
- public void testNotEquals() {
+ void testNotEquals() {
assertNotEquals(QUERY_STAGE, QUERY_STEP1);
assertNotEquals(QUERY_STEP1, QUERY_STAGE);
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RangeTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RangeTest.java
index 2d98376b3..b72b4b70c 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RangeTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RangeTest.java
@@ -15,11 +15,11 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class RangeTest {
private static final Range RANGE_DATE =
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RemoteFunctionOptionsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RemoteFunctionOptionsTest.java
index 8ee0e4564..a3559f5cf 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RemoteFunctionOptionsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RemoteFunctionOptionsTest.java
@@ -15,13 +15,13 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class RemoteFunctionOptionsTest {
+class RemoteFunctionOptionsTest {
private static final String endpoint = "https://aaabbbccc-uc.a.run.app";
private static final String connection =
"projects/{projectId}/locations/{locationId}/connections/{connectionId}";
@@ -43,13 +43,13 @@ public class RemoteFunctionOptionsTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareRemoteFunctionOptions(
REMOTE_FUNCTION_OPTIONS, REMOTE_FUNCTION_OPTIONS.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(endpoint, REMOTE_FUNCTION_OPTIONS.getEndpoint());
assertEquals(connection, REMOTE_FUNCTION_OPTIONS.getConnection());
assertEquals(userDefinedContext, REMOTE_FUNCTION_OPTIONS.getUserDefinedContext());
@@ -57,7 +57,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareRemoteFunctionOptions(
REMOTE_FUNCTION_OPTIONS, RemoteFunctionOptions.fromPb(REMOTE_FUNCTION_OPTIONS.toPb()));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineArgumentTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineArgumentTest.java
index 909d5981d..31a2c56de 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineArgumentTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineArgumentTest.java
@@ -15,9 +15,9 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class RoutineArgumentTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineIdTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineIdTest.java
index 94a19fbfd..2800f3caa 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineIdTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineIdTest.java
@@ -15,9 +15,9 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class RoutineIdTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineInfoTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineInfoTest.java
index 145dc8914..f191cbedd 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineInfoTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineInfoTest.java
@@ -15,14 +15,14 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class RoutineInfoTest {
+class RoutineInfoTest {
private static final RoutineId ROUTINE_ID = RoutineId.of("dataset", "routine");
private static final String ETAG = "etag";
@@ -68,18 +68,18 @@ public class RoutineInfoTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareRoutineInfo(ROUTINE_INFO, ROUTINE_INFO.toBuilder().build());
}
@Test
- public void testBuilderIncomplete() {
+ void testBuilderIncomplete() {
RoutineInfo routineInfo = RoutineInfo.of(ROUTINE_ID);
assertEquals(routineInfo, routineInfo.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(ROUTINE_ID, ROUTINE_INFO.getRoutineId());
assertEquals(ETAG, ROUTINE_INFO.getEtag());
assertEquals(ROUTINE_TYPE, ROUTINE_INFO.getRoutineType());
@@ -96,7 +96,7 @@ public void testBuilder() {
}
@Test
- public void testOf() {
+ void testOf() {
RoutineInfo routineInfo = RoutineInfo.of(ROUTINE_ID);
assertEquals(ROUTINE_ID, ROUTINE_INFO.getRoutineId());
assertNull(routineInfo.getEtag());
@@ -114,12 +114,12 @@ public void testOf() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareRoutineInfo(ROUTINE_INFO, RoutineInfo.fromPb(ROUTINE_INFO.toPb()));
}
@Test
- public void testSetProjectId() {
+ void testSetProjectId() {
assertEquals("project", ROUTINE_INFO.setProjectId("project").getRoutineId().getProject());
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineTest.java
index eaf142012..839bfe5e6 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/RoutineTest.java
@@ -15,11 +15,11 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -29,14 +29,12 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.mockito.junit.MockitoRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class RoutineTest {
private static final RoutineId ROUTINE_ID = RoutineId.of("dataset", "routine");
@@ -116,15 +114,13 @@ public class RoutineTest {
.setReturnTableType(RETURN_TABLE_TYPE)
.build();
- @Rule public MockitoRule rule;
-
private BigQuery bigquery;
private BigQueryOptions mockOptions;
private Routine expectedRoutine;
private Routine expectedRoutineTvf;
private Routine routine;
- @Before
+ @BeforeEach
public void setUp() {
bigquery = mock(BigQuery.class);
mockOptions = mock(BigQueryOptions.class);
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SchemaTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SchemaTest.java
index 7f53680e6..9750fd7bd 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SchemaTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SchemaTest.java
@@ -16,14 +16,14 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.api.services.bigquery.model.TableSchema;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class SchemaTest {
+class SchemaTest {
private static PolicyTags POLICY_TAGS =
PolicyTags.newBuilder().setNames(ImmutableList.of("someTag")).build();
@@ -53,12 +53,12 @@ public class SchemaTest {
private static final Schema TABLE_SCHEMA = Schema.of(FIELDS);
@Test
- public void testOf() {
+ void testOf() {
compareTableSchema(TABLE_SCHEMA, Schema.of(FIELDS));
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareTableSchema(TABLE_SCHEMA, Schema.fromPb(TABLE_SCHEMA.toPb()));
}
@@ -68,7 +68,7 @@ private void compareTableSchema(Schema expected, Schema value) {
}
@Test
- public void testEmptySchema() {
+ void testEmptySchema() {
TableSchema tableSchema = new TableSchema();
Schema schema = Schema.fromPb(tableSchema);
assertEquals(0, schema.getFields().size());
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SnapshotTableDefinitionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SnapshotTableDefinitionTest.java
index c739bcf5a..defcd9cb3 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SnapshotTableDefinitionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/SnapshotTableDefinitionTest.java
@@ -16,12 +16,12 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class SnapshotTableDefinitionTest {
+class SnapshotTableDefinitionTest {
private static final TableId BASE_TABLE_ID = TableId.of("DATASET_NAME", "BASE_TABLE_NAME");
private static final String SNAPSHOT_TIME = "2021-05-19T11:32:26.553Z";
@@ -32,7 +32,7 @@ public class SnapshotTableDefinitionTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareSnapshotTableDefinition(
SNAPSHOTTABLE_DEFINITION, SNAPSHOTTABLE_DEFINITION.toBuilder().build());
SnapshotTableDefinition snapshotTableDefinition =
@@ -41,7 +41,7 @@ public void testToBuilder() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(TableDefinition.Type.SNAPSHOT, SNAPSHOTTABLE_DEFINITION.getType());
assertEquals(BASE_TABLE_ID, SNAPSHOTTABLE_DEFINITION.getBaseTableId());
assertEquals(SNAPSHOT_TIME, SNAPSHOTTABLE_DEFINITION.getSnapshotTime());
@@ -54,7 +54,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
SnapshotTableDefinition snapshotTableDefinition = SNAPSHOTTABLE_DEFINITION.toBuilder().build();
assertTrue(
TableDefinition.fromPb(snapshotTableDefinition.toPb()) instanceof SnapshotTableDefinition);
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLDataTypeTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLDataTypeTest.java
index 635a75612..ffc631118 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLDataTypeTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLDataTypeTest.java
@@ -15,13 +15,13 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class StandardSQLDataTypeTest {
+class StandardSQLDataTypeTest {
private static final String STRING_TYPEKIND = "STRING";
private static final String ARRAY_TYPEKIND = "ARRAY";
private static final String STRUCT_TYPEKIND = "STRUCT";
@@ -42,7 +42,7 @@ public class StandardSQLDataTypeTest {
StandardSQLDataType.newBuilder(STRUCT_TYPEKIND).setStructType(STRUCT_TYPE).build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareStandardSQLDataType(STRING_DATA_TYPE, STRING_DATA_TYPE.toBuilder().build());
compareStandardSQLDataType(
ARRAY_OF_STRING_DATA_TYPE, ARRAY_OF_STRING_DATA_TYPE.toBuilder().build());
@@ -50,7 +50,7 @@ public void testToBuilder() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(STRING_TYPEKIND, STRING_DATA_TYPE.getTypeKind());
assertEquals(ARRAY_TYPEKIND, ARRAY_OF_STRING_DATA_TYPE.getTypeKind());
assertEquals(STRING_DATA_TYPE, ARRAY_OF_STRING_DATA_TYPE.getArrayElementType());
@@ -58,7 +58,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareStandardSQLDataType(
ARRAY_OF_STRING_DATA_TYPE, StandardSQLDataType.fromPb(ARRAY_OF_STRING_DATA_TYPE.toPb()));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLFieldTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLFieldTest.java
index 904ed8028..5e3af997d 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLFieldTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLFieldTest.java
@@ -15,9 +15,9 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class StandardSQLFieldTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLStructTypeTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLStructTypeTest.java
index d4fa86950..ab88de3f0 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLStructTypeTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLStructTypeTest.java
@@ -15,13 +15,13 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class StandardSQLStructTypeTest {
+class StandardSQLStructTypeTest {
private static final StandardSQLField FIELD_1 =
StandardSQLField.newBuilder("FIELD_1", StandardSQLDataType.newBuilder("STRING").build())
@@ -35,18 +35,18 @@ public class StandardSQLStructTypeTest {
StandardSQLStructType.newBuilder(FIELD_LIST).build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareStandardSQLStructType(STRUCT_TYPE, STRUCT_TYPE.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(FIELD_1, STRUCT_TYPE.getFields().get(0));
assertEquals(FIELD_2, STRUCT_TYPE.getFields().get(1));
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareStandardSQLStructType(STRUCT_TYPE, StandardSQLStructType.fromPb(STRUCT_TYPE.toPb()));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLTableTypeTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLTableTypeTest.java
index 2ed6e3535..ce5a4992c 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLTableTypeTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardSQLTableTypeTest.java
@@ -16,11 +16,11 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class StandardSQLTableTypeTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardTableDefinitionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardTableDefinitionTest.java
index 8fbe3cefe..6ff0a366d 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardTableDefinitionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/StandardTableDefinitionTest.java
@@ -16,12 +16,12 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.api.services.bigquery.model.Streamingbuffer;
import com.google.api.services.bigquery.model.Table;
@@ -29,7 +29,7 @@
import com.google.cloud.bigquery.StandardTableDefinition.StreamingBuffer;
import com.google.common.collect.ImmutableList;
import com.google.common.truth.Truth;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class StandardTableDefinitionTest {
@@ -131,12 +131,10 @@ public void testBuilder() {
@Test
public void testTypeNullPointerException() {
- try {
- TABLE_DEFINITION.toBuilder().setType(null).build();
- fail();
- } catch (NullPointerException ex) {
- assertNotNull(ex.getMessage());
- }
+ NullPointerException ex =
+ assertThrows(
+ NullPointerException.class, () -> TABLE_DEFINITION.toBuilder().setType(null).build());
+ assertNotNull(ex.getMessage());
}
@Test
@@ -183,15 +181,12 @@ public void testFromPbWithUnexpectedTimePartitioningTypeRaisesInvalidArgumentExc
.setTableId("ILLEGAL_ARG_TEST_TABLE"))
.setTimePartitioning(
new com.google.api.services.bigquery.model.TimePartitioning().setType("GHURRY"));
- try {
- StandardTableDefinition.fromPb(invalidTable);
- } catch (IllegalArgumentException ie) {
- Truth.assertThat(ie.getMessage())
- .contains(
- "Illegal Argument - Got unexpected time partitioning GHURRY in project ILLEGAL_ARG_TEST_PROJECT in dataset ILLEGAL_ARG_TEST_DATASET in table ILLEGAL_ARG_TEST_TABLE");
- return;
- }
- fail("testFromPb illegal argument exception did not throw!");
+ IllegalArgumentException ie =
+ assertThrows(
+ IllegalArgumentException.class, () -> StandardTableDefinition.fromPb(invalidTable));
+ Truth.assertThat(ie.getMessage())
+ .contains(
+ "Illegal Argument - Got unexpected time partitioning GHURRY in project ILLEGAL_ARG_TEST_PROJECT in dataset ILLEGAL_ARG_TEST_DATASET in table ILLEGAL_ARG_TEST_TABLE");
}
@Test
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableConstraintsTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableConstraintsTest.java
index 7d0f57ef7..b074b2f22 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableConstraintsTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableConstraintsTest.java
@@ -16,16 +16,16 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class TableConstraintsTest {
+class TableConstraintsTest {
private static final List COLUMNS_PK = Arrays.asList("column1", "column2");
private static final PrimaryKey PRIMARY_KEY =
PrimaryKey.newBuilder().setColumns(COLUMNS_PK).build();
@@ -50,7 +50,7 @@ public class TableConstraintsTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareTableConstraintsDefinition(TABLE_CONSTRAINTS, TABLE_CONSTRAINTS.toBuilder().build());
List columnsPk = Arrays.asList("col1", "col2", "col3");
PrimaryKey primaryKey = PrimaryKey.newBuilder().setColumns(columnsPk).build();
@@ -90,7 +90,7 @@ public void testToBuilder() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(Collections.singletonList(FOREIGN_KEY), TABLE_CONSTRAINTS.getForeignKeys());
assertEquals(PRIMARY_KEY, TABLE_CONSTRAINTS.getPrimaryKey());
TableConstraints tableConstraints =
@@ -103,7 +103,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
TableConstraints tableConstraints = TABLE_CONSTRAINTS.toBuilder().build();
assertTrue(TableConstraints.fromPb(tableConstraints.toPb()) instanceof TableConstraints);
compareTableConstraintsDefinition(
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableDataWriteChannelTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableDataWriteChannelTest.java
index a90b5c4d7..8752b2708 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableDataWriteChannelTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableDataWriteChannelTest.java
@@ -16,11 +16,11 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
@@ -39,15 +39,17 @@
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Random;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
public class TableDataWriteChannelTest {
private static final String UPLOAD_ID = "uploadid";
@@ -80,7 +82,7 @@ public class TableDataWriteChannelTest {
private TableDataWriteChannel writer;
- @Before
+ @BeforeEach
public void setUp() {
rpcFactoryMock = mock(BigQueryRpcFactory.class);
bigqueryRpcMock = mock(HttpBigQueryRpc.class);
@@ -142,12 +144,14 @@ public void testCreateNonRetryableError() throws IOException {
.setJobReference(JOB_INFO.getJobId().toPb())
.setConfiguration(LOAD_CONFIGURATION.toPb())))
.thenThrow(new RuntimeException("expected"));
- try (TableDataWriteChannel channel =
- new TableDataWriteChannel(options, JOB_INFO.getJobId(), LOAD_CONFIGURATION)) {
- Assert.fail();
- } catch (RuntimeException expected) {
- Assert.assertEquals("java.lang.RuntimeException: expected", expected.getMessage());
- }
+ RuntimeException expected =
+ assertThrows(
+ RuntimeException.class,
+ () -> {
+ try (TableDataWriteChannel channel =
+ new TableDataWriteChannel(options, JOB_INFO.getJobId(), LOAD_CONFIGURATION)) {}
+ });
+ assertEquals("java.lang.RuntimeException: expected", expected.getMessage());
verify(bigqueryRpcMock)
.openSkipExceptionTranslation(
new com.google.api.services.bigquery.model.Job()
@@ -269,17 +273,18 @@ public void testWritesAndFlushNonRetryableError() throws IOException {
eq(DEFAULT_CHUNK_SIZE),
eq(false)))
.thenThrow(new RuntimeException("expected"));
- try {
- writer = new TableDataWriteChannel(options, JOB_INFO.getJobId(), LOAD_CONFIGURATION);
- ByteBuffer[] buffers = new ByteBuffer[DEFAULT_CHUNK_SIZE / MIN_CHUNK_SIZE];
- for (int i = 0; i < buffers.length; i++) {
- buffers[i] = randomBuffer(MIN_CHUNK_SIZE);
- assertEquals(MIN_CHUNK_SIZE, writer.write(buffers[i]));
- }
- Assert.fail();
- } catch (RuntimeException expected) {
- Assert.assertEquals("java.lang.RuntimeException: expected", expected.getMessage());
- }
+ RuntimeException expected =
+ assertThrows(
+ RuntimeException.class,
+ () -> {
+ writer = new TableDataWriteChannel(options, JOB_INFO.getJobId(), LOAD_CONFIGURATION);
+ ByteBuffer[] buffers = new ByteBuffer[DEFAULT_CHUNK_SIZE / MIN_CHUNK_SIZE];
+ for (int i = 0; i < buffers.length; i++) {
+ buffers[i] = randomBuffer(MIN_CHUNK_SIZE);
+ assertEquals(MIN_CHUNK_SIZE, writer.write(buffers[i]));
+ }
+ });
+ assertEquals("java.lang.RuntimeException: expected", expected.getMessage());
verify(bigqueryRpcMock)
.openSkipExceptionTranslation(
new com.google.api.services.bigquery.model.Job()
@@ -363,12 +368,7 @@ public void testWriteClosed() throws IOException {
writer = new TableDataWriteChannel(options, JOB_INFO.getJobId(), LOAD_CONFIGURATION);
writer.close();
assertEquals(job, writer.getJob());
- try {
- writer.write(ByteBuffer.allocate(MIN_CHUNK_SIZE));
- fail("Expected TableDataWriteChannel write to throw IOException");
- } catch (IOException ex) {
- // expected
- }
+ assertThrows(IOException.class, () -> writer.write(ByteBuffer.allocate(MIN_CHUNK_SIZE)));
verify(bigqueryRpcMock)
.openSkipExceptionTranslation(
new com.google.api.services.bigquery.model.Job()
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableIdTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableIdTest.java
index dc28ff861..02154db0c 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableIdTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableIdTest.java
@@ -16,11 +16,11 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class TableIdTest {
+class TableIdTest {
private static final TableId TABLE = TableId.of("dataset", "table");
private static final TableId TABLE_COMPLETE = TableId.of("project", "dataset", "table");
@@ -28,7 +28,7 @@ public class TableIdTest {
"projects/project/datasets/dataset/tables/table";
@Test
- public void testOf() {
+ void testOf() {
assertEquals(null, TABLE.getProject());
assertEquals("dataset", TABLE.getDataset());
assertEquals("table", TABLE.getTable());
@@ -39,19 +39,19 @@ public void testOf() {
}
@Test
- public void testEquals() {
+ void testEquals() {
compareTableIds(TABLE, TableId.of("dataset", "table"));
compareTableIds(TABLE_COMPLETE, TableId.of("project", "dataset", "table"));
}
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
compareTableIds(TABLE, TableId.fromPb(TABLE.toPb()));
compareTableIds(TABLE_COMPLETE, TableId.fromPb(TABLE_COMPLETE.toPb()));
}
@Test
- public void testSetProjectId() {
+ void testSetProjectId() {
TableId differentProjectTable = TableId.of("differentProject", "dataset", "table");
assertEquals(differentProjectTable, TABLE.setProjectId("differentProject"));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableInfoTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableInfoTest.java
index a4ce6fbb4..4dd488a68 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableInfoTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableInfoTest.java
@@ -16,16 +16,16 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.common.collect.ImmutableList;
import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class TableInfoTest {
+class TableInfoTest {
private static final String ETAG = "etag";
private static final String GENERATED_ID = "project:dataset:table";
@@ -153,7 +153,7 @@ public class TableInfoTest {
.build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareTableInfo(TABLE_INFO, TABLE_INFO.toBuilder().build());
compareTableInfo(VIEW_INFO, VIEW_INFO.toBuilder().build());
compareTableInfo(EXTERNAL_TABLE_INFO, EXTERNAL_TABLE_INFO.toBuilder().build());
@@ -164,7 +164,7 @@ public void testToBuilder() {
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
TableInfo tableInfo = TableInfo.of(TABLE_ID, TABLE_DEFINITION);
assertEquals(tableInfo, tableInfo.toBuilder().build());
tableInfo = TableInfo.of(TABLE_ID, VIEW_DEFINITION);
@@ -174,7 +174,7 @@ public void testToBuilderIncomplete() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(TABLE_ID, TABLE_INFO.getTableId());
assertEquals(CREATION_TIME, TABLE_INFO.getCreationTime());
assertEquals(DESCRIPTION, TABLE_INFO.getDescription());
@@ -223,7 +223,7 @@ public void testBuilder() {
}
@Test
- public void testOf() {
+ void testOf() {
TableInfo tableInfo = TableInfo.of(TABLE_ID, TABLE_DEFINITION);
assertEquals(TABLE_ID, tableInfo.getTableId());
assertNull(tableInfo.getCreationTime());
@@ -266,21 +266,21 @@ public void testOf() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareTableInfo(TABLE_INFO, TableInfo.fromPb(TABLE_INFO.toPb()));
compareTableInfo(VIEW_INFO, TableInfo.fromPb(VIEW_INFO.toPb()));
compareTableInfo(EXTERNAL_TABLE_INFO, TableInfo.fromPb(EXTERNAL_TABLE_INFO.toPb()));
}
@Test
- public void testSetProjectId() {
+ void testSetProjectId() {
assertEquals("project", TABLE_INFO.setProjectId("project").getTableId().getProject());
assertEquals("project", EXTERNAL_TABLE_INFO.setProjectId("project").getTableId().getProject());
assertEquals("project", VIEW_INFO.setProjectId("project").getTableId().getProject());
}
@Test
- public void testSetProjectIdDoNotOverride() {
+ void testSetProjectIdDoNotOverride() {
TableInfo tableInfo = TableInfo.of(TABLE_ID, TABLE_DEFINITION).setProjectId("project");
tableInfo.setProjectId("not-override-project").toBuilder();
assertEquals("project", tableInfo.getTableId().getProject());
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableMetadataCacheUsageTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableMetadataCacheUsageTest.java
index 8f141fa59..dc996693c 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableMetadataCacheUsageTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableMetadataCacheUsageTest.java
@@ -16,13 +16,13 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.api.services.bigquery.model.TableReference;
import com.google.cloud.bigquery.TableMetadataCacheUsage.UnusedReason;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class TableMetadataCacheUsageTest {
+class TableMetadataCacheUsageTest {
private static final String EXPLANATION = "test explanation";
@@ -51,7 +51,7 @@ public class TableMetadataCacheUsageTest {
.setUnusedReason(UNUSED_REASON.toString());
@Test
- public void testToPbAndFromPb() {
+ void testToPbAndFromPb() {
assertEquals(TABLE_METADATA_CACHE_USAGE_PB, TABLE_METADATA_CACHE_USAGE.toPb());
compareTableMetadataCacheUsage(
TABLE_METADATA_CACHE_USAGE, TableMetadataCacheUsage.fromPb(TABLE_METADATA_CACHE_USAGE_PB));
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableResultTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableResultTest.java
index 71f9e35da..5bdb14cf4 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableResultTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableResultTest.java
@@ -22,9 +22,9 @@
import com.google.api.gax.paging.Page;
import com.google.cloud.PageImpl;
import com.google.common.collect.ImmutableList;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class TableResultTest {
+class TableResultTest {
private static final Page INNER_PAGE_0 =
new PageImpl<>(
new PageImpl.NextPageFetcher() {
@@ -52,7 +52,7 @@ private static FieldValueList newFieldValueList(String s) {
}
@Test
- public void testNullSchema() {
+ void testNullSchema() {
TableResult result =
TableResult.newBuilder().setTotalRows(3L).setPageNoSchema(INNER_PAGE_0).build();
assertThat(result.getSchema()).isNull();
@@ -75,7 +75,7 @@ public void testNullSchema() {
}
@Test
- public void testSchema() {
+ void testSchema() {
TableResult result =
TableResult.newBuilder()
.setSchema(SCHEMA)
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableTest.java
index 6e99b701c..6ad7822d9 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableTest.java
@@ -17,11 +17,11 @@
package com.google.cloud.bigquery;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -34,14 +34,12 @@
import com.google.common.collect.ImmutableMap;
import java.math.BigInteger;
import java.util.List;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.mockito.junit.MockitoRule;
-
-@RunWith(MockitoJUnitRunner.class)
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+@ExtendWith(MockitoExtension.class)
public class TableTest {
private static final String ETAG = "etag";
@@ -97,14 +95,12 @@ public class TableTest {
FieldValueList.of(ImmutableList.of(FIELD_VALUE1)).withSchema(SCHEMA.getFields()),
FieldValueList.of(ImmutableList.of(FIELD_VALUE2)).withSchema(SCHEMA.getFields()));
- @Rule public MockitoRule rule;
-
private BigQuery bigquery;
private BigQueryOptions mockOptions;
private Table expectedTable;
private Table table;
- @Before
+ @BeforeEach
public void setUp() {
bigquery = mock(BigQuery.class);
mockOptions = mock(BigQueryOptions.class);
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TimePartitioningTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TimePartitioningTest.java
index 1e48c817e..ec947381b 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TimePartitioningTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TimePartitioningTest.java
@@ -16,16 +16,16 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.cloud.bigquery.TimePartitioning.Type;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class TimePartitioningTest {
+class TimePartitioningTest {
private static final Type TYPE_DAY = Type.DAY;
private static final Type TYPE_HOUR = Type.HOUR;
@@ -60,7 +60,7 @@ public class TimePartitioningTest {
.build();
@Test
- public void testOf() {
+ void testOf() {
assertEquals(TYPE_DAY, TIME_PARTITIONING_DAY.getType());
assertEquals(TYPE_HOUR, TIME_PARTITIONING_HOUR.getType());
assertEquals(TYPE_MONTH, TIME_PARTITIONING_MONTH.getType());
@@ -74,7 +74,7 @@ public void testOf() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
TimePartitioning partitioning = TimePartitioning.newBuilder(TYPE_DAY).build();
assertEquals(TYPE_DAY, partitioning.getType());
assertNull(partitioning.getExpirationMs());
@@ -90,27 +90,21 @@ public void testBuilder() {
}
@Test
- public void testTypeOf_Npe() {
- try {
- TimePartitioning.of(null);
- Assert.fail();
- } catch (NullPointerException ex) {
- assertNotNull(ex.getMessage());
- }
+ void testTypeOf_Npe() {
+ NullPointerException ex =
+ assertThrows(NullPointerException.class, () -> TimePartitioning.of(null));
+ assertNotNull(ex.getMessage());
}
@Test
- public void testTypeAndExpirationOf_Npe() {
- try {
- TimePartitioning.of(null, EXPIRATION_MS);
- Assert.fail();
- } catch (NullPointerException ex) {
- assertNotNull(ex.getMessage());
- }
+ void testTypeAndExpirationOf_Npe() {
+ NullPointerException ex =
+ assertThrows(NullPointerException.class, () -> TimePartitioning.of(null, EXPIRATION_MS));
+ assertNotNull(ex.getMessage());
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
compareTimePartitioning(
TIME_PARTITIONING_DAY, TimePartitioning.fromPb(TIME_PARTITIONING_DAY.toPb()));
TimePartitioning partitioning = TimePartitioning.of(TYPE_DAY);
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TimelineSampleTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TimelineSampleTest.java
index 1d888f00d..22f419593 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TimelineSampleTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TimelineSampleTest.java
@@ -15,10 +15,10 @@
*/
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TimelineSampleTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/UserDefinedFunctionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/UserDefinedFunctionTest.java
index 93657b44c..81622527a 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/UserDefinedFunctionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/UserDefinedFunctionTest.java
@@ -16,9 +16,9 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class UserDefinedFunctionTest {
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ViewDefinitionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ViewDefinitionTest.java
index d60c7be2b..60eeea766 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ViewDefinitionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ViewDefinitionTest.java
@@ -16,19 +16,18 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.ImmutableList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ViewDefinitionTest {
+class ViewDefinitionTest {
private static final String VIEW_QUERY = "VIEW QUERY";
private static final List USER_DEFINED_FUNCTIONS =
@@ -37,7 +36,7 @@ public class ViewDefinitionTest {
ViewDefinition.newBuilder(VIEW_QUERY, USER_DEFINED_FUNCTIONS).setSchema(Schema.of()).build();
@Test
- public void testToBuilder() {
+ void testToBuilder() {
compareViewDefinition(VIEW_DEFINITION, VIEW_DEFINITION.toBuilder().build());
ViewDefinition viewDefinition = VIEW_DEFINITION.toBuilder().setQuery("NEW QUERY").build();
assertEquals("NEW QUERY", viewDefinition.getQuery());
@@ -50,23 +49,21 @@ public void testToBuilder() {
}
@Test
- public void testTypeNullPointerException() {
- try {
- VIEW_DEFINITION.toBuilder().setType(null).build();
- fail();
- } catch (NullPointerException ex) {
- assertNotNull(ex.getMessage());
- }
+ void testTypeNullPointerException() {
+ NullPointerException ex =
+ org.junit.jupiter.api.Assertions.assertThrows(
+ NullPointerException.class, () -> VIEW_DEFINITION.toBuilder().setType(null).build());
+ assertNotNull(ex.getMessage());
}
@Test
- public void testToBuilderIncomplete() {
+ void testToBuilderIncomplete() {
TableDefinition viewDefinition = ViewDefinition.of(VIEW_QUERY);
assertEquals(viewDefinition, viewDefinition.toBuilder().build());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
assertEquals(VIEW_QUERY, VIEW_DEFINITION.getQuery());
assertEquals(TableDefinition.Type.VIEW, VIEW_DEFINITION.getType());
assertEquals(USER_DEFINED_FUNCTIONS, VIEW_DEFINITION.getUserDefinedFunctions());
@@ -106,7 +103,7 @@ public void testBuilder() {
}
@Test
- public void testToAndFromPb() {
+ void testToAndFromPb() {
ViewDefinition viewDefinition = VIEW_DEFINITION.toBuilder().setUseLegacySql(false).build();
assertTrue(TableDefinition.fromPb(viewDefinition.toPb()) instanceof ViewDefinition);
compareViewDefinition(
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/WriteChannelConfigurationTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/WriteChannelConfigurationTest.java
index 240f12185..35745235e 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/WriteChannelConfigurationTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/WriteChannelConfigurationTest.java
@@ -16,8 +16,8 @@
package com.google.cloud.bigquery;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.cloud.bigquery.JobInfo.CreateDisposition;
import com.google.cloud.bigquery.JobInfo.WriteDisposition;
@@ -27,7 +27,7 @@
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class WriteChannelConfigurationTest {
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 ddad48d39..fec7e55e0 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
@@ -20,15 +20,15 @@
import static com.google.common.truth.Truth.assertThat;
import static java.lang.System.currentTimeMillis;
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.api.client.util.IOUtils;
import com.google.api.gax.paging.Page;
@@ -208,14 +208,14 @@
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.Timeout;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.threeten.extra.PeriodDuration;
-public class ITBigQueryTest {
+@Timeout(value = 300)
+class ITBigQueryTest {
private static final byte[] BYTES = {0xD, 0xE, 0xA, 0xD};
private static final String BYTES_BASE64 = BaseEncoding.base64().encode(BYTES);
@@ -1063,10 +1063,8 @@ public CompletableResultCode shutdown() {
}
}
- @Rule public Timeout globalTimeout = Timeout.seconds(300);
-
- @BeforeClass
- public static void beforeClass() throws InterruptedException, IOException {
+ @BeforeAll
+ static void beforeClass() throws InterruptedException, IOException {
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
RemoteStorageHelper storageHelper = RemoteStorageHelper.create();
Map labels = ImmutableMap.of("test-job-name", "test-load-job");
@@ -1180,8 +1178,8 @@ public static void beforeClass() throws InterruptedException, IOException {
assertNull(jobLargeTable.getStatus().getError());
}
- @AfterClass
- public static void afterClass() throws Exception {
+ @AfterAll
+ static void afterClass() throws Exception {
if (bigquery != null) {
RemoteBigQueryHelper.forceDelete(bigquery, DATASET);
RemoteBigQueryHelper.forceDelete(bigquery, UK_DATASET);
@@ -1206,13 +1204,12 @@ static GoogleCredentials loadCredentials(String credentialFile) {
try (InputStream keyStream = new ByteArrayInputStream(credentialFile.getBytes())) {
return GoogleCredentials.fromStream(keyStream);
} catch (IOException e) {
- fail("Couldn't create fake JSON credentials.");
+ throw new RuntimeException("Couldn't create fake JSON credentials.", e);
}
- return null;
}
@Test
- public void testListDatasets() {
+ void testListDatasets() {
Page datasets = bigquery.listDatasets("bigquery-public-data");
Iterator iterator = datasets.iterateAll().iterator();
Set datasetNames = new HashSet<>();
@@ -1230,24 +1227,24 @@ public void testListDatasets() {
}
@Test
- public void testListDatasetsWithFilter() {
+ void testListDatasetsWithFilter() {
String labelFilter = "labels.example-label1:example-value1";
Page datasets = bigquery.listDatasets(DatasetListOption.labelFilter(labelFilter));
int count = 0;
for (Dataset dataset : datasets.getValues()) {
assertTrue(
- "failed to find label key in dataset", dataset.getLabels().containsKey("example-label1"));
+ dataset.getLabels().containsKey("example-label1"), "failed to find label key in dataset");
assertEquals(
- "failed to find label value in dataset",
"example-value1",
- dataset.getLabels().get("example-label1"));
+ dataset.getLabels().get("example-label1"),
+ "failed to find label value in dataset");
count++;
}
assertTrue(count > 0);
}
@Test
- public void testGetDataset() {
+ void testGetDataset() {
Dataset dataset = bigquery.getDataset(DATASET);
assertEquals(bigquery.getOptions().getProjectId(), dataset.getDatasetId().getProject());
assertEquals(DATASET, dataset.getDatasetId().getDataset());
@@ -1261,7 +1258,7 @@ public void testGetDataset() {
}
@Test
- public void testDatasetUpdateAccess() throws IOException {
+ void testDatasetUpdateAccess() throws IOException {
Dataset dataset = bigquery.getDataset(DATASET);
ServiceAccountCredentials credentials =
(ServiceAccountCredentials) GoogleCredentials.getApplicationDefault();
@@ -1276,7 +1273,7 @@ public void testDatasetUpdateAccess() throws IOException {
}
@Test
- public void testGetDatasetWithSelectedFields() {
+ void testGetDatasetWithSelectedFields() {
Dataset dataset =
bigquery.getDataset(
DATASET, DatasetOption.fields(DatasetField.CREATION_TIME, DatasetField.LABELS));
@@ -1298,7 +1295,7 @@ public void testGetDatasetWithSelectedFields() {
}
@Test
- public void testGetDatasetWithAccessPolicyVersion() throws IOException {
+ void testGetDatasetWithAccessPolicyVersion() throws IOException {
String accessPolicyDataset = RemoteBigQueryHelper.generateDatasetName();
ServiceAccountCredentials credentials =
(ServiceAccountCredentials) GoogleCredentials.getApplicationDefault();
@@ -1342,7 +1339,7 @@ public void testGetDatasetWithAccessPolicyVersion() throws IOException {
}
@Test
- public void testUpdateDataset() {
+ void testUpdateDataset() {
Dataset dataset =
bigquery.create(
DatasetInfo.newBuilder(OTHER_DATASET)
@@ -1379,7 +1376,7 @@ public void testUpdateDataset() {
}
@Test
- public void testUpdateDatasetWithSelectedFields() {
+ void testUpdateDatasetWithSelectedFields() {
Dataset dataset =
bigquery.create(
DatasetInfo.newBuilder(OTHER_DATASET).setDescription("Some Description").build());
@@ -1407,7 +1404,7 @@ public void testUpdateDatasetWithSelectedFields() {
}
@Test
- public void testUpdateDatasetWithAccessPolicyVersion() throws IOException {
+ void testUpdateDatasetWithAccessPolicyVersion() throws IOException {
String accessPolicyDataset = RemoteBigQueryHelper.generateDatasetName();
ServiceAccountCredentials credentials =
(ServiceAccountCredentials) GoogleCredentials.getApplicationDefault();
@@ -1460,12 +1457,12 @@ public void testUpdateDatasetWithAccessPolicyVersion() throws IOException {
}
@Test
- public void testGetNonExistingTable() {
+ void testGetNonExistingTable() {
assertNull(bigquery.getTable(DATASET, "test_get_non_existing_table"));
}
@Test
- public void testCreateTableWithRangePartitioning() {
+ void testCreateTableWithRangePartitioning() {
String tableName = "test_create_table_rangepartitioning";
TableId tableId = TableId.of(DATASET, tableName);
try {
@@ -1490,7 +1487,7 @@ public void testCreateTableWithRangePartitioning() {
/* TODO(prasmish): replicate this test case for executeSelect on the relevant part */
@Test
- public void testJsonType() throws InterruptedException {
+ void testJsonType() throws InterruptedException {
String tableName = "test_create_table_jsontype";
TableId tableId = TableId.of(DATASET, tableName);
Schema schema = Schema.of(Field.of("jsonField", StandardSQLTypeName.JSON));
@@ -1586,9 +1583,9 @@ public void testJsonType() throws InterruptedException {
.build();
BigQueryException exception =
assertThrows(
- "Querying with malformed JSON shouldn't work",
BigQueryException.class,
- () -> bigquery.query(dmlQueryJobConfiguration2));
+ () -> bigquery.query(dmlQueryJobConfiguration2),
+ "Querying with malformed JSON shouldn't work");
BigQueryError error = exception.getError();
assertNotNull(error);
assertEquals("invalidQuery", error.getReason());
@@ -1599,7 +1596,7 @@ public void testJsonType() throws InterruptedException {
/* TODO(prasmish): replicate this test case for executeSelect on the relevant part */
@Test
- public void testIntervalType() throws InterruptedException {
+ void testIntervalType() throws InterruptedException {
String tableName = "test_create_table_intervaltype";
TableId tableId = TableId.of(DATASET, tableName);
Schema schema = Schema.of(Field.of("intervalField", StandardSQLTypeName.INTERVAL));
@@ -1674,7 +1671,7 @@ public void testIntervalType() throws InterruptedException {
}
@Test
- public void testRangeType() throws InterruptedException {
+ void testRangeType() throws InterruptedException {
String tableName = "test_range_type_table";
TableId tableId = TableId.of(DATASET, tableName);
@@ -1751,7 +1748,7 @@ public void testRangeType() throws InterruptedException {
}
@Test
- public void testCreateTableWithConstraints() {
+ void testCreateTableWithConstraints() {
String tableName = "test_create_table_with_constraints";
TableId tableId = TableId.of(DATASET, tableName);
Field stringFieldWithConstraint =
@@ -1795,7 +1792,7 @@ public void testCreateTableWithConstraints() {
}
@Test
- public void testCreateDatasetWithSpecifiedStorageBillingModel() {
+ void testCreateDatasetWithSpecifiedStorageBillingModel() {
String billingModelDataset = RemoteBigQueryHelper.generateDatasetName();
DatasetInfo info =
DatasetInfo.newBuilder(billingModelDataset)
@@ -1812,7 +1809,7 @@ public void testCreateDatasetWithSpecifiedStorageBillingModel() {
}
@Test
- public void testCreateDatasetWithSpecificMaxTimeTravelHours() {
+ void testCreateDatasetWithSpecificMaxTimeTravelHours() {
String timeTravelDataset = RemoteBigQueryHelper.generateDatasetName();
DatasetInfo info =
DatasetInfo.newBuilder(timeTravelDataset)
@@ -1829,7 +1826,7 @@ public void testCreateDatasetWithSpecificMaxTimeTravelHours() {
}
@Test
- public void testCreateDatasetWithDefaultMaxTimeTravelHours() {
+ void testCreateDatasetWithDefaultMaxTimeTravelHours() {
String timeTravelDataset = RemoteBigQueryHelper.generateDatasetName();
DatasetInfo info =
DatasetInfo.newBuilder(timeTravelDataset)
@@ -1846,7 +1843,7 @@ public void testCreateDatasetWithDefaultMaxTimeTravelHours() {
}
@Test
- public void testCreateDatasetWithDefaultCollation() {
+ void testCreateDatasetWithDefaultCollation() {
String collationDataset = RemoteBigQueryHelper.generateDatasetName();
DatasetInfo info =
DatasetInfo.newBuilder(collationDataset)
@@ -1863,7 +1860,7 @@ public void testCreateDatasetWithDefaultCollation() {
}
@Test
- public void testCreateDatasetWithAccessPolicyVersion() throws IOException {
+ void testCreateDatasetWithAccessPolicyVersion() throws IOException {
String accessPolicyDataset = RemoteBigQueryHelper.generateDatasetName();
ServiceAccountCredentials credentials =
(ServiceAccountCredentials) GoogleCredentials.getApplicationDefault();
@@ -1899,8 +1896,8 @@ public void testCreateDatasetWithAccessPolicyVersion() throws IOException {
RemoteBigQueryHelper.forceDelete(bigquery, accessPolicyDataset);
}
- @Test(expected = BigQueryException.class)
- public void testCreateDatasetWithInvalidAccessPolicyVersion() throws IOException {
+ @Test
+ void testCreateDatasetWithInvalidAccessPolicyVersion() throws IOException {
String accessPolicyDataset = RemoteBigQueryHelper.generateDatasetName();
ServiceAccountCredentials credentials =
(ServiceAccountCredentials) GoogleCredentials.getApplicationDefault();
@@ -1920,14 +1917,13 @@ public void testCreateDatasetWithInvalidAccessPolicyVersion() throws IOException
.setAcl(ImmutableList.of(acl))
.build();
DatasetOption datasetOption = DatasetOption.accessPolicyVersion(4);
- Dataset dataset = bigquery.create(info, datasetOption);
- assertNotNull(dataset);
+ assertThrows(BigQueryException.class, () -> bigquery.create(info, datasetOption));
RemoteBigQueryHelper.forceDelete(bigquery, accessPolicyDataset);
}
@Test
- public void testCreateTableWithDefaultCollation() {
+ void testCreateTableWithDefaultCollation() {
String tableName = "test_create_table_with_default_collation";
TableId tableId = TableId.of(DATASET, tableName);
Field stringFieldWithoutCollation =
@@ -1965,7 +1961,7 @@ public void testCreateTableWithDefaultCollation() {
}
@Test
- public void testCreateFieldWithDefaultCollation() {
+ void testCreateFieldWithDefaultCollation() {
String tableName = "test_create_field_with_default_collation";
TableId tableId = TableId.of(DATASET, tableName);
Field stringFieldWithCollation =
@@ -2002,7 +1998,7 @@ public void testCreateFieldWithDefaultCollation() {
}
@Test
- public void testCreateTableWithDefaultValueExpression() {
+ void testCreateTableWithDefaultValueExpression() {
String tableName = "test_create_table_with_default_value_expression";
TableId tableId = TableId.of(DATASET, tableName);
Field stringFieldWithDefaultValueExpression =
@@ -2064,7 +2060,7 @@ public void testCreateTableWithDefaultValueExpression() {
}
@Test
- public void testCreateAndUpdateTableWithPolicyTags() throws IOException {
+ void testCreateAndUpdateTableWithPolicyTags() throws IOException {
// Set up policy tags in the datacatalog service
try (PolicyTagManagerClient policyTagManagerClient = PolicyTagManagerClient.create()) {
CreateTaxonomyRequest createTaxonomyRequest =
@@ -2146,7 +2142,7 @@ public void testCreateAndUpdateTableWithPolicyTags() throws IOException {
}
@Test
- public void testCreateAndGetTable() {
+ void testCreateAndGetTable() {
String tableName = "test_create_and_get_table";
TableId tableId = TableId.of(DATASET, tableName);
TimePartitioning partitioning = TimePartitioning.of(Type.DAY);
@@ -2184,7 +2180,7 @@ public void testCreateAndGetTable() {
}
@Test
- public void testCreateAndListTable() {
+ void testCreateAndListTable() {
String tableName = "test_create_and_list_table";
TableId tableId = TableId.of(DATASET, tableName);
TimePartitioning partitioning = TimePartitioning.of(Type.DAY);
@@ -2219,7 +2215,7 @@ public void testCreateAndListTable() {
}
@Test
- public void testCreateAndGetTableWithBasicTableMetadataView() {
+ void testCreateAndGetTableWithBasicTableMetadataView() {
String tableName = "test_create_and_get_table_with_basic_metadata_view";
TableId tableId = TableId.of(DATASET, tableName);
TimePartitioning partitioning = TimePartitioning.of(Type.DAY);
@@ -2251,7 +2247,7 @@ public void testCreateAndGetTableWithBasicTableMetadataView() {
}
@Test
- public void testCreateAndGetTableWithFullTableMetadataView() {
+ void testCreateAndGetTableWithFullTableMetadataView() {
String tableName = "test_create_and_get_table_with_full_metadata_view";
TableId tableId = TableId.of(DATASET, tableName);
TimePartitioning partitioning = TimePartitioning.of(Type.DAY);
@@ -2282,7 +2278,7 @@ public void testCreateAndGetTableWithFullTableMetadataView() {
}
@Test
- public void testCreateAndGetTableWithStorageStatsTableMetadataView() {
+ void testCreateAndGetTableWithStorageStatsTableMetadataView() {
String tableName = "test_create_and_get_table_with_storage_stats_metadata_view";
TableId tableId = TableId.of(DATASET, tableName);
TimePartitioning partitioning = TimePartitioning.of(Type.DAY);
@@ -2314,7 +2310,7 @@ public void testCreateAndGetTableWithStorageStatsTableMetadataView() {
}
@Test
- public void testCreateAndGetTableWithUnspecifiedTableMetadataView() {
+ void testCreateAndGetTableWithUnspecifiedTableMetadataView() {
String tableName = "test_create_and_get_table_with_unspecified_metadata_view";
TableId tableId = TableId.of(DATASET, tableName);
TimePartitioning partitioning = TimePartitioning.of(Type.DAY);
@@ -2346,7 +2342,7 @@ public void testCreateAndGetTableWithUnspecifiedTableMetadataView() {
}
@Test
- public void testCreateAndGetTableWithSelectedField() {
+ void testCreateAndGetTableWithSelectedField() {
String tableName = "test_create_and_get_selected_fields_table";
TableId tableId = TableId.of(DATASET, tableName);
StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
@@ -2386,7 +2382,7 @@ public void testCreateAndGetTableWithSelectedField() {
}
@Test
- public void testCreateExternalTable() throws InterruptedException {
+ void testCreateExternalTable() throws InterruptedException {
String tableName = "test_create_external_table";
TableId tableId = TableId.of(DATASET, tableName);
@@ -2444,7 +2440,7 @@ public void testCreateExternalTable() throws InterruptedException {
}
@Test
- public void testSetPermExternalTableSchema() {
+ void testSetPermExternalTableSchema() {
String tableName = "test_create_external_table_perm";
TableId tableId = TableId.of(DATASET, tableName);
ExternalTableDefinition externalTableDefinition =
@@ -2466,7 +2462,7 @@ public void testSetPermExternalTableSchema() {
}
@Test
- public void testUpdatePermExternableTableWithAutodetectSchemaUpdatesSchema() {
+ void testUpdatePermExternableTableWithAutodetectSchemaUpdatesSchema() {
String tableName = "test_create_external_table_perm_with_auto_detect";
TableId tableId = TableId.of(DATASET, tableName);
Schema setSchema = Schema.of(TIMESTAMP_FIELD_SCHEMA, STRING_FIELD_SCHEMA);
@@ -2501,7 +2497,7 @@ public void testUpdatePermExternableTableWithAutodetectSchemaUpdatesSchema() {
}
@Test
- public void testCreateViewTable() throws InterruptedException {
+ void testCreateViewTable() throws InterruptedException {
String tableName = "test_create_view_table";
TableId tableId = TableId.of(DATASET, tableName);
ViewDefinition viewDefinition =
@@ -2549,7 +2545,7 @@ public void testCreateViewTable() throws InterruptedException {
}
@Test
- public void testCreateMaterializedViewTable() {
+ void testCreateMaterializedViewTable() {
String tableName = "test_materialized_view_table";
TableId tableId = TableId.of(DATASET, tableName);
MaterializedViewDefinition viewDefinition =
@@ -2573,7 +2569,7 @@ public void testCreateMaterializedViewTable() {
}
@Test
- public void testTableIAM() {
+ void testTableIAM() {
String tableName = "test_iam_table";
TableId tableId = TableId.of(DATASET, tableName);
StandardTableDefinition tableDefinition =
@@ -2602,7 +2598,7 @@ public void testTableIAM() {
}
@Test
- public void testListTables() {
+ void testListTables() {
String tableName = "test_list_tables";
StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
TableInfo tableInfo = TableInfo.of(TableId.of(DATASET, tableName), tableDefinition);
@@ -2621,7 +2617,7 @@ public void testListTables() {
}
@Test
- public void testListTablesWithPartitioning() {
+ void testListTablesWithPartitioning() {
String tableName = "test_list_tables_partitioning";
TimePartitioning timePartitioning = TimePartitioning.of(Type.DAY, EXPIRATION_MS);
StandardTableDefinition tableDefinition =
@@ -2654,7 +2650,7 @@ public void testListTablesWithPartitioning() {
}
@Test
- public void testListTablesWithRangePartitioning() {
+ void testListTablesWithRangePartitioning() {
String tableName = "test_list_tables_range_partitioning";
StandardTableDefinition tableDefinition =
StandardTableDefinition.newBuilder()
@@ -2684,7 +2680,7 @@ public void testListTablesWithRangePartitioning() {
}
@Test
- public void testListPartitions() throws InterruptedException {
+ void testListPartitions() throws InterruptedException {
String tableName = "test_table_partitions_" + UUID.randomUUID().toString().substring(0, 8);
Date date = Date.fromJavaUtilDate(new java.util.Date());
String partitionDate = date.toString().replaceAll("-", "");
@@ -2710,7 +2706,7 @@ public void testListPartitions() throws InterruptedException {
}
@Test
- public void testUpdateTable() {
+ void testUpdateTable() {
String tableName = "test_update_table";
StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
TableInfo tableInfo =
@@ -2740,7 +2736,7 @@ public void testUpdateTable() {
}
@Test
- public void testUpdateTimePartitioning() {
+ void testUpdateTimePartitioning() {
String tableName = "testUpdateTimePartitioning";
TableId tableId = TableId.of(DATASET, tableName);
StandardTableDefinition tableDefinition =
@@ -2782,8 +2778,7 @@ public void testUpdateTimePartitioning() {
table.delete();
}
- @Test
- public void testUpdateTableWithSelectedFields() {
+ void testUpdateTableWithSelectedFields() {
String tableName = "test_update_with_selected_fields_table";
StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
TableInfo tableInfo = TableInfo.of(TableId.of(DATASET, tableName), tableDefinition);
@@ -2814,16 +2809,16 @@ public void testUpdateTableWithSelectedFields() {
}
@Test
- public void testUpdateNonExistingTable() {
+ void testUpdateNonExistingTable() {
TableInfo tableInfo =
TableInfo.of(
TableId.of(DATASET, "test_update_non_existing_table"),
StandardTableDefinition.of(SIMPLE_SCHEMA));
BigQueryException exception =
assertThrows(
- "BigQueryException was expected",
BigQueryException.class,
- () -> bigquery.update(tableInfo));
+ () -> bigquery.update(tableInfo),
+ "BigQueryException was expected");
BigQueryError error = exception.getError();
assertNotNull(error);
assertEquals("notFound", error.getReason());
@@ -2831,12 +2826,12 @@ public void testUpdateNonExistingTable() {
}
@Test
- public void testDeleteNonExistingTable() {
+ void testDeleteNonExistingTable() {
assertFalse(bigquery.delete("test_delete_non_existing_table"));
}
@Test
- public void testDeleteJob() {
+ void testDeleteJob() {
String query = "SELECT 17 as foo";
QueryJobConfiguration config = QueryJobConfiguration.of(query);
String jobName = "jobId_" + UUID.randomUUID().toString();
@@ -2850,7 +2845,7 @@ public void testDeleteJob() {
}
@Test
- public void testInsertAll() throws IOException {
+ void testInsertAll() throws IOException {
String tableName = "test_insert_all_table";
StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
TableInfo tableInfo = TableInfo.of(TableId.of(DATASET, tableName), tableDefinition);
@@ -2909,7 +2904,7 @@ public void testInsertAll() throws IOException {
}
@Test
- public void testInsertAllWithSuffix() throws InterruptedException {
+ void testInsertAllWithSuffix() throws InterruptedException {
String tableName = "test_insert_all_with_suffix_table";
StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
TableInfo tableInfo = TableInfo.of(TableId.of(DATASET, tableName), tableDefinition);
@@ -2977,7 +2972,7 @@ public void testInsertAllWithSuffix() throws InterruptedException {
}
@Test
- public void testInsertAllWithErrors() {
+ void testInsertAllWithErrors() {
String tableName = "test_insert_all_with_errors_table";
StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
TableInfo tableInfo = TableInfo.of(TableId.of(DATASET, tableName), tableDefinition);
@@ -3047,7 +3042,7 @@ public void testInsertAllWithErrors() {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testListAllTableData() {
+ void testListAllTableData() {
Page rows = bigquery.listTableData(TABLE_ID);
int rowCount = 0;
for (FieldValueList row : rows.getValues()) {
@@ -3092,7 +3087,7 @@ public void testListAllTableData() {
}
@Test
- public void testListPageWithStartIndex() {
+ void testListPageWithStartIndex() {
String tableName = "midyear_population_agespecific";
TableId tableId = TableId.of(PUBLIC_PROJECT, PUBLIC_DATASET, tableName);
Table table = bigquery.getTable(tableId);
@@ -3111,7 +3106,7 @@ public void testListPageWithStartIndex() {
}
@Test
- public void testModelLifecycle() throws InterruptedException {
+ void testModelLifecycle() throws InterruptedException {
String modelName = RemoteBigQueryHelper.generateModelName();
@@ -3170,7 +3165,7 @@ public void testModelLifecycle() throws InterruptedException {
}
@Test
- public void testEmptyListModels() {
+ void testEmptyListModels() {
String datasetId = "test_empty_dataset_list_models_" + RANDOM_ID;
assertNotNull(bigquery.create(DatasetInfo.of(datasetId)));
Page models = bigquery.listModels(datasetId, BigQuery.ModelListOption.pageSize(100));
@@ -3181,7 +3176,7 @@ public void testEmptyListModels() {
}
@Test
- public void testEmptyListRoutines() {
+ void testEmptyListRoutines() {
String datasetId = "test_empty_dataset_list_routines_" + RANDOM_ID;
assertNotNull(bigquery.create(DatasetInfo.of(datasetId)));
Page routines =
@@ -3193,7 +3188,7 @@ public void testEmptyListRoutines() {
}
@Test
- public void testRoutineLifecycle() throws InterruptedException {
+ void testRoutineLifecycle() throws InterruptedException {
String routineName = RemoteBigQueryHelper.generateRoutineName();
// Create a routine using SQL.
String sql =
@@ -3236,7 +3231,7 @@ public void testRoutineLifecycle() throws InterruptedException {
}
@Test
- public void testRoutineAPICreation() {
+ void testRoutineAPICreation() {
String routineName = RemoteBigQueryHelper.generateRoutineName();
RoutineId routineId = RoutineId.of(ROUTINE_DATASET, routineName);
RoutineInfo routineInfo =
@@ -3258,7 +3253,7 @@ public void testRoutineAPICreation() {
}
@Test
- public void testRoutineAPICreationJavascriptUDF() {
+ void testRoutineAPICreationJavascriptUDF() {
String routineName = RemoteBigQueryHelper.generateRoutineName();
RoutineId routineId = RoutineId.of(ROUTINE_DATASET, routineName);
RoutineInfo routineInfo =
@@ -3286,7 +3281,7 @@ public void testRoutineAPICreationJavascriptUDF() {
}
@Test
- public void testRoutineAPICreationTVF() {
+ void testRoutineAPICreationTVF() {
String routineName = RemoteBigQueryHelper.generateRoutineName();
RoutineId routineId = RoutineId.of(ROUTINE_DATASET, routineName);
List columns =
@@ -3314,7 +3309,7 @@ public void testRoutineAPICreationTVF() {
}
@Test
- public void testRoutineDataGovernanceType() {
+ void testRoutineDataGovernanceType() {
String routineName = RemoteBigQueryHelper.generateRoutineName();
RoutineId routineId = RoutineId.of(ROUTINE_DATASET, routineName);
RoutineInfo routineInfo =
@@ -3341,7 +3336,7 @@ public void testRoutineDataGovernanceType() {
}
@Test
- public void testAuthorizeRoutine() {
+ void testAuthorizeRoutine() {
String routineName = RemoteBigQueryHelper.generateRoutineName();
RoutineId routineId = RoutineId.of(PROJECT_ID, ROUTINE_DATASET, routineName);
RoutineInfo routineInfo =
@@ -3367,7 +3362,7 @@ public void testAuthorizeRoutine() {
}
@Test
- public void testAuthorizeDataset() {
+ void testAuthorizeDataset() {
String datasetName = RemoteBigQueryHelper.generateDatasetName();
DatasetId datasetId = DatasetId.of(PROJECT_ID, datasetName);
List targetTypes = ImmutableList.of("VIEWS");
@@ -3412,14 +3407,14 @@ public void testAuthorizeDataset() {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testSingleStatementsQueryException() throws InterruptedException {
+ void testSingleStatementsQueryException() throws InterruptedException {
String invalidQuery =
String.format("INSERT %s.%s VALUES('3', 10);", DATASET, TABLE_ID.getTable());
BigQueryException exception =
assertThrows(
- "BigQueryException was expected",
BigQueryException.class,
- () -> bigquery.create(JobInfo.of(QueryJobConfiguration.of(invalidQuery))).waitFor());
+ () -> bigquery.create(JobInfo.of(QueryJobConfiguration.of(invalidQuery))).waitFor(),
+ "BigQueryException was expected");
assertEquals("invalidQuery", exception.getReason());
assertNotNull(exception.getMessage());
BigQueryError error = exception.getError();
@@ -3429,16 +3424,16 @@ public void testSingleStatementsQueryException() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testMultipleStatementsQueryException() throws InterruptedException {
+ void testMultipleStatementsQueryException() throws InterruptedException {
String invalidQuery =
String.format(
"INSERT %s.%s VALUES('3', 10); DELETE %s.%s where c2=3;",
DATASET, TABLE_ID.getTable(), DATASET, TABLE_ID.getTable());
BigQueryException exception =
assertThrows(
- "BigQueryException was expected",
BigQueryException.class,
- () -> bigquery.create(JobInfo.of(QueryJobConfiguration.of(invalidQuery))).waitFor());
+ () -> bigquery.create(JobInfo.of(QueryJobConfiguration.of(invalidQuery))).waitFor(),
+ "BigQueryException was expected");
assertEquals("invalidQuery", exception.getReason());
assertNotNull(exception.getMessage());
BigQueryError error = exception.getError();
@@ -3447,7 +3442,7 @@ public void testMultipleStatementsQueryException() throws InterruptedException {
}
@Test
- public void testTimestamp() throws InterruptedException {
+ void testTimestamp() throws InterruptedException {
String query = "SELECT TIMESTAMP '2022-01-24T23:54:25.095574Z'";
String timestampStringValueExpected = "2022-01-24T23:54:25.095574Z";
@@ -3465,7 +3460,7 @@ public void testTimestamp() throws InterruptedException {
}
@Test
- public void testLosslessTimestamp() throws InterruptedException {
+ void testLosslessTimestamp() throws InterruptedException {
String query = "SELECT TIMESTAMP '2022-01-24T23:54:25.095574Z'";
long expectedTimestamp = 1643068465095574L;
@@ -3505,7 +3500,7 @@ public void testLosslessTimestamp() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testQuery() throws InterruptedException {
+ void testQuery() throws InterruptedException {
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
QueryJobConfiguration config =
QueryJobConfiguration.newBuilder(query).setDefaultDataset(DatasetId.of(DATASET)).build();
@@ -3538,7 +3533,7 @@ public void testQuery() throws InterruptedException {
}
@Test
- public void testQueryStatistics() throws InterruptedException {
+ void testQueryStatistics() throws InterruptedException {
// Use CURRENT_TIMESTAMP to avoid potential caching.
String query = "SELECT CURRENT_TIMESTAMP() AS ts";
QueryJobConfiguration config =
@@ -3555,7 +3550,7 @@ public void testQueryStatistics() throws InterruptedException {
}
@Test
- public void testExecuteSelectDefaultConnectionSettings() throws SQLException {
+ void testExecuteSelectDefaultConnectionSettings() throws SQLException {
// Use the default connection settings
Connection connection = bigquery.createConnection();
String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;";
@@ -3565,7 +3560,7 @@ public void testExecuteSelectDefaultConnectionSettings() throws SQLException {
}
@Test
- public void testExecuteSelectWithReadApi() throws SQLException {
+ void testExecuteSelectWithReadApi() throws SQLException {
final int rowLimit = 5000;
final String QUERY =
"SELECT * FROM bigquery-public-data.new_york_taxi_trips.tlc_yellow_trips_2017 LIMIT %s";
@@ -3595,7 +3590,7 @@ public void testExecuteSelectWithReadApi() throws SQLException {
}
@Test
- public void testExecuteSelectWithFastQueryReadApi() throws SQLException {
+ void testExecuteSelectWithFastQueryReadApi() throws SQLException {
final int rowLimit = 5000;
final String QUERY =
"SELECT * FROM bigquery-public-data.new_york_taxi_trips.tlc_yellow_trips_2017 LIMIT %s";
@@ -3622,7 +3617,7 @@ public void testExecuteSelectWithFastQueryReadApi() throws SQLException {
}
@Test
- public void testExecuteSelectReadApiEmptyResultSet() throws SQLException {
+ void testExecuteSelectReadApiEmptyResultSet() throws SQLException {
ConnectionSettings connectionSettings =
ConnectionSettings.newBuilder()
.setJobTimeoutMs(
@@ -3640,7 +3635,7 @@ public void testExecuteSelectReadApiEmptyResultSet() throws SQLException {
}
@Test
- public void testExecuteSelectWithCredentials() throws SQLException {
+ void testExecuteSelectWithCredentials() throws SQLException {
// This test validate that executeSelect uses the same credential provided by the BigQuery
// object used to create the Connection client.
// This is done the following scenarios:
@@ -3684,7 +3679,7 @@ public void testExecuteSelectWithCredentials() throws SQLException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testQueryTimeStamp() throws InterruptedException {
+ void testQueryTimeStamp() throws InterruptedException {
String query = "SELECT TIMESTAMP '2022-01-24T23:54:25.095574Z'";
Instant beforeQueryInstant = Instant.parse("2022-01-24T23:54:25.095574Z");
long microsBeforeQuery =
@@ -3721,7 +3716,7 @@ public void testQueryTimeStamp() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testQueryCaseInsensitiveSchemaFieldByGetName() throws InterruptedException {
+ void testQueryCaseInsensitiveSchemaFieldByGetName() throws InterruptedException {
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
QueryJobConfiguration config =
QueryJobConfiguration.newBuilder(query).setDefaultDataset(DatasetId.of(DATASET)).build();
@@ -3751,7 +3746,7 @@ public void testQueryCaseInsensitiveSchemaFieldByGetName() throws InterruptedExc
/* TODO(prasmish): replicate bigquery.query part of the test case for executeSelect - modify this test case */
@Test
- public void testQueryExternalHivePartitioningOptionAutoLayout() throws InterruptedException {
+ void testQueryExternalHivePartitioningOptionAutoLayout() throws InterruptedException {
String tableName = "test_queryexternalhivepartition_autolayout_table";
String sourceUri =
"gs://" + CLOUD_SAMPLES_DATA + "/bigquery/hive-partitioning-samples/autolayout/*";
@@ -3787,7 +3782,7 @@ public void testQueryExternalHivePartitioningOptionAutoLayout() throws Interrupt
/* TODO(prasmish): replicate bigquery.query part of the test case for executeSelect - modify this test case */
@Test
- public void testQueryExternalHivePartitioningOptionCustomLayout() throws InterruptedException {
+ void testQueryExternalHivePartitioningOptionCustomLayout() throws InterruptedException {
String tableName = "test_queryexternalhivepartition_customlayout_table";
String sourceUri =
"gs://" + CLOUD_SAMPLES_DATA + "/bigquery/hive-partitioning-samples/customlayout/*";
@@ -3823,7 +3818,7 @@ public void testQueryExternalHivePartitioningOptionCustomLayout() throws Interru
}
@Test
- public void testConnectionImplDryRun() throws SQLException {
+ void testConnectionImplDryRun() throws SQLException {
String query =
String.format(
"select StringField, BigNumericField, BooleanField, BytesField, IntegerField, TimestampField, FloatField, NumericField, TimeField, DateField, DateTimeField , GeographyField, RecordField.BytesField, RecordField.BooleanField, IntegerArrayField from %s where StringField = ? order by TimestampField",
@@ -3848,7 +3843,7 @@ public void testConnectionImplDryRun() throws SQLException {
}
@Test
- public void testConnectionImplDryRunNoQueryParameters() throws SQLException {
+ void testConnectionImplDryRunNoQueryParameters() throws SQLException {
String query =
String.format(
"select StringField, BigNumericField, BooleanField, BytesField, IntegerField, "
@@ -3878,7 +3873,7 @@ public void testConnectionImplDryRunNoQueryParameters() throws SQLException {
@Test
// This test case test the order of the records, making sure that the result is not jumbled up due
// to the multithreaded BigQueryResult implementation
- public void testBQResultSetMultiThreadedOrder() throws SQLException {
+ void testBQResultSetMultiThreadedOrder() throws SQLException {
String query =
"SELECT date FROM "
+ TABLE_ID_LARGE.getTable()
@@ -3905,7 +3900,7 @@ public void testBQResultSetMultiThreadedOrder() throws SQLException {
}
@Test
- public void testBQResultSetPaginationSlowQuery() throws SQLException {
+ void testBQResultSetPaginationSlowQuery() throws SQLException {
String query =
"SELECT date, county, state_name, confirmed_cases, deaths FROM "
+ TABLE_ID_LARGE.getTable()
@@ -3934,7 +3929,7 @@ public void testBQResultSetPaginationSlowQuery() throws SQLException {
}
@Test
- public void testExecuteSelectSinglePageTableRow() throws SQLException {
+ void testExecuteSelectSinglePageTableRow() throws SQLException {
String query =
"select StringField, BigNumericField, BooleanField, BytesField, IntegerField, TimestampField, FloatField, "
+ "NumericField, TimeField, DateField, DateTimeField , GeographyField, RecordField.BytesField, RecordField.BooleanField, IntegerArrayField from "
@@ -3998,7 +3993,7 @@ public void testExecuteSelectSinglePageTableRow() throws SQLException {
}
@Test
- public void testExecuteSelectSinglePageTableRowWithReadAPI() throws SQLException {
+ void testExecuteSelectSinglePageTableRowWithReadAPI() throws SQLException {
String query =
"select StringField, BigNumericField, BooleanField, BytesField, IntegerField, TimestampField, FloatField, "
+ "NumericField, TimeField, DateField, DateTimeField , GeographyField, RecordField.BytesField, RecordField.BooleanField, IntegerArrayField from "
@@ -4063,7 +4058,7 @@ public void testExecuteSelectSinglePageTableRowWithReadAPI() throws SQLException
}
@Test
- public void testConnectionClose() throws SQLException {
+ void testConnectionClose() throws SQLException {
String query =
"SELECT date, county, state_name, confirmed_cases, deaths FROM "
+ TABLE_ID_LARGE.getTable()
@@ -4089,7 +4084,7 @@ public void testConnectionClose() throws SQLException {
}
@Test
- public void testBQResultSetPagination() throws SQLException {
+ void testBQResultSetPagination() throws SQLException {
String query =
"SELECT date, county, state_name, confirmed_cases, deaths FROM "
+ TABLE_ID_LARGE.getTable()
@@ -4115,7 +4110,7 @@ public void testBQResultSetPagination() throws SQLException {
}
@Test
- public void testReadAPIIterationAndOrder()
+ void testReadAPIIterationAndOrder()
throws SQLException { // use read API to read 300K records and check the order
String query =
"SELECT date, county, state_name, confirmed_cases, deaths FROM "
@@ -4152,7 +4147,7 @@ public void testReadAPIIterationAndOrder()
}
@Test
- public void testReadAPIIterationAndOrderAsync()
+ void testReadAPIIterationAndOrderAsync()
throws SQLException,
ExecutionException,
InterruptedException { // use read API to read 300K records and check the order
@@ -4200,7 +4195,7 @@ public void testReadAPIIterationAndOrderAsync()
// TODO(prasmish): Remove this test case if it turns out to be flaky, as expecting the process to
// be uncompleted in 1000ms is nondeterministic! Though very likely it won't be complete in the
// specified amount of time
- public void testExecuteSelectAsyncCancel()
+ void testExecuteSelectAsyncCancel()
throws SQLException,
ExecutionException,
InterruptedException { // use read API to read 300K records and check the order
@@ -4242,7 +4237,7 @@ public void testExecuteSelectAsyncCancel()
// TODO(prasmish): Remove this test case if it turns out to be flaky, as expecting the process to
// be uncompleted in 1000ms is nondeterministic! Though very likely it won't be complete in the
// specified amount of time
- public void testExecuteSelectAsyncTimeout()
+ void testExecuteSelectAsyncTimeout()
throws SQLException,
ExecutionException,
InterruptedException { // use read API to read 300K records and check the order
@@ -4272,7 +4267,7 @@ public void testExecuteSelectAsyncTimeout()
}
@Test
- public void testExecuteSelectWithNamedQueryParametersAsync()
+ void testExecuteSelectWithNamedQueryParametersAsync()
throws BigQuerySQLException, ExecutionException, InterruptedException {
String query =
"SELECT TimestampField, StringField, BooleanField FROM "
@@ -4302,14 +4297,14 @@ public void testExecuteSelectWithNamedQueryParametersAsync()
// Ref: https://github.com/googleapis/java-bigquery/issues/2070. Adding a pre-submit test to see
// if bigquery.createConnection() returns null
@Test
- public void testCreateDefaultConnection() throws BigQuerySQLException {
+ void testCreateDefaultConnection() throws BigQuerySQLException {
Connection connection = bigquery.createConnection();
- assertNotNull("bigquery.createConnection() returned null", connection);
+ assertNotNull(connection, "bigquery.createConnection() returned null");
assertTrue(connection.close());
}
@Test
- public void testReadAPIConnectionMultiClose()
+ void testReadAPIConnectionMultiClose()
throws
SQLException { // use read API to read 300K records, then closes the connection. This test
// repeats it multiple times and assets if the connection was closed
@@ -4345,7 +4340,7 @@ public void testReadAPIConnectionMultiClose()
}
@Test
- public void testExecuteSelectSinglePageTableRowColInd() throws SQLException {
+ void testExecuteSelectSinglePageTableRowColInd() throws SQLException {
String query =
"select StringField, BigNumericField, BooleanField, BytesField, IntegerField, TimestampField, FloatField, "
+ "NumericField, TimeField, DateField, DateTimeField , GeographyField, RecordField.BytesField, RecordField.BooleanField, IntegerArrayField from "
@@ -4424,7 +4419,7 @@ public void testExecuteSelectSinglePageTableRowColInd() throws SQLException {
}
@Test
- public void testExecuteSelectStruct() throws SQLException {
+ void testExecuteSelectStruct() throws SQLException {
String query = "select (STRUCT(\"Vancouver\" as city, 5 as years)) as address";
ConnectionSettings connectionSettings =
ConnectionSettings.newBuilder().setDefaultDataset(DatasetId.of(DATASET)).build();
@@ -4457,7 +4452,7 @@ public void testExecuteSelectStruct() throws SQLException {
}
@Test
- public void testExecuteSelectStructSubField() throws SQLException {
+ void testExecuteSelectStructSubField() throws SQLException {
String query =
"select address.city from (select (STRUCT(\"Vancouver\" as city, 5 as years)) as address)";
ConnectionSettings connectionSettings =
@@ -4483,7 +4478,7 @@ public void testExecuteSelectStructSubField() throws SQLException {
}
@Test
- public void testExecuteSelectArray() throws SQLException {
+ void testExecuteSelectArray() throws SQLException {
String query = "SELECT [1,2,3]";
ConnectionSettings connectionSettings =
ConnectionSettings.newBuilder().setDefaultDataset(DatasetId.of(DATASET)).build();
@@ -4506,7 +4501,7 @@ public void testExecuteSelectArray() throws SQLException {
}
@Test
- public void testExecuteSelectArrayOfStruct() throws SQLException {
+ void testExecuteSelectArrayOfStruct() throws SQLException {
String query =
"SELECT [STRUCT(\"Vancouver\" as city, 5 as years), STRUCT(\"Boston\" as city, 10 as years)]";
ConnectionSettings connectionSettings =
@@ -4546,7 +4541,7 @@ public void testExecuteSelectArrayOfStruct() throws SQLException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testFastQueryMultipleRuns() throws InterruptedException {
+ void testFastQueryMultipleRuns() throws InterruptedException {
String query =
"SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID_FASTQUERY.getTable();
QueryJobConfiguration config =
@@ -4583,7 +4578,7 @@ public void testFastQueryMultipleRuns() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testFastQuerySinglePageDuplicateRequestIds() throws InterruptedException {
+ void testFastQuerySinglePageDuplicateRequestIds() throws InterruptedException {
String query =
"SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID_FASTQUERY.getTable();
QueryJobConfiguration config =
@@ -4616,7 +4611,7 @@ public void testFastQuerySinglePageDuplicateRequestIds() throws InterruptedExcep
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testFastSQLQuery() throws InterruptedException {
+ void testFastSQLQuery() throws InterruptedException {
String query =
"SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID_FASTQUERY.getTable();
QueryJobConfiguration config =
@@ -4646,7 +4641,7 @@ public void testFastSQLQuery() throws InterruptedException {
}
@Test
- public void testProjectIDFastSQLQueryWithJobId() throws InterruptedException {
+ void testProjectIDFastSQLQueryWithJobId() throws InterruptedException {
String random_project_id = "RANDOM_PROJECT_" + UUID.randomUUID().toString().replace('-', '_');
System.out.println(random_project_id);
String query =
@@ -4667,7 +4662,7 @@ public void testProjectIDFastSQLQueryWithJobId() throws InterruptedException {
}
@Test
- public void testLocationFastSQLQueryWithJobId() throws InterruptedException {
+ void testLocationFastSQLQueryWithJobId() throws InterruptedException {
DatasetInfo infoUK =
DatasetInfo.newBuilder(UK_DATASET)
.setDescription(DESCRIPTION)
@@ -4728,7 +4723,7 @@ public void testLocationFastSQLQueryWithJobId() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testFastSQLQueryMultiPage() throws InterruptedException {
+ void testFastSQLQueryMultiPage() throws InterruptedException {
String query =
"SELECT date, county, state_name, county_fips_code, confirmed_cases, deaths FROM "
+ TABLE_ID_LARGE.getTable();
@@ -4761,7 +4756,7 @@ public void testFastSQLQueryMultiPage() throws InterruptedException {
}
@Test
- public void testFastDMLQuery() throws InterruptedException {
+ void testFastDMLQuery() throws InterruptedException {
String tableName = TABLE_ID_FASTQUERY.getTable();
String dmlQuery =
String.format("UPDATE %s.%s SET StringField = 'hello' WHERE TRUE", DATASET, tableName);
@@ -4777,7 +4772,7 @@ public void testFastDMLQuery() throws InterruptedException {
}
@Test
- public void testFastDDLQuery() throws InterruptedException {
+ void testFastDDLQuery() throws InterruptedException {
String tableName = "test_table_fast_query_ddl";
String tableNameFastQuery = TABLE_ID_DDL.getTable();
String ddlQuery =
@@ -4816,7 +4811,7 @@ public void testFastDDLQuery() throws InterruptedException {
}
@Test
- public void testFastQuerySlowDDL() throws InterruptedException {
+ void testFastQuerySlowDDL() throws InterruptedException {
String tableName =
"test_table_fast_query_ddl_slow_" + UUID.randomUUID().toString().substring(0, 8);
// This query take more than 10s to run and should fall back on the old query path
@@ -4849,7 +4844,7 @@ public void testFastQuerySlowDDL() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testFastQueryHTTPException() throws InterruptedException {
+ void testFastQueryHTTPException() throws InterruptedException {
String queryInvalid =
"CREATE OR REPLACE SELECT * FROM UPDATE TABLE SET " + TABLE_ID_FASTQUERY.getTable();
QueryJobConfiguration configInvalidQuery =
@@ -4858,9 +4853,9 @@ public void testFastQueryHTTPException() throws InterruptedException {
.build();
BigQueryException exception =
assertThrows(
- "BigQueryException was expected",
BigQueryException.class,
- () -> bigquery.query(configInvalidQuery));
+ () -> bigquery.query(configInvalidQuery),
+ "BigQueryException was expected");
BigQueryError error = exception.getError();
assertNotNull(error.getMessage());
assertEquals("invalidQuery", error.getReason());
@@ -4874,16 +4869,16 @@ public void testFastQueryHTTPException() throws InterruptedException {
BigQueryException exception1 =
assertThrows(
- "BigQueryException was expected",
BigQueryException.class,
- () -> bigquery.query(configMissingTable));
+ () -> bigquery.query(configMissingTable),
+ "BigQueryException was expected");
BigQueryError error1 = exception1.getError();
assertNotNull(error1.getMessage());
assertEquals("notFound", error1.getReason());
}
@Test
- public void testQuerySessionSupport() throws InterruptedException {
+ void testQuerySessionSupport() throws InterruptedException {
String query = "CREATE TEMPORARY TABLE temptable AS SELECT 17 as foo";
QueryJobConfiguration queryJobConfiguration =
QueryJobConfiguration.newBuilder(query)
@@ -4916,7 +4911,7 @@ public void testQuerySessionSupport() throws InterruptedException {
}
@Test
- public void testLoadSessionSupportWriteChannelConfiguration() throws InterruptedException {
+ void testLoadSessionSupportWriteChannelConfiguration() throws InterruptedException {
TableId sessionTableId = TableId.of("_SESSION", "test_temp_destination_table_from_file");
WriteChannelConfiguration configuration =
@@ -4990,7 +4985,7 @@ public void testLoadSessionSupportWriteChannelConfiguration() throws Interrupted
}
@Test
- public void testLoadSessionSupport() throws InterruptedException {
+ void testLoadSessionSupport() throws InterruptedException {
// Start the session
TableId sessionTableId = TableId.of("_SESSION", "test_temp_destination_table");
LoadJobConfiguration configuration =
@@ -5053,7 +5048,7 @@ public void testLoadSessionSupport() throws InterruptedException {
// }
@Test
- public void testExecuteSelectSessionSupport() throws BigQuerySQLException {
+ void testExecuteSelectSessionSupport() throws BigQuerySQLException {
String query = "SELECT 17 as foo";
ConnectionSettings connectionSettings =
ConnectionSettings.newBuilder()
@@ -5067,7 +5062,7 @@ public void testExecuteSelectSessionSupport() throws BigQuerySQLException {
}
@Test
- public void testDmlStatistics() throws InterruptedException {
+ void testDmlStatistics() throws InterruptedException {
String tableName = TABLE_ID_FASTQUERY.getTable();
// Run a DML statement to UPDATE 2 rows of data
String dmlQuery =
@@ -5089,7 +5084,7 @@ public void testDmlStatistics() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testTransactionInfo() throws InterruptedException {
+ void testTransactionInfo() throws InterruptedException {
String tableName = TABLE_ID_FASTQUERY.getTable();
String transaction =
String.format(
@@ -5111,7 +5106,7 @@ public void testTransactionInfo() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testScriptStatistics() throws InterruptedException {
+ void testScriptStatistics() throws InterruptedException {
String script =
"-- Declare a variable to hold names as an array.\n"
+ "DECLARE top_names ARRAY;\n"
@@ -5164,7 +5159,7 @@ public void testScriptStatistics() throws InterruptedException {
}
@Test
- public void testQueryParameterModeWithDryRun() {
+ void testQueryParameterModeWithDryRun() {
String query =
"SELECT TimestampField, StringField, BooleanField, BigNumericField, BigNumericField1, BigNumericField2, BigNumericField3, BigNumericField4 FROM "
+ TABLE_ID.getTable()
@@ -5191,7 +5186,7 @@ public void testQueryParameterModeWithDryRun() {
}
@Test
- public void testPositionalQueryParameters() throws InterruptedException {
+ void testPositionalQueryParameters() throws InterruptedException {
String query =
"SELECT TimestampField, StringField, BooleanField, BigNumericField, BigNumericField1, BigNumericField2, BigNumericField3, BigNumericField4 FROM "
+ TABLE_ID.getTable()
@@ -5268,7 +5263,7 @@ public void testPositionalQueryParameters() throws InterruptedException {
/* TODO(prasmish): expand below test case with all the fields shown in the above test case */
@Test
- public void testExecuteSelectWithPositionalQueryParameters() throws BigQuerySQLException {
+ void testExecuteSelectWithPositionalQueryParameters() throws BigQuerySQLException {
String query =
"SELECT TimestampField, StringField FROM "
+ TABLE_ID.getTable()
@@ -5288,7 +5283,7 @@ public void testExecuteSelectWithPositionalQueryParameters() throws BigQuerySQLE
}
@Test
- public void testNamedQueryParameters() throws InterruptedException {
+ void testNamedQueryParameters() throws InterruptedException {
String query =
"SELECT TimestampField, StringField, BooleanField FROM "
+ TABLE_ID.getTable()
@@ -5311,7 +5306,7 @@ public void testNamedQueryParameters() throws InterruptedException {
}
@Test
- public void testExecuteSelectWithNamedQueryParameters() throws BigQuerySQLException {
+ void testExecuteSelectWithNamedQueryParameters() throws BigQuerySQLException {
String query =
"SELECT TimestampField, StringField, BooleanField FROM "
+ TABLE_ID.getTable()
@@ -5335,7 +5330,7 @@ public void testExecuteSelectWithNamedQueryParameters() throws BigQuerySQLExcept
/* TODO(prasmish): replicate relevant parts of the test case for executeSelect */
@Test
- public void testStructNamedQueryParameters() throws InterruptedException {
+ void testStructNamedQueryParameters() throws InterruptedException {
QueryParameterValue booleanValue = QueryParameterValue.bool(true);
QueryParameterValue stringValue = QueryParameterValue.string("test-stringField");
QueryParameterValue integerValue = QueryParameterValue.int64(10);
@@ -5362,7 +5357,7 @@ public void testStructNamedQueryParameters() throws InterruptedException {
}
@Test
- public void testRepeatedRecordNamedQueryParameters() throws InterruptedException {
+ void testRepeatedRecordNamedQueryParameters() throws InterruptedException {
String[] stringValues = new String[] {"test-stringField", "test-stringField2"};
List tuples = new ArrayList<>();
for (int i = 0; i < 2; i++) {
@@ -5403,7 +5398,7 @@ public void testRepeatedRecordNamedQueryParameters() throws InterruptedException
}
@Test
- public void testUnnestRepeatedRecordNamedQueryParameter() throws InterruptedException {
+ void testUnnestRepeatedRecordNamedQueryParameter() throws InterruptedException {
Boolean[] boolValues = new Boolean[] {true, false};
List tuples = new ArrayList<>();
for (int i = 0; i < 2; i++) {
@@ -5442,7 +5437,7 @@ public void testUnnestRepeatedRecordNamedQueryParameter() throws InterruptedExce
}
@Test
- public void testUnnestRepeatedRecordNamedQueryParameterFromDataset() throws InterruptedException {
+ void testUnnestRepeatedRecordNamedQueryParameterFromDataset() throws InterruptedException {
TableId tableId = TableId.of(DATASET, "test_repeated_record_table");
setUpRepeatedRecordTable(tableId);
@@ -5548,7 +5543,7 @@ private void setUpRepeatedRecordTable(TableId tableId) {
}
@Test
- public void testEmptyRepeatedRecordNamedQueryParameters() throws InterruptedException {
+ void testEmptyRepeatedRecordNamedQueryParameters() throws InterruptedException {
QueryParameterValue[] tuples = {};
QueryParameterValue repeatedRecord =
@@ -5563,13 +5558,13 @@ public void testEmptyRepeatedRecordNamedQueryParameters() throws InterruptedExce
.build();
assertThrows(
- "an empty array of struct query parameter shouldn't work with 'IN UNNEST'",
BigQueryException.class,
- () -> bigquery.query(config));
+ () -> bigquery.query(config),
+ "an empty array of struct query parameter shouldn't work with 'IN UNNEST'");
}
@Test
- public void testStructQuery() throws InterruptedException {
+ void testStructQuery() throws InterruptedException {
// query into a table
String query = String.format("SELECT RecordField FROM %s.%s", DATASET, TABLE_ID.getTable());
QueryJobConfiguration config =
@@ -5597,7 +5592,7 @@ private static void assertsFieldValue(FieldValue record) {
/* TODO(prasmish): replicate relevant parts of the test case for executeSelect */
@Test
- public void testNestedStructNamedQueryParameters() throws InterruptedException {
+ void testNestedStructNamedQueryParameters() throws InterruptedException {
QueryParameterValue booleanValue = QueryParameterValue.bool(true);
QueryParameterValue stringValue = QueryParameterValue.string("test-stringField");
QueryParameterValue integerValue = QueryParameterValue.int64(10);
@@ -5639,7 +5634,7 @@ public void testNestedStructNamedQueryParameters() throws InterruptedException {
/* TODO(prasmish): replicate relevant parts of the test case for executeSelect */
@Test
- public void testBytesParameter() throws Exception {
+ void testBytesParameter() throws Exception {
String query = "SELECT BYTE_LENGTH(@p) AS length";
QueryParameterValue bytesParameter = QueryParameterValue.bytes(new byte[] {1, 3});
QueryJobConfiguration config =
@@ -5660,7 +5655,7 @@ public void testBytesParameter() throws Exception {
}
@Test
- public void testGeographyParameter() throws Exception {
+ void testGeographyParameter() throws Exception {
// Issues a simple ST_DISTANCE using two geopoints, one being a named geography parameter.
String query =
"SELECT ST_DISTANCE(ST_GEOGFROMTEXT(\"POINT(-122.335503 47.625536)\"), @geo) < 3000 as within3k";
@@ -5683,7 +5678,7 @@ public void testGeographyParameter() throws Exception {
}
@Test
- public void testListJobs() {
+ void testListJobs() {
Page jobs = bigquery.listJobs();
for (Job job : jobs.getValues()) {
assertNotNull(job.getJobId());
@@ -5695,7 +5690,7 @@ public void testListJobs() {
}
@Test
- public void testListJobsWithSelectedFields() {
+ void testListJobsWithSelectedFields() {
Page jobs = bigquery.listJobs(JobListOption.fields(JobField.USER_EMAIL));
for (Job job : jobs.getValues()) {
assertNotNull(job.getJobId());
@@ -5707,7 +5702,7 @@ public void testListJobsWithSelectedFields() {
}
@Test
- public void testListJobsWithCreationBounding() {
+ void testListJobsWithCreationBounding() {
long currentMillis = currentTimeMillis();
long lowerBound = currentMillis - 3600 * 1000;
long upperBound = currentMillis;
@@ -5723,14 +5718,14 @@ public void testListJobsWithCreationBounding() {
foundMax = Math.max(job.getStatistics().getCreationTime(), foundMax);
}
assertTrue(
- "Found min job time " + foundMin + " earlier than " + lowerBound, foundMin >= lowerBound);
+ foundMin >= lowerBound, "Found min job time " + foundMin + " earlier than " + lowerBound);
assertTrue(
- "Found max job time " + foundMax + " later than " + upperBound, foundMax <= upperBound);
- assertTrue("no jobs listed", jobCount > 0);
+ foundMax <= upperBound, "Found max job time " + foundMax + " later than " + upperBound);
+ assertTrue(jobCount > 0, "no jobs listed");
}
@Test
- public void testCreateAndGetJob() throws InterruptedException, TimeoutException {
+ void testCreateAndGetJob() throws InterruptedException, TimeoutException {
String sourceTableName = "test_create_and_get_job_source_table";
String destinationTableName = "test_create_and_get_job_destination_table";
TableId sourceTable = TableId.of(DATASET, sourceTableName);
@@ -5769,8 +5764,7 @@ public void testCreateAndGetJob() throws InterruptedException, TimeoutException
}
@Test
- public void testCreateJobAndWaitForWithRetryOptions()
- throws InterruptedException, TimeoutException {
+ 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 =
@@ -5789,8 +5783,7 @@ public void testCreateJobAndWaitForWithRetryOptions()
}
@Test
- public void testCreateAndGetJobWithSelectedFields()
- throws InterruptedException, TimeoutException {
+ void testCreateAndGetJobWithSelectedFields() throws InterruptedException, TimeoutException {
String sourceTableName = "test_create_and_get_job_with_selected_fields_source_table";
String destinationTableName = "test_create_and_get_job_with_selected_fields_destination_table";
TableId sourceTable = TableId.of(DATASET, sourceTableName);
@@ -5838,7 +5831,7 @@ public void testCreateAndGetJobWithSelectedFields()
}
@Test
- public void testCopyJob() throws InterruptedException, TimeoutException {
+ void testCopyJob() throws InterruptedException, TimeoutException {
String sourceTableName = "test_copy_job_source_table";
String destinationTableName = "test_copy_job_destination_table";
TableId sourceTable = TableId.of(DATASET, sourceTableName);
@@ -5870,7 +5863,7 @@ public void testCopyJob() throws InterruptedException, TimeoutException {
}
@Test
- public void testCopyJobStatistics() throws InterruptedException, TimeoutException {
+ void testCopyJobStatistics() throws InterruptedException, TimeoutException {
String sourceTableName = "test_copy_job_statistics_source_table";
String destinationTableName = "test_copy_job_statistics_destination_table";
@@ -5901,7 +5894,7 @@ public void testCopyJobStatistics() throws InterruptedException, TimeoutExceptio
}
@Test
- public void testSnapshotTableCopyJob() throws InterruptedException {
+ void testSnapshotTableCopyJob() throws InterruptedException {
String sourceTableName = "test_copy_job_base_table";
String ddlTableName = TABLE_ID_DDL.getTable();
// this creates a snapshot table at specified snapshotTime
@@ -5979,7 +5972,7 @@ public void testSnapshotTableCopyJob() throws InterruptedException {
}
@Test
- public void testCopyJobWithLabelsAndExpTime() throws InterruptedException {
+ void testCopyJobWithLabelsAndExpTime() throws InterruptedException {
String destExpiryTime = "2099-12-31T23:59:59.999999999Z";
String sourceTableName =
"test_copy_job_source_table_label" + UUID.randomUUID().toString().substring(0, 8);
@@ -6058,7 +6051,7 @@ public void testQueryJob() throws InterruptedException, TimeoutException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testQueryJobWithConnectionProperties() throws InterruptedException {
+ void testQueryJobWithConnectionProperties() throws InterruptedException {
String tableName = "test_query_job_table_connection_properties";
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
TableId destinationTable = TableId.of(DATASET, tableName);
@@ -6078,7 +6071,7 @@ public void testQueryJobWithConnectionProperties() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testQueryJobWithLabels() throws InterruptedException, TimeoutException {
+ void testQueryJobWithLabels() throws InterruptedException, TimeoutException {
String tableName = "test_query_job_table";
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
Map labels = ImmutableMap.of("test-job-name", "test-query-job");
@@ -6101,7 +6094,7 @@ public void testQueryJobWithLabels() throws InterruptedException, TimeoutExcepti
}
@Test
- public void testQueryJobWithSearchReturnsSearchStatisticsUnused() throws InterruptedException {
+ void testQueryJobWithSearchReturnsSearchStatisticsUnused() throws InterruptedException {
String tableName = "test_query_job_table";
String query =
"SELECT * FROM "
@@ -6131,7 +6124,7 @@ public void testQueryJobWithSearchReturnsSearchStatisticsUnused() throws Interru
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
- public void testQueryJobWithRangePartitioning() throws InterruptedException {
+ void testQueryJobWithRangePartitioning() throws InterruptedException {
String tableName = "test_query_job_table_rangepartitioning";
String query =
"SELECT IntegerField, TimestampField, StringField, BooleanField FROM "
@@ -6156,7 +6149,7 @@ public void testQueryJobWithRangePartitioning() throws InterruptedException {
}
@Test
- public void testLoadJobWithRangePartitioning() throws InterruptedException {
+ void testLoadJobWithRangePartitioning() throws InterruptedException {
String tableName = "test_load_job_table_rangepartitioning";
TableId destinationTable = TableId.of(DATASET, tableName);
try {
@@ -6180,7 +6173,7 @@ public void testLoadJobWithRangePartitioning() throws InterruptedException {
}
@Test
- public void testLoadJobWithDecimalTargetTypes() throws InterruptedException {
+ void testLoadJobWithDecimalTargetTypes() throws InterruptedException {
String tableName = "test_load_job_table_parquet_decimalTargetTypes";
TableId destinationTable = TableId.of(DATASET, tableName);
String sourceUri = "gs://" + CLOUD_SAMPLES_DATA + "/bigquery/numeric/numeric_38_12.parquet";
@@ -6208,7 +6201,7 @@ public void testLoadJobWithDecimalTargetTypes() throws InterruptedException {
}
@Test
- public void testExternalTableWithDecimalTargetTypes() throws InterruptedException {
+ void testExternalTableWithDecimalTargetTypes() throws InterruptedException {
String tableName = "test_create_external_table_parquet_decimalTargetTypes";
TableId destinationTable = TableId.of(DATASET, tableName);
String sourceUri = "gs://" + CLOUD_SAMPLES_DATA + "/bigquery/numeric/numeric_38_12.parquet";
@@ -6228,7 +6221,7 @@ public void testExternalTableWithDecimalTargetTypes() throws InterruptedExceptio
}
@Test
- public void testQueryJobWithDryRun() throws InterruptedException, TimeoutException {
+ void testQueryJobWithDryRun() throws InterruptedException, TimeoutException {
String tableName = "test_query_job_table";
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
TableId destinationTable = TableId.of(DATASET, tableName);
@@ -6246,7 +6239,7 @@ public void testQueryJobWithDryRun() throws InterruptedException, TimeoutExcepti
}
@Test
- public void testExtractJob() throws InterruptedException, TimeoutException {
+ void testExtractJob() throws InterruptedException, TimeoutException {
String tableName = "test_export_job_table";
TableId destinationTable = TableId.of(DATASET, tableName);
Map labels = ImmutableMap.of("test-job-name", "test-load-extract-job");
@@ -6286,7 +6279,7 @@ public void testExtractJob() throws InterruptedException, TimeoutException {
}
@Test
- public void testExtractJobWithModel() throws InterruptedException {
+ void testExtractJobWithModel() throws InterruptedException {
String modelName = RemoteBigQueryHelper.generateModelName();
String sql =
"CREATE MODEL `"
@@ -6323,7 +6316,7 @@ public void testExtractJobWithModel() throws InterruptedException {
}
@Test
- public void testExtractJobWithLabels() throws InterruptedException, TimeoutException {
+ void testExtractJobWithLabels() throws InterruptedException, TimeoutException {
String tableName = "test_export_job_table_label";
Map labels = ImmutableMap.of("test_job_name", "test_export_job");
TableId destinationTable = TableId.of(DATASET, tableName);
@@ -6349,7 +6342,7 @@ public void testExtractJobWithLabels() throws InterruptedException, TimeoutExcep
}
@Test
- public void testCancelJob() throws InterruptedException, TimeoutException {
+ void testCancelJob() throws InterruptedException, TimeoutException {
String destinationTableName = "test_cancel_query_job_table";
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
TableId destinationTable = TableId.of(DATASET, destinationTableName);
@@ -6363,12 +6356,12 @@ public void testCancelJob() throws InterruptedException, TimeoutException {
}
@Test
- public void testCancelNonExistingJob() {
+ void testCancelNonExistingJob() {
assertFalse(bigquery.cancel("test_cancel_non_existing_job"));
}
@Test
- public void testInsertFromFile() throws InterruptedException, IOException, TimeoutException {
+ void testInsertFromFile() throws InterruptedException, IOException, TimeoutException {
String destinationTableName = "test_insert_from_file_table";
TableId tableId = TableId.of(DATASET, destinationTableName);
WriteChannelConfiguration configuration =
@@ -6441,8 +6434,7 @@ public void testInsertFromFile() throws InterruptedException, IOException, Timeo
}
@Test
- public void testInsertFromFileWithLabels()
- throws InterruptedException, IOException, TimeoutException {
+ void testInsertFromFileWithLabels() throws InterruptedException, IOException, TimeoutException {
String destinationTableName = "test_insert_from_file_table_with_labels";
TableId tableId = TableId.of(DATASET, destinationTableName);
WriteChannelConfiguration configuration =
@@ -6472,7 +6464,7 @@ public void testInsertFromFileWithLabels()
}
@Test
- public void testInsertWithDecimalTargetTypes()
+ void testInsertWithDecimalTargetTypes()
throws InterruptedException, IOException, TimeoutException {
String destinationTableName = "test_insert_from_file_table_with_decimal_target_type";
TableId tableId = TableId.of(DATASET, destinationTableName);
@@ -6499,7 +6491,7 @@ public void testInsertWithDecimalTargetTypes()
}
@Test
- public void testLocation() throws Exception {
+ void testLocation() throws Exception {
String location = "EU";
String wrongLocation = "US";
@@ -6563,14 +6555,14 @@ public void testLocation() throws Exception {
.isEmpty();
assertThrows(
- "querying a table with wrong location shouldn't work",
BigQueryException.class,
() ->
otelBigquery
.query(
QueryJobConfiguration.of(query),
JobId.newBuilder().setLocation(wrongLocation).build())
- .iterateAll());
+ .iterateAll(),
+ "querying a table with wrong location shouldn't work");
// Test write
{
@@ -6590,14 +6582,14 @@ public void testLocation() throws Exception {
}
assertThrows(
- "writing to a table with wrong location shouldn't work",
BigQueryException.class,
() -> {
try (TableDataWriteChannel ignore =
otelBigquery.writer(
JobId.newBuilder().setLocation(wrongLocation).build(),
writeChannelConfiguration)) {}
- });
+ },
+ "writing to a table with wrong location shouldn't work");
}
} finally {
RemoteBigQueryHelper.forceDelete(bigquery, datasetName);
@@ -6605,7 +6597,7 @@ public void testLocation() throws Exception {
}
@Test
- public void testWriteChannelPreserveAsciiControlCharacters()
+ void testWriteChannelPreserveAsciiControlCharacters()
throws InterruptedException, IOException, TimeoutException {
String destinationTableName = "test_write_channel_preserve_ascii_control_characters";
TableId tableId = TableId.of(DATASET, destinationTableName);
@@ -6632,7 +6624,7 @@ public void testWriteChannelPreserveAsciiControlCharacters()
}
@Test
- public void testLoadJobPreserveAsciiControlCharacters() throws InterruptedException {
+ void testLoadJobPreserveAsciiControlCharacters() throws InterruptedException {
String destinationTableName = "test_load_job_preserve_ascii_control_characters";
TableId destinationTable = TableId.of(DATASET, destinationTableName);
@@ -6652,7 +6644,7 @@ public void testLoadJobPreserveAsciiControlCharacters() throws InterruptedExcept
}
@Test
- public void testReferenceFileSchemaUriForAvro() {
+ void testReferenceFileSchemaUriForAvro() {
try {
String destinationTableName = "test_reference_file_schema_avro";
TableId tableId = TableId.of(DATASET, destinationTableName);
@@ -6711,7 +6703,7 @@ public void testReferenceFileSchemaUriForAvro() {
}
@Test
- public void testReferenceFileSchemaUriForParquet() {
+ void testReferenceFileSchemaUriForParquet() {
try {
String destinationTableName = "test_reference_file_schema_parquet";
TableId tableId = TableId.of(DATASET, destinationTableName);
@@ -6769,7 +6761,7 @@ public void testReferenceFileSchemaUriForParquet() {
}
@Test
- public void testCreateExternalTableWithReferenceFileSchemaAvro() {
+ void testCreateExternalTableWithReferenceFileSchemaAvro() {
String destinationTableName = "test_create_external_table_reference_file_schema_avro";
TableId tableId = TableId.of(DATASET, destinationTableName);
Schema expectedSchema =
@@ -6808,7 +6800,7 @@ public void testCreateExternalTableWithReferenceFileSchemaAvro() {
}
@Test
- public void testCreateExternalTableWithReferenceFileSchemaParquet() {
+ void testCreateExternalTableWithReferenceFileSchemaParquet() {
String destinationTableName = "test_create_external_table_reference_file_schema_parquet";
TableId tableId = TableId.of(DATASET, destinationTableName);
Schema expectedSchema =
@@ -6849,7 +6841,7 @@ public void testCreateExternalTableWithReferenceFileSchemaParquet() {
}
@Test
- public void testCloneTableCopyJob() throws InterruptedException {
+ void testCloneTableCopyJob() throws InterruptedException {
String sourceTableName = "test_copy_job_base_table";
String ddlTableName = TABLE_ID_DDL.getTable();
String cloneTableName = "test_clone_table";
@@ -6902,15 +6894,15 @@ public void testCloneTableCopyJob() throws InterruptedException {
}
@Test
- public void testHivePartitioningOptionsFieldsFieldExistence() throws InterruptedException {
+ void testHivePartitioningOptionsFieldsFieldExistence() throws InterruptedException {
String tableName = "hive_partitioned_external_table";
// Create data on GCS
String sourceDirectory = "bigquery/hive-partitioning-table/example";
BlobInfo blobInfo = BlobInfo.newBuilder(BUCKET, sourceDirectory + "/key=foo/data.json").build();
assertNotNull(
- "Failed to upload JSON to GCS",
- storage.create(blobInfo, "{\"name\":\"bar\"}".getBytes(StandardCharsets.UTF_8)));
+ storage.create(blobInfo, "{\"name\":\"bar\"}".getBytes(StandardCharsets.UTF_8)),
+ "Failed to upload JSON to GCS");
String sourceUri = "gs://" + BUCKET + "/" + sourceDirectory + "/*";
String sourceUriPrefix = "gs://" + BUCKET + "/" + sourceDirectory + "/";
@@ -6946,7 +6938,7 @@ public void testHivePartitioningOptionsFieldsFieldExistence() throws Interrupted
}
@Test
- public void testPrimaryKey() {
+ void testPrimaryKey() {
String tableName = "test_primary_key";
TableId tableId = TableId.of(DATASET, tableName);
PrimaryKey primaryKey = PrimaryKey.newBuilder().setColumns(Arrays.asList("ID")).build();
@@ -6971,7 +6963,7 @@ public void testPrimaryKey() {
}
@Test
- public void testPrimaryKeyUpdate() {
+ void testPrimaryKeyUpdate() {
String tableName = "test_primary_key_update";
TableId tableId = TableId.of(DATASET, tableName);
PrimaryKey primaryKey =
@@ -7000,7 +6992,7 @@ public void testPrimaryKeyUpdate() {
}
@Test
- public void testForeignKeys() {
+ void testForeignKeys() {
String tableNamePk = "test_foreign_key";
String tableNameFk = "test_foreign_key2";
// TableIds referenced by foreign keys need project id to be specified
@@ -7050,7 +7042,7 @@ public void testForeignKeys() {
}
@Test
- public void testForeignKeysUpdate() {
+ void testForeignKeysUpdate() {
String tableNameFk = "test_foreign_key";
String tableNamePk1 = "test_foreign_key2";
String tableNamePk2 = "test_foreign_key3";
@@ -7148,7 +7140,7 @@ public void testForeignKeysUpdate() {
}
@Test
- public void testAlreadyExistJobExceptionHandling() throws InterruptedException {
+ void testAlreadyExistJobExceptionHandling() throws InterruptedException {
String query =
"SELECT TimestampField, StringField, BooleanField FROM "
+ DATASET
@@ -7175,7 +7167,7 @@ public void testAlreadyExistJobExceptionHandling() throws InterruptedException {
}
@Test
- public void testStatelessQueries() throws InterruptedException {
+ void testStatelessQueries() throws InterruptedException {
// Create local BigQuery to not contaminate global test parameters.
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
BigQuery bigQuery = bigqueryHelper.getOptions().getService();
@@ -7187,8 +7179,8 @@ public void testStatelessQueries() throws InterruptedException {
// Ideally Stateless query will return queryId but in some cases it would return jobId instead
// of queryId based on the query complexity or other factors (job timeout configs).
assertTrue(
- "Exactly one of jobId or queryId should be non-null",
- (tableResult.getJobId() != null) ^ (tableResult.getQueryId() != null));
+ (tableResult.getJobId() != null) ^ (tableResult.getQueryId() != null),
+ "Exactly one of jobId or queryId should be non-null");
// Job creation takes over, no query id is created.
bigQuery.getOptions().setDefaultJobCreationMode(JobCreationMode.JOB_CREATION_REQUIRED);
@@ -7209,7 +7201,7 @@ private TableResult executeSimpleQuery(BigQuery bigQuery) throws InterruptedExce
}
@Test
- public void testTableResultJobIdAndQueryId() throws InterruptedException {
+ void testTableResultJobIdAndQueryId() throws InterruptedException {
// For stateless queries, jobId and queryId are populated based on the following criteria:
// 1. For stateless queries, then queryId is populated.
// 2. For queries that fails the requirements to be stateless, then jobId is populated and
@@ -7232,8 +7224,8 @@ public void testTableResultJobIdAndQueryId() throws InterruptedException {
// Ideally Stateless query will return queryId but in some cases it would return jobId instead
// of queryId based on the query complexity or other factors (job timeout configs).
assertTrue(
- "Exactly one of jobId or queryId should be non-null",
- (result.getJobId() != null) ^ (result.getQueryId() != null));
+ (result.getJobId() != null) ^ (result.getQueryId() != null),
+ "Exactly one of jobId or queryId should be non-null");
// Test scenario 2 by failing stateless check by setting job timeout.
QueryJobConfiguration configQueryWithJob =
@@ -7261,7 +7253,7 @@ public void testTableResultJobIdAndQueryId() throws InterruptedException {
}
@Test
- public void testStatelessQueriesWithLocation() throws Exception {
+ void testStatelessQueriesWithLocation() throws Exception {
// This test validates BigQueryOption location is used for stateless query by verifying that the
// stateless query fails when the BigQueryOption location does not match the dataset location.
String location = "EU";
@@ -7294,7 +7286,6 @@ public void testStatelessQueriesWithLocation() throws Exception {
// Test stateless query when BigQueryOption location does not match dataset location.
assertThrows(
- "querying a table with wrong location shouldn't work",
BigQueryException.class,
() -> {
BigQuery bigQueryWrongLocation =
@@ -7306,14 +7297,15 @@ public void testStatelessQueriesWithLocation() throws Exception {
.getOptions()
.setDefaultJobCreationMode(JobCreationMode.JOB_CREATION_OPTIONAL);
bigQueryWrongLocation.query(QueryJobConfiguration.of(query));
- });
+ },
+ "querying a table with wrong location shouldn't work");
} finally {
RemoteBigQueryHelper.forceDelete(bigQuery, datasetName);
}
}
@Test
- public void testQueryWithTimeout() throws InterruptedException {
+ void testQueryWithTimeout() throws InterruptedException {
// Validate that queryWithTimeout returns either TableResult or Job object
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
@@ -7357,7 +7349,7 @@ public void testQueryWithTimeout() throws InterruptedException {
}
@Test
- public void testUniverseDomainWithInvalidUniverseDomain() {
+ void testUniverseDomainWithInvalidUniverseDomain() {
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
BigQueryOptions bigQueryOptions =
bigqueryHelper.getOptions().toBuilder()
@@ -7368,9 +7360,9 @@ public void testUniverseDomainWithInvalidUniverseDomain() {
BigQueryException exception =
assertThrows(
- "RPCs to invalid universe domain should fail",
BigQueryException.class,
- () -> bigQuery.listDatasets("bigquery-public-data"));
+ () -> bigQuery.listDatasets("bigquery-public-data"),
+ "RPCs to invalid universe domain should fail");
assertEquals(HTTP_UNAUTHORIZED, exception.getCode());
assertNotNull(exception.getMessage());
assertTrue(
@@ -7380,7 +7372,7 @@ public void testUniverseDomainWithInvalidUniverseDomain() {
}
@Test
- public void testInvalidUniverseDomainWithMismatchCredentials() {
+ void testInvalidUniverseDomainWithMismatchCredentials() {
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
BigQueryOptions bigQueryOptions =
bigqueryHelper.getOptions().toBuilder()
@@ -7390,9 +7382,9 @@ public void testInvalidUniverseDomainWithMismatchCredentials() {
BigQueryException exception =
assertThrows(
- "RPCs to invalid universe domain should fail",
BigQueryException.class,
- () -> bigQuery.listDatasets("bigquery-public-data"));
+ () -> bigQuery.listDatasets("bigquery-public-data"),
+ "RPCs to invalid universe domain should fail");
assertEquals(HTTP_UNAUTHORIZED, exception.getCode());
assertNotNull(exception.getMessage());
assertTrue(
@@ -7402,7 +7394,7 @@ public void testInvalidUniverseDomainWithMismatchCredentials() {
}
@Test
- public void testUniverseDomainWithMatchingDomain() {
+ void testUniverseDomainWithMatchingDomain() {
// Test a valid domain using the default credentials and Google default universe domain.
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
BigQueryOptions bigQueryOptions =
@@ -7427,7 +7419,7 @@ public void testUniverseDomainWithMatchingDomain() {
}
@Test
- public void testExternalTableMetadataCachingNotEnable() throws InterruptedException {
+ void testExternalTableMetadataCachingNotEnable() throws InterruptedException {
String tableName = "test_metadata_cache_not_enable";
TableId tableId = TableId.of(DATASET, tableName);
ExternalTableDefinition externalTableDefinition =
@@ -7468,7 +7460,7 @@ public void testExternalTableMetadataCachingNotEnable() throws InterruptedExcept
}
@Test
- public void testExternalMetadataCacheModeFailForNonBiglake() {
+ void testExternalMetadataCacheModeFailForNonBiglake() {
// Validate that MetadataCacheMode is passed to the backend.
// TODO: Enhance this test after BigLake testing infrastructure is inplace.
String tableName = "test_metadata_cache_mode_fail_for_non_biglake";
@@ -7482,9 +7474,9 @@ public void testExternalMetadataCacheModeFailForNonBiglake() {
BigQueryException exception =
assertThrows(
- "BigQueryException was expected",
BigQueryException.class,
- () -> bigquery.create(tableInfo));
+ () -> bigquery.create(tableInfo),
+ "BigQueryException was expected");
BigQueryError error = exception.getError();
assertNotNull(error);
assertEquals("invalid", error.getReason());
@@ -7495,7 +7487,7 @@ public void testExternalMetadataCacheModeFailForNonBiglake() {
}
@Test
- public void testObjectTable() throws InterruptedException {
+ void testObjectTable() throws InterruptedException {
String tableName = "test_object_table";
TableId tableId = TableId.of(DATASET, tableName);
@@ -7538,7 +7530,7 @@ public void testObjectTable() throws InterruptedException {
}
@Test
- public void testQueryExportStatistics() throws InterruptedException {
+ void testQueryExportStatistics() throws InterruptedException {
String query =
String.format(
"EXPORT DATA OPTIONS(\n"
@@ -7562,7 +7554,7 @@ public void testQueryExportStatistics() throws InterruptedException {
}
@Test
- public void testLoadConfigurationFlexibleColumnName() throws InterruptedException {
+ void testLoadConfigurationFlexibleColumnName() throws InterruptedException {
// See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#columnnamecharactermap for
// mapping.
@@ -7618,7 +7610,7 @@ public void testLoadConfigurationFlexibleColumnName() throws InterruptedExceptio
}
@Test
- public void testStatementType() throws InterruptedException {
+ void testStatementType() throws InterruptedException {
String tableName = "test_materialized_view_table_statemnt_type";
String createQuery =
String.format(
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITHighPrecisionTimestamp.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITHighPrecisionTimestamp.java
index 332071a62..4942c3008 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITHighPrecisionTimestamp.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITHighPrecisionTimestamp.java
@@ -15,11 +15,11 @@
*/
package com.google.cloud.bigquery.it;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryException;
@@ -47,9 +47,9 @@
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
public class ITHighPrecisionTimestamp {
@@ -69,7 +69,7 @@ public class ITHighPrecisionTimestamp {
private static final String TIMESTAMP2 = "1970-01-01T12:34:56.123456789123Z";
private static final String TIMESTAMP3 = "2000-01-01T12:34:56.123456789123Z";
- @BeforeClass
+ @BeforeAll
public static void beforeClass() {
BigQueryOptions.Builder builder =
BigQueryOptions.newBuilder()
@@ -110,7 +110,7 @@ public static void beforeClass() {
assertEquals(0, response.getInsertErrors().size());
}
- @AfterClass
+ @AfterAll
public static void afterClass() {
if (bigquery != null) {
bigquery.delete(defaultTableId);
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITNightlyBigQueryTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITNightlyBigQueryTest.java
index 790f35fe5..84e355f9e 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITNightlyBigQueryTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITNightlyBigQueryTest.java
@@ -16,12 +16,13 @@
package com.google.cloud.bigquery.it;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.cloud.ServiceOptions;
import com.google.cloud.bigquery.BigQuery;
@@ -53,6 +54,7 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
+import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Time;
@@ -66,12 +68,12 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.arrow.vector.util.JsonStringArrayList;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.Timeout;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+@Timeout(value = 1800) // 30 min timeout
public class ITNightlyBigQueryTest {
private static final Logger logger = Logger.getLogger(ITNightlyBigQueryTest.class.getName());
private static final String DATASET = RemoteBigQueryHelper.generateDatasetName();
@@ -170,9 +172,7 @@ public class ITNightlyBigQueryTest {
.setDescription("IntervalFieldDescription")
.build());
- @Rule public Timeout globalTimeout = Timeout.seconds(1800); // setting 30 mins as the timeout
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws InterruptedException, IOException {
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
bigquery = bigqueryHelper.getOptions().getService();
@@ -181,17 +181,15 @@ public static void beforeClass() throws InterruptedException, IOException {
populateTestRecords(DATASET, TABLE);
}
- @AfterClass
+ @AfterAll
public static void afterClass() {
try {
if (bigquery != null) {
deleteTable(DATASET, TABLE);
RemoteBigQueryHelper.forceDelete(bigquery, DATASET);
- } else {
- fail("Error clearing the test dataset");
}
} catch (BigQueryException e) {
- fail("Error clearing the test dataset " + e);
+ throw new RuntimeException("Error clearing the test dataset " + e);
}
}
@@ -199,9 +197,8 @@ public static void afterClass() {
public void testInvalidQuery() throws BigQuerySQLException {
Connection connection = getConnection();
try {
- BigQueryResult bigQueryResult = connection.executeSelect(INVALID_QUERY);
- fail("BigQuerySQLException was expected");
- } catch (BigQuerySQLException ex) {
+ BigQuerySQLException ex =
+ assertThrows(BigQuerySQLException.class, () -> connection.executeSelect(INVALID_QUERY));
assertNotNull(ex.getMessage());
assertTrue(ex.getMessage().toLowerCase().contains("unexpected keyword into"));
} finally {
@@ -215,282 +212,300 @@ public void testInvalidQuery() throws BigQuerySQLException {
@Test
public void testIterateAndOrder() throws SQLException {
Connection connection = getConnection();
- BigQueryResult bigQueryResult = connection.executeSelect(QUERY);
- logger.log(Level.INFO, "Query used: {0}", QUERY);
- ResultSet rs = bigQueryResult.getResultSet();
- int cnt = 0;
-
- int prevIntegerFieldVal = 0;
- while (rs.next()) {
- if (cnt == 0) { // first row is supposed to be null
- assertNull(rs.getString("StringField"));
- assertNull(rs.getString("GeographyField"));
- Object intAryField = rs.getObject("IntegerArrayField");
- if (intAryField instanceof JsonStringArrayList) {
- assertEquals(
- new JsonStringArrayList(),
- ((JsonStringArrayList) intAryField)); // null array is returned as an empty array
+ try {
+ BigQueryResult bigQueryResult = connection.executeSelect(QUERY);
+ logger.log(Level.INFO, "Query used: {0}", QUERY);
+ ResultSet rs = bigQueryResult.getResultSet();
+ int cnt = 0;
+
+ int prevIntegerFieldVal = 0;
+ while (rs.next()) {
+ if (cnt == 0) { // first row is supposed to be null
+ assertNull(rs.getString("StringField"));
+ assertNull(rs.getString("GeographyField"));
+ Object intAryField = rs.getObject("IntegerArrayField");
+ if (intAryField instanceof JsonStringArrayList) {
+ assertEquals(
+ new JsonStringArrayList(),
+ ((JsonStringArrayList) intAryField)); // null array is returned as an empty array
+ }
+ assertFalse(rs.getBoolean("BooleanField"));
+ assertTrue(0.0d == rs.getDouble("BigNumericField"));
+ assertTrue(0 == rs.getInt("IntegerField"));
+ assertTrue(0L == rs.getLong("NumericField"));
+ assertNull(rs.getBytes("BytesField"));
+ assertNull(rs.getTimestamp("TimestampField"));
+ assertNull(rs.getTime("TimeField"));
+ assertNull(rs.getDate("DateField"));
+ assertNull(rs.getString("JSONField"));
+ assertFalse(rs.getBoolean("BooleanField_1"));
+ assertNull(rs.getString("StringField_1"));
+ assertNull(rs.getString("hello")); // equivalent of testJsonType
+ assertEquals(0, rs.getInt("id"));
+
+ } else { // remaining rows are supposed to be non null
+ assertNotNull(rs.getString("StringField"));
+ assertNotNull(rs.getString("GeographyField"));
+ assertNotNull(rs.getObject("IntegerArrayField"));
+ assertTrue(rs.getBoolean("BooleanField"));
+ assertTrue(0.0d < rs.getDouble("BigNumericField"));
+ assertTrue(0 < rs.getInt("IntegerField"));
+ assertTrue(0L < rs.getLong("NumericField"));
+ assertNotNull(rs.getBytes("BytesField"));
+ assertNotNull(rs.getTimestamp("TimestampField"));
+ assertNotNull(rs.getTime("TimeField"));
+ assertNotNull(rs.getDate("DateField"));
+ assertNotNull(rs.getString("JSONField"));
+ assertFalse(rs.getBoolean("BooleanField_1"));
+ assertNotNull(rs.getString("StringField_1"));
+
+ // check the order of the records
+ assertTrue(prevIntegerFieldVal < rs.getInt("IntegerField"));
+ prevIntegerFieldVal = rs.getInt("IntegerField");
+
+ testForAllDataTypeValues(rs, cnt); // asserts the value of each row
}
- assertFalse(rs.getBoolean("BooleanField"));
- assertTrue(0.0d == rs.getDouble("BigNumericField"));
- assertTrue(0 == rs.getInt("IntegerField"));
- assertTrue(0L == rs.getLong("NumericField"));
- assertNull(rs.getBytes("BytesField"));
- assertNull(rs.getTimestamp("TimestampField"));
- assertNull(rs.getTime("TimeField"));
- assertNull(rs.getDate("DateField"));
- assertNull(rs.getString("JSONField"));
- assertFalse(rs.getBoolean("BooleanField_1"));
- assertNull(rs.getString("StringField_1"));
- assertNull(rs.getString("hello")); // equivalent of testJsonType
- assertEquals(0, rs.getInt("id"));
-
- } else { // remaining rows are supposed to be non null
- assertNotNull(rs.getString("StringField"));
- assertNotNull(rs.getString("GeographyField"));
- assertNotNull(rs.getObject("IntegerArrayField"));
- assertTrue(rs.getBoolean("BooleanField"));
- assertTrue(0.0d < rs.getDouble("BigNumericField"));
- assertTrue(0 < rs.getInt("IntegerField"));
- assertTrue(0L < rs.getLong("NumericField"));
- assertNotNull(rs.getBytes("BytesField"));
- assertNotNull(rs.getTimestamp("TimestampField"));
- assertNotNull(rs.getTime("TimeField"));
- assertNotNull(rs.getDate("DateField"));
- assertNotNull(rs.getString("JSONField"));
- assertFalse(rs.getBoolean("BooleanField_1"));
- assertNotNull(rs.getString("StringField_1"));
-
- // check the order of the records
- assertTrue(prevIntegerFieldVal < rs.getInt("IntegerField"));
- prevIntegerFieldVal = rs.getInt("IntegerField");
-
- testForAllDataTypeValues(rs, cnt); // asserts the value of each row
+ ++cnt;
}
- ++cnt;
+ assertEquals(LIMIT_RECS, cnt); // all the records were retrieved
+ } finally {
+ connection.close();
}
- assertEquals(LIMIT_RECS, cnt); // all the records were retrieved
- connection.close();
}
/*
This tests for the order of the records using default connection settings as well as the value of the records using testForAllDataTypeValues
*/
@Test
- public void testIterateAndOrderDefaultConnSettings() throws SQLException {
+ void testIterateAndOrderDefaultConnSettings() throws SQLException {
Connection connection = bigquery.createConnection();
- BigQueryResult bigQueryResult = connection.executeSelect(QUERY);
- logger.log(Level.INFO, "Query used: {0}", QUERY);
- ResultSet rs = bigQueryResult.getResultSet();
- int cnt = 0;
-
- int prevIntegerFieldVal = 0;
- while (rs.next()) {
- if (cnt == 0) { // first row is supposed to be null
- assertNull(rs.getString("StringField"));
- assertNull(rs.getString("GeographyField"));
- Object intAryField = rs.getObject("IntegerArrayField");
- if (intAryField instanceof JsonStringArrayList) {
- assertEquals(
- new JsonStringArrayList(),
- ((JsonStringArrayList) intAryField)); // null array is returned as an empty array
+ try {
+ BigQueryResult bigQueryResult = connection.executeSelect(QUERY);
+ logger.log(Level.INFO, "Query used: {0}", QUERY);
+ ResultSet rs = bigQueryResult.getResultSet();
+ int cnt = 0;
+
+ int prevIntegerFieldVal = 0;
+ while (rs.next()) {
+ if (cnt == 0) { // first row is supposed to be null
+ assertNull(rs.getString("StringField"));
+ assertNull(rs.getString("GeographyField"));
+ Object intAryField = rs.getObject("IntegerArrayField");
+ if (intAryField instanceof JsonStringArrayList) {
+ assertEquals(
+ new JsonStringArrayList(),
+ ((JsonStringArrayList) intAryField)); // null array is returned as an empty array
+ }
+ assertFalse(rs.getBoolean("BooleanField"));
+ assertTrue(0.0d == rs.getDouble("BigNumericField"));
+ assertTrue(0 == rs.getInt("IntegerField"));
+ assertTrue(0L == rs.getLong("NumericField"));
+ assertNull(rs.getBytes("BytesField"));
+ assertNull(rs.getTimestamp("TimestampField"));
+ assertNull(rs.getTime("TimeField"));
+ assertNull(rs.getDate("DateField"));
+ assertNull(rs.getString("JSONField"));
+ assertFalse(rs.getBoolean("BooleanField_1"));
+ assertNull(rs.getString("StringField_1"));
+ assertNull(rs.getString("hello")); // equivalent of testJsonType
+ assertEquals(0, rs.getInt("id"));
+
+ } else { // remaining rows are supposed to be non null
+ assertNotNull(rs.getString("StringField"));
+ assertNotNull(rs.getString("GeographyField"));
+ assertNotNull(rs.getObject("IntegerArrayField"));
+ assertTrue(rs.getBoolean("BooleanField"));
+ assertTrue(0.0d < rs.getDouble("BigNumericField"));
+ assertTrue(0 < rs.getInt("IntegerField"));
+ assertTrue(0L < rs.getLong("NumericField"));
+ assertNotNull(rs.getBytes("BytesField"));
+ assertNotNull(rs.getTimestamp("TimestampField"));
+ assertNotNull(rs.getTime("TimeField"));
+ assertNotNull(rs.getDate("DateField"));
+ assertNotNull(rs.getString("JSONField"));
+ assertFalse(rs.getBoolean("BooleanField_1"));
+ assertNotNull(rs.getString("StringField_1"));
+
+ // check the order of the records
+ assertTrue(prevIntegerFieldVal < rs.getInt("IntegerField"));
+ prevIntegerFieldVal = rs.getInt("IntegerField");
+
+ testForAllDataTypeValues(rs, cnt); // asserts the value of each row
}
- assertFalse(rs.getBoolean("BooleanField"));
- assertTrue(0.0d == rs.getDouble("BigNumericField"));
- assertTrue(0 == rs.getInt("IntegerField"));
- assertTrue(0L == rs.getLong("NumericField"));
- assertNull(rs.getBytes("BytesField"));
- assertNull(rs.getTimestamp("TimestampField"));
- assertNull(rs.getTime("TimeField"));
- assertNull(rs.getDate("DateField"));
- assertNull(rs.getString("JSONField"));
- assertFalse(rs.getBoolean("BooleanField_1"));
- assertNull(rs.getString("StringField_1"));
- assertNull(rs.getString("hello")); // equivalent of testJsonType
- assertEquals(0, rs.getInt("id"));
-
- } else { // remaining rows are supposed to be non null
- assertNotNull(rs.getString("StringField"));
- assertNotNull(rs.getString("GeographyField"));
- assertNotNull(rs.getObject("IntegerArrayField"));
- assertTrue(rs.getBoolean("BooleanField"));
- assertTrue(0.0d < rs.getDouble("BigNumericField"));
- assertTrue(0 < rs.getInt("IntegerField"));
- assertTrue(0L < rs.getLong("NumericField"));
- assertNotNull(rs.getBytes("BytesField"));
- assertNotNull(rs.getTimestamp("TimestampField"));
- assertNotNull(rs.getTime("TimeField"));
- assertNotNull(rs.getDate("DateField"));
- assertNotNull(rs.getString("JSONField"));
- assertFalse(rs.getBoolean("BooleanField_1"));
- assertNotNull(rs.getString("StringField_1"));
-
- // check the order of the records
- assertTrue(prevIntegerFieldVal < rs.getInt("IntegerField"));
- prevIntegerFieldVal = rs.getInt("IntegerField");
-
- testForAllDataTypeValues(rs, cnt); // asserts the value of each row
+ ++cnt;
}
- ++cnt;
+ assertEquals(LIMIT_RECS, cnt); // all the records were retrieved
+ } finally {
+ connection.close();
}
- assertEquals(LIMIT_RECS, cnt); // all the records were retrieved
- assertTrue(connection.close());
}
/*
This tests interrupts the execution in between and checks if it has been interrupted successfully while using ReadAPI
*/
@Test
- public void testConnectionClose() throws SQLException {
+ void testConnectionClose() throws SQLException {
Connection connection = bigquery.createConnection();
- assertNotNull("bigquery.createConnection() returned null", connection);
- BigQueryResult bigQueryResult = connection.executeSelect(QUERY);
- logger.log(Level.INFO, "Query used: {0}", QUERY);
- ResultSet rs = bigQueryResult.getResultSet();
- int cnt = 0;
- while (rs.next()) {
- ++cnt;
- if (cnt == 50000) { // interrupt at 50K
- assertTrue(connection.close());
+ try {
+ assertNotNull(connection, "bigquery.createConnection() returned null");
+ BigQueryResult bigQueryResult = connection.executeSelect(QUERY);
+ logger.log(Level.INFO, "Query used: {0}", QUERY);
+ ResultSet rs = bigQueryResult.getResultSet();
+ int cnt = 0;
+ while (rs.next()) {
+ ++cnt;
+ if (cnt == 50000) { // interrupt at 50K
+ assertTrue(connection.close());
+ }
}
+ assertTrue(LIMIT_RECS > cnt);
+ // we stopped at 50K but still we can expect additional records (typically ~100)
+ // to be retrieved
+ // as a number of records should have been already buffered. less than
+ // LIMIT_RECS should be retrieved
+ } finally {
+ connection.close();
}
- assertTrue(
- LIMIT_RECS
- > cnt); // we stopped at 50K but still we can expect additional records (typically ~100)
- // to be retrieved
- // as a number of records should have been already buffered. less than
- // LIMIT_RECS should be retrieved
}
@Test
- public void testMultipleRuns() throws SQLException {
-
- Connection connection = getConnection();
- BigQueryResult bigQueryResult = connection.executeSelect(MULTI_QUERY);
- logger.log(Level.INFO, "Query used: {0}", MULTI_QUERY);
- ResultSet rs = bigQueryResult.getResultSet();
- int cnt = 0;
+ void testMultipleRuns() throws SQLException {
int totalCnt = 0;
-
- int prevIntegerFieldVal = 0;
- while (rs.next()) {
- if (cnt == 0) { // first row is supposed to be null
- assertNull(rs.getString("StringField"));
- assertNull(rs.getString("GeographyField"));
- Object intAryField = rs.getObject("IntegerArrayField");
- if (intAryField instanceof JsonStringArrayList) {
- assertEquals(
- new JsonStringArrayList(),
- ((JsonStringArrayList) intAryField)); // null array is returned as an empty array
+ Connection connection = getConnection();
+ try {
+ BigQueryResult bigQueryResult = connection.executeSelect(MULTI_QUERY);
+ logger.log(Level.INFO, "Query used: {0}", MULTI_QUERY);
+ ResultSet rs = bigQueryResult.getResultSet();
+ int cnt = 0;
+
+ int prevIntegerFieldVal = 0;
+ while (rs.next()) {
+ if (cnt == 0) { // first row is supposed to be null
+ assertNull(rs.getString("StringField"));
+ assertNull(rs.getString("GeographyField"));
+ Object intAryField = rs.getObject("IntegerArrayField");
+ if (intAryField instanceof JsonStringArrayList) {
+ assertEquals(
+ new JsonStringArrayList(),
+ ((JsonStringArrayList) intAryField)); // null array is returned as an empty array
+ }
+ assertFalse(rs.getBoolean("BooleanField"));
+ assertTrue(0.0d == rs.getDouble("BigNumericField"));
+ assertTrue(0 == rs.getInt("IntegerField"));
+ assertTrue(0L == rs.getLong("NumericField"));
+ assertNull(rs.getBytes("BytesField"));
+ assertNull(rs.getTimestamp("TimestampField"));
+ assertNull(rs.getTime("TimeField"));
+ assertNull(rs.getDate("DateField"));
+ assertNull(rs.getString("JSONField"));
+ assertFalse(rs.getBoolean("BooleanField_1"));
+ assertNull(rs.getString("StringField_1"));
+ assertNull(rs.getString("hello")); // equivalent of testJsonType
+ assertEquals(0, rs.getInt("id"));
+
+ } else { // remaining rows are supposed to be non null
+ // check the order of the records
+ assertTrue(prevIntegerFieldVal < rs.getInt("IntegerField"));
+ prevIntegerFieldVal = rs.getInt("IntegerField");
+
+ testForAllDataTypeValues(rs, cnt); // asserts the value of each row
}
- assertFalse(rs.getBoolean("BooleanField"));
- assertTrue(0.0d == rs.getDouble("BigNumericField"));
- assertTrue(0 == rs.getInt("IntegerField"));
- assertTrue(0L == rs.getLong("NumericField"));
- assertNull(rs.getBytes("BytesField"));
- assertNull(rs.getTimestamp("TimestampField"));
- assertNull(rs.getTime("TimeField"));
- assertNull(rs.getDate("DateField"));
- assertNull(rs.getString("JSONField"));
- assertFalse(rs.getBoolean("BooleanField_1"));
- assertNull(rs.getString("StringField_1"));
- assertNull(rs.getString("hello")); // equivalent of testJsonType
- assertEquals(0, rs.getInt("id"));
-
- } else { // remaining rows are supposed to be non null
- // check the order of the records
- assertTrue(prevIntegerFieldVal < rs.getInt("IntegerField"));
- prevIntegerFieldVal = rs.getInt("IntegerField");
-
- testForAllDataTypeValues(rs, cnt); // asserts the value of each row
+ ++cnt;
}
- ++cnt;
+ totalCnt += cnt;
+ } finally {
+ connection.close();
}
- connection.close();
- totalCnt += cnt;
+
// Repeat the same run
- connection = getConnection();
- bigQueryResult = connection.executeSelect(MULTI_QUERY);
- rs = bigQueryResult.getResultSet();
- cnt = 0;
- prevIntegerFieldVal = 0;
- while (rs.next()) {
- if (cnt == 0) { // first row is supposed to be null
- assertNull(rs.getString("StringField"));
- assertNull(rs.getString("GeographyField"));
- Object intAryField = rs.getObject("IntegerArrayField");
- if (intAryField instanceof JsonStringArrayList) {
- assertEquals(
- new JsonStringArrayList(),
- ((JsonStringArrayList) intAryField)); // null array is returned as an empty array
+ Connection connection1 = getConnection();
+ try {
+ BigQueryResult bigQueryResult = connection1.executeSelect(MULTI_QUERY);
+ ResultSet rs = bigQueryResult.getResultSet();
+ int cnt = 0;
+ int prevIntegerFieldVal = 0;
+ while (rs.next()) {
+ if (cnt == 0) { // first row is supposed to be null
+ assertNull(rs.getString("StringField"));
+ assertNull(rs.getString("GeographyField"));
+ Object intAryField = rs.getObject("IntegerArrayField");
+ if (intAryField instanceof JsonStringArrayList) {
+ assertEquals(
+ new JsonStringArrayList(),
+ ((JsonStringArrayList) intAryField)); // null array is returned as an empty array
+ }
+ assertFalse(rs.getBoolean("BooleanField"));
+ assertTrue(0.0d == rs.getDouble("BigNumericField"));
+ assertTrue(0 == rs.getInt("IntegerField"));
+ assertTrue(0L == rs.getLong("NumericField"));
+ assertNull(rs.getBytes("BytesField"));
+ assertNull(rs.getTimestamp("TimestampField"));
+ assertNull(rs.getTime("TimeField"));
+ assertNull(rs.getDate("DateField"));
+ assertNull(rs.getString("JSONField"));
+ assertFalse(rs.getBoolean("BooleanField_1"));
+ assertNull(rs.getString("StringField_1"));
+ assertNull(rs.getString("hello")); // equivalent of testJsonType
+ assertEquals(0, rs.getInt("id"));
+
+ } else { // remaining rows are supposed to be non null
+ // check the order of the records
+ assertTrue(prevIntegerFieldVal < rs.getInt("IntegerField"));
+ prevIntegerFieldVal = rs.getInt("IntegerField");
+
+ testForAllDataTypeValues(rs, cnt); // asserts the value of each row
}
- assertFalse(rs.getBoolean("BooleanField"));
- assertTrue(0.0d == rs.getDouble("BigNumericField"));
- assertTrue(0 == rs.getInt("IntegerField"));
- assertTrue(0L == rs.getLong("NumericField"));
- assertNull(rs.getBytes("BytesField"));
- assertNull(rs.getTimestamp("TimestampField"));
- assertNull(rs.getTime("TimeField"));
- assertNull(rs.getDate("DateField"));
- assertNull(rs.getString("JSONField"));
- assertFalse(rs.getBoolean("BooleanField_1"));
- assertNull(rs.getString("StringField_1"));
- assertNull(rs.getString("hello")); // equivalent of testJsonType
- assertEquals(0, rs.getInt("id"));
-
- } else { // remaining rows are supposed to be non null
- // check the order of the records
- assertTrue(prevIntegerFieldVal < rs.getInt("IntegerField"));
- prevIntegerFieldVal = rs.getInt("IntegerField");
-
- testForAllDataTypeValues(rs, cnt); // asserts the value of each row
+ ++cnt;
}
- ++cnt;
+ totalCnt += cnt;
+ } finally {
+ connection1.close();
}
- connection.close();
- totalCnt += cnt;
assertEquals(MULTI_LIMIT_RECS * 2, totalCnt);
}
@Test
- public void testPositionalParams()
+ void testPositionalParams()
throws SQLException { // Bypasses Read API as it doesnt support Positional Params
Connection connection = getConnection();
- Parameter dateParam =
- Parameter.newBuilder().setValue(QueryParameterValue.date("2022-01-01")).build();
- Parameter boolParam = Parameter.newBuilder().setValue(QueryParameterValue.bool(true)).build();
- Parameter intParam = Parameter.newBuilder().setValue(QueryParameterValue.int64(1)).build();
- Parameter numericParam =
- Parameter.newBuilder().setValue(QueryParameterValue.numeric(new BigDecimal(100))).build();
- List parameters = ImmutableList.of(dateParam, boolParam, intParam, numericParam);
-
- BigQueryResult bigQueryResult = connection.executeSelect(POSITIONAL_QUERY, parameters);
- logger.log(Level.INFO, "Query used: {0}", POSITIONAL_QUERY);
- ResultSet rs = bigQueryResult.getResultSet();
- int cnt = 0;
- while (rs.next()) {
- assertFalse(rs.getBoolean("BooleanField"));
- assertTrue(0.0d <= rs.getDouble("BigNumericField"));
- assertTrue(0 <= rs.getInt("IntegerField"));
- assertTrue(0L <= rs.getLong("NumericField"));
- assertNotNull(rs.getBytes("BytesField"));
- assertNotNull(rs.getTimestamp("TimestampField"));
- assertNotNull(rs.getTime("TimeField"));
- assertNotNull(rs.getDate("DateField"));
- assertNotNull(rs.getString("JSONField"));
- assertTrue(rs.getBoolean("BooleanField_1"));
- assertNotNull(rs.getString("StringField_1"));
- ++cnt;
+ try {
+ Parameter dateParam =
+ Parameter.newBuilder().setValue(QueryParameterValue.date("2022-01-01")).build();
+ Parameter boolParam = Parameter.newBuilder().setValue(QueryParameterValue.bool(true)).build();
+ Parameter intParam = Parameter.newBuilder().setValue(QueryParameterValue.int64(1)).build();
+ Parameter numericParam =
+ Parameter.newBuilder().setValue(QueryParameterValue.numeric(new BigDecimal(100))).build();
+ List parameters = ImmutableList.of(dateParam, boolParam, intParam, numericParam);
+
+ BigQueryResult bigQueryResult = connection.executeSelect(POSITIONAL_QUERY, parameters);
+ logger.log(Level.INFO, "Query used: {0}", POSITIONAL_QUERY);
+ ResultSet rs = bigQueryResult.getResultSet();
+ int cnt = 0;
+ while (rs.next()) {
+ assertFalse(rs.getBoolean("BooleanField"));
+ assertTrue(0.0d <= rs.getDouble("BigNumericField"));
+ assertTrue(0 <= rs.getInt("IntegerField"));
+ assertTrue(0L <= rs.getLong("NumericField"));
+ assertNotNull(rs.getBytes("BytesField"));
+ assertNotNull(rs.getTimestamp("TimestampField"));
+ assertNotNull(rs.getTime("TimeField"));
+ assertNotNull(rs.getDate("DateField"));
+ assertNotNull(rs.getString("JSONField"));
+ assertTrue(rs.getBoolean("BooleanField_1"));
+ assertNotNull(rs.getString("StringField_1"));
+ ++cnt;
+ }
+ assertEquals(MULTI_LIMIT_RECS, cnt);
+ } finally {
+ connection.close();
}
- connection.close();
- assertEquals(MULTI_LIMIT_RECS, cnt);
}
@Test
// This testcase reads rows in bulk for a public table to make sure we do not get
// table-not-found exception. Ref: b/241134681 . This exception has been seen while reading data
// in bulk
- public void testForTableNotFound() throws SQLException {
+ void testForTableNotFound() throws SQLException {
int recordCnt = 50000000; // 5Mil
String query =
String.format(
@@ -578,8 +593,7 @@ private static void testForAllDataTypeValues(ResultSet rs, int cnt) throws SQLEx
// Timestamp, Time, DateTime and Date fields
assertEquals(1649064795000L, rs.getTimestamp("TimestampField").getTime());
- assertEquals(
- java.sql.Date.valueOf("2022-01-01").toString(), rs.getDate("DateField").toString());
+ assertEquals(Date.valueOf("2022-01-01").toString(), rs.getDate("DateField").toString());
// Time is represented independent of a specific date and timezone. For example a 12:11:35 (GMT)
// is returned as
// 17:11:35 (GMT+5:30) . So we need to adjust the offset
@@ -615,15 +629,15 @@ private static void addBatchRecords(TableId tableId) {
for (Map.Entry> entry : response.getInsertErrors().entrySet()) {
logger.log(Level.WARNING, "Exception while adding records {0}", entry.getValue());
}
- fail("Response has errors");
+ throw new BigQueryException(0, "Response has errors");
}
} catch (BigQueryException e) {
logger.log(Level.WARNING, "Exception while adding records {0}", e);
- fail("Error in addBatchRecords");
+ throw new BigQueryException(0, "Error in addBatchRecords", e);
}
}
- private static void createTable(String datasetName, String tableName, Schema schema) {
+ static void createTable(String datasetName, String tableName, Schema schema) {
try {
TableId tableId = TableId.of(datasetName, tableName);
TableDefinition tableDefinition = StandardTableDefinition.of(schema);
@@ -635,7 +649,7 @@ private static void createTable(String datasetName, String tableName, Schema sch
}
}
- public static void deleteTable(String datasetName, String tableName) {
+ static void deleteTable(String datasetName, String tableName) {
try {
assertTrue(bigquery.delete(TableId.of(datasetName, tableName)));
} catch (BigQueryException e) {
@@ -643,7 +657,7 @@ public static void deleteTable(String datasetName, String tableName) {
}
}
- public static void createDataset(String datasetName) {
+ static void createDataset(String datasetName) {
try {
DatasetInfo datasetInfo = DatasetInfo.newBuilder(datasetName).build();
Dataset newDataset = bigquery.create(datasetInfo);
@@ -653,7 +667,7 @@ public static void createDataset(String datasetName) {
}
}
- public static void deleteDataset(String datasetName) {
+ static void deleteDataset(String datasetName) {
try {
DatasetInfo datasetInfo = DatasetInfo.newBuilder(datasetName).build();
assertTrue(bigquery.delete(datasetInfo.getDatasetId()));
@@ -663,7 +677,6 @@ public static void deleteDataset(String datasetName) {
}
private Connection getConnection() {
-
ConnectionSettings connectionSettings =
ConnectionSettings.newBuilder()
.setDefaultDataset(DatasetId.of(DATASET))
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITRemoteUDFTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITRemoteUDFTest.java
index 7a3194e52..6598d0835 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITRemoteUDFTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITRemoteUDFTest.java
@@ -15,8 +15,8 @@
*/
package com.google.cloud.bigquery.it;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.google.cloud.ServiceOptions;
import com.google.cloud.bigquery.BigQuery;
@@ -39,11 +39,11 @@
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class ITRemoteUDFTest {
+class ITRemoteUDFTest {
private static final String ID = UUID.randomUUID().toString().substring(0, 8);
private static final String PROJECT_ID = ServiceOptions.getDefaultProjectId();
@@ -56,8 +56,8 @@ public class ITRemoteUDFTest {
private static Connection connection;
private static BigQuery bigquery;
- @Before
- public void setUp() throws IOException {
+ @BeforeEach
+ void setUp() throws IOException {
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
bigquery = bigqueryHelper.getOptions().getService();
client = ConnectionServiceClient.create();
@@ -76,8 +76,8 @@ public void setUp() throws IOException {
connection = client.createConnection(request);
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
if (bigquery != null) {
RemoteBigQueryHelper.forceDelete(bigquery, ROUTINE_DATASET);
}
@@ -89,7 +89,7 @@ public static void afterClass() {
}
@Test
- public void testRoutineRemoteUDF() {
+ void testRoutineRemoteUDF() {
String routineName = RemoteBigQueryHelper.generateRoutineName();
RoutineId routineId = RoutineId.of(ROUTINE_DATASET, routineName);
Map userDefinedContext =
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java
index eec39f633..3968cd05e 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java
@@ -21,7 +21,7 @@
import com.google.api.services.bigquery.model.DatasetList;
import com.google.api.services.bigquery.model.DatasetReference;
import java.util.Collections;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class HttpBigQueryRpcTest {
@Test
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/testing/RemoteBigQueryHelperTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/testing/RemoteBigQueryHelperTest.java
index 5aadd11e3..589f7ccda 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/testing/RemoteBigQueryHelperTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/testing/RemoteBigQueryHelperTest.java
@@ -16,8 +16,8 @@
package com.google.cloud.bigquery.testing;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQuery.DatasetDeleteOption;
@@ -27,12 +27,12 @@
import java.io.InputStream;
import java.time.Duration;
import java.util.concurrent.ExecutionException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class RemoteBigQueryHelperTest {
private static final String DATASET_NAME = "dataset-name";
diff --git a/pom.xml b/pom.xml
index 4cded9553..f99bb3f90 100644
--- a/pom.xml
+++ b/pom.xml
@@ -110,12 +110,6 @@
-
- junit
- junit
- 4.13.2
- test
-
com.google.truth
truth
@@ -128,12 +122,6 @@
-
- org.mockito
- mockito-core
- 4.11.0
- test
-
com.google.cloud
google-cloud-storage
@@ -152,6 +140,13 @@
2.70.0
test
+
+ org.mockito
+ mockito-bom
+ 4.11.0
+ pom
+ import
+