Skip to content

Commit

Permalink
make sure tests work and rename is good
Browse files Browse the repository at this point in the history
  • Loading branch information
allenc3 committed Jul 6, 2020
1 parent a4d9c6e commit a3e3ee2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Expand Up @@ -29,7 +29,7 @@
* This class converts a BQ table schema to protobuf descriptor. The mapping between field types and
* field modes are shown in the ImmutableMaps below.
*/
public class BQTableSchemaToProtoSchema {
public class BQTableSchemaToProtoDescriptor {
private static ImmutableMap<Table.TableFieldSchema.Mode, FieldDescriptorProto.Label>
BQTableSchemaModeMap =
ImmutableMap.of(
Expand Down
Expand Up @@ -60,9 +60,10 @@ private void isDescriptorEqual(Descriptor convertedProto, Descriptor originalPro
// Check type
assertEquals(convertedType, originalType);
// Check mode
assertEquals(originalField.isRepeated(), convertedField.isRepeated());
assertEquals(originalField.isRequired(), convertedField.isRequired());
assertEquals(originalField.isOptional(), convertedField.isOptional());
assertTrue(
(originalField.isRepeated() == convertedField.isRepeated())
|| (originalField.isRequired() == convertedField.isRequired())
|| (originalField.isOptional() == convertedField.isOptional()));
if (convertedType == FieldDescriptor.Type.MESSAGE) {
// Recursively check nested messages
isDescriptorEqual(convertedField.getMessageType(), originalField.getMessageType());
Expand All @@ -82,7 +83,8 @@ public void testBQTableSchemaToProtoDescriptorSimpleTypes() throws Exception {
.build();
Table.TableSchema tableSchema =
Table.TableSchema.newBuilder().addFields(0, tableFieldSchema).build();
Descriptor descriptor = JsonToProtoConverter.ConvertBQTableSchemaToProtoSchema(tableSchema);
Descriptor descriptor =
BQTableSchemaToProtoDescriptor.ConvertBQTableSchemaToProtoSchema(tableSchema);
isDescriptorEqual(descriptor, entry.getValue());
}
}
Expand All @@ -104,7 +106,8 @@ public void testBQTableSchemaToProtoDescriptorStructSimple() throws Exception {
.build();
Table.TableSchema tableSchema =
Table.TableSchema.newBuilder().addFields(0, tableFieldSchema).build();
Descriptor descriptor = JsonToProtoConverter.ConvertBQTableSchemaToProtoSchema(tableSchema);
Descriptor descriptor =
BQTableSchemaToProtoDescriptor.ConvertBQTableSchemaToProtoSchema(tableSchema);
isDescriptorEqual(descriptor, MessageType.getDescriptor());
}

Expand Down Expand Up @@ -137,7 +140,8 @@ public void testBQTableSchemaToProtoDescriptorStructComplex() throws Exception {
.addFields(1, NestingLvl1)
.addFields(2, NestingLvl2)
.build();
Descriptor descriptor = JsonToProtoConverter.ConvertBQTableSchemaToProtoSchema(tableSchema);
Descriptor descriptor =
BQTableSchemaToProtoDescriptor.ConvertBQTableSchemaToProtoSchema(tableSchema);
isDescriptorEqual(descriptor, NestingStackedLvl0.getDescriptor());
}

Expand Down Expand Up @@ -167,7 +171,8 @@ public void testBQTableSchemaToProtoDescriptorOptions() throws Exception {
.addFields(1, repeated)
.addFields(2, optional)
.build();
Descriptor descriptor = JsonToProtoConverter.ConvertBQTableSchemaToProtoSchema(tableSchema);
Descriptor descriptor =
BQTableSchemaToProtoDescriptor.ConvertBQTableSchemaToProtoSchema(tableSchema);
isDescriptorEqual(descriptor, OptionTest.getDescriptor());
}
}

0 comments on commit a3e3ee2

Please sign in to comment.