Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions google-cloud-bigquerystorage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-util</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>api-common</artifactId>
Expand Down Expand Up @@ -197,6 +193,23 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<!-- The generated tests from gapic-generator are still generated with JUnit4. -->
<!-- Remove once they are migrated to JUnit 5.x+ -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
Expand Down Expand Up @@ -237,12 +250,6 @@
<artifactId>protobuf-java-util</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
Expand Down Expand Up @@ -332,6 +339,10 @@
<artifactId>opentest4j</artifactId>
<version>${opentest4j.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
Expand All @@ -345,6 +356,11 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-vintage-engine.version}</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,22 @@
*/
package com.google.cloud.bigquery.storage.util;

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.protobuf.Duration;
import com.google.protobuf.Parser;
import com.google.rpc.RetryInfo;
import io.grpc.Metadata;
import io.grpc.Status;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;

@RunWith(JUnit4.class)
public class ErrorsTest {
class ErrorsTest {

@Test
public void testRetryableInternalForRstErrors() {
void testRetryableInternalForRstErrors() {
assertTrue(
Errors.isRetryableInternalStatus(
Status.INTERNAL.withDescription(
Expand All @@ -46,21 +43,21 @@ public void testRetryableInternalForRstErrors() {
}

@Test
public void testNonRetryableInternalError() {
void testNonRetryableInternalError() {
assertFalse(Errors.isRetryableInternalStatus(Status.INTERNAL));
assertFalse(Errors.isRetryableInternalStatus(Status.INTERNAL.withDescription("Server error.")));
}

@Test
public void testNonRetryableOtherError() {
void testNonRetryableOtherError() {
assertFalse(
Errors.isRetryableInternalStatus(
Status.DATA_LOSS.withDescription(
"RST_STREAM closed stream. HTTP/2 error code: INTERNAL_ERROR")));
}

@Test
public void testIsRetryableStatus() {
void testIsRetryableStatus() {
Errors.IsRetryableStatusResult result =
Errors.isRetryableStatus(
Status.INTERNAL.withDescription(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package com.google.cloud.bigquery.storage.v1;

import static org.junit.Assert.assertEquals;
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.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.cloud.bigquery.storage.test.JsonTest;
import com.google.cloud.bigquery.storage.test.SchemaTest;
Expand All @@ -29,12 +29,9 @@
import com.google.protobuf.Int64Value;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;

@RunWith(JUnit4.class)
public class BQTableSchemaToProtoDescriptorTest {
class BQTableSchemaToProtoDescriptorTest {
// This is a map between the TableFieldSchema.Type and the descriptor it is supposed to
// produce. The produced descriptor will be used to check against the entry values here.
private static Map<TableFieldSchema.Type, Descriptor> BQTableTypeToCorrectProtoDescriptorTest =
Expand Down Expand Up @@ -82,7 +79,7 @@ private void assertDescriptorsAreEqual(Descriptor expected, Descriptor actual) {
// Check type
FieldDescriptor.Type convertedType = convertedField.getType();
FieldDescriptor.Type originalType = expectedField.getType();
assertEquals(convertedField.getName(), convertedType, originalType);
assertEquals(convertedType, originalType, convertedField.getName());
// Check mode
assertEquals(expectedField.isRepeated(), convertedField.isRepeated());
assertEquals(expectedField.isRequired(), convertedField.isRequired());
Expand All @@ -95,7 +92,7 @@ private void assertDescriptorsAreEqual(Descriptor expected, Descriptor actual) {
}

@Test
public void testSimpleTypes() throws Exception {
void testSimpleTypes() throws Exception {
for (Map.Entry<TableFieldSchema.Type, Descriptor> entry :
BQTableTypeToCorrectProtoDescriptorTest.entrySet()) {
final TableFieldSchema tableFieldSchema =
Expand All @@ -114,7 +111,7 @@ public void testSimpleTypes() throws Exception {

// BQ Timestamp field with higher precision (12) is mapped to a String protobuf type (not int64)
@Test
public void testTimestampType_higherTimestampPrecision()
void testTimestampType_higherTimestampPrecision()
throws Descriptors.DescriptorValidationException {
TableFieldSchema tableFieldSchema =
TableFieldSchema.newBuilder()
Expand All @@ -130,7 +127,7 @@ public void testTimestampType_higherTimestampPrecision()
}

@Test
public void testRange() throws Exception {
void testRange() throws Exception {
final TableSchema tableSchema =
TableSchema.newBuilder()
.addFields(
Expand Down Expand Up @@ -200,7 +197,7 @@ public void testRange() throws Exception {
}

@Test
public void testStructSimple() throws Exception {
void testStructSimple() throws Exception {
final TableFieldSchema stringType =
TableFieldSchema.newBuilder()
.setType(TableFieldSchema.Type.STRING)
Expand All @@ -221,7 +218,7 @@ public void testStructSimple() throws Exception {
}

@Test
public void testStructComplex() throws Exception {
void testStructComplex() throws Exception {
final TableFieldSchema test_int =
TableFieldSchema.newBuilder()
.setType(TableFieldSchema.Type.INT64)
Expand Down Expand Up @@ -467,7 +464,7 @@ public void testStructComplex() throws Exception {
}

@Test
public void testCasingComplexStruct() throws Exception {
void testCasingComplexStruct() throws Exception {
final TableFieldSchema required =
TableFieldSchema.newBuilder()
.setType(TableFieldSchema.Type.INT64)
Expand Down Expand Up @@ -547,7 +544,7 @@ public void testCasingComplexStruct() throws Exception {
}

@Test
public void testOptions() throws Exception {
void testOptions() throws Exception {
final TableFieldSchema required =
TableFieldSchema.newBuilder()
.setType(TableFieldSchema.Type.INT64)
Expand Down Expand Up @@ -578,7 +575,7 @@ public void testOptions() throws Exception {
}

@Test
public void testDescriptorReuseDuringCreation() throws Exception {
void testDescriptorReuseDuringCreation() throws Exception {
final TableFieldSchema test_int =
TableFieldSchema.newBuilder()
.setType(TableFieldSchema.Type.INT64)
Expand Down Expand Up @@ -635,7 +632,7 @@ public void testDescriptorReuseDuringCreation() throws Exception {
}

@Test
public void testNestedFlexibleFieldName() throws Exception {
void testNestedFlexibleFieldName() throws Exception {
final TableFieldSchema stringField =
TableFieldSchema.newBuilder()
.setType(TableFieldSchema.Type.STRING)
Expand Down Expand Up @@ -663,7 +660,7 @@ public void testNestedFlexibleFieldName() throws Exception {
}

@Test
public void timestampField_defaultPrecision() throws Exception {
void timestampField_defaultPrecision() throws Exception {
TableFieldSchema timestampField =
TableFieldSchema.newBuilder()
.setType(TableFieldSchema.Type.TIMESTAMP)
Expand All @@ -676,7 +673,7 @@ public void timestampField_defaultPrecision() throws Exception {
}

@Test
public void timestampField_picosecondPrecision() throws Exception {
void timestampField_picosecondPrecision() throws Exception {
TableFieldSchema timestampField =
TableFieldSchema.newBuilder()
.setType(TableFieldSchema.Type.TIMESTAMP)
Expand All @@ -690,7 +687,7 @@ public void timestampField_picosecondPrecision() throws Exception {
}

@Test
public void timestampField_unexpectedPrecision() throws Exception {
void timestampField_unexpectedPrecision() throws Exception {
TableFieldSchema timestampField =
TableFieldSchema.newBuilder()
.setType(TableFieldSchema.Type.TIMESTAMP)
Expand Down
Loading
Loading