Skip to content

Commit

Permalink
Fix failing unit tests. (#3546)
Browse files Browse the repository at this point in the history
For TableOptions, explicit null-checking is requred as
javax.annotation.Nonnull does not enforce the check during runtime.

For DiskBackedCorfuClientTest::disableSecondaryIndexes negative test,
open a seperate Corfu Table.
  • Loading branch information
vjeko committed Mar 10, 2023
1 parent 555eda3 commit cf365ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ public static <V extends Message> TableOptions fromProtoSchema(@Nonnull Class<V>
tableOptionsBuilder = tableOptions.toBuilder();
}

V defaultValueMessage = (V) vClass.getMethod("getDefaultInstance").invoke(null);
return tableOptionsBuilder.schemaOptions(defaultValueMessage
.getDescriptorForType()
.getOptions()
.getExtension(CorfuOptions.tableSchema))
.build();
if (vClass != null) { // some test cases pass vClass as null to verify behavior
V defaultValueMessage = (V) vClass.getMethod("getDefaultInstance").invoke(null);
tableOptionsBuilder.schemaOptions(defaultValueMessage
.getDescriptorForType()
.getOptions()
.getExtension(CorfuOptions.tableSchema));
}

return tableOptionsBuilder.build();
}

public static <V extends Message> TableOptions fromProtoSchema(@Nonnull Class<V> vClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,17 +565,17 @@ void disableSecondaryIndexes(
.withMessage("Secondary Index anotherKey is not defined.");
}
{ // Negative test.
final Table<Uuid, ExampleValue, SampleSchema.ManagedResources> table1 =
corfuStore.openTable(namespace, tableName,
final Table<Uuid, ExampleValue, SampleSchema.ManagedResources> table =
corfuStore.openTable(namespace, tableName + tableName,
Uuid.class, ExampleValue.class,
SampleSchema.ManagedResources.class,
// TableOptions includes option to choose - Memory/Disk based corfu table.
TableOptions.fromProtoSchema(ExampleValue.class).toBuilder()
.persistentDataPath(Paths.get(diskBackedDirectory, tableName))
.persistentDataPath(Paths.get(diskBackedDirectory, tableName + tableName))
.build());

// Negative test. No throw.
table1.getByIndex(ANOTHER_KEY_INDEX, 0L);
table.getByIndex(ANOTHER_KEY_INDEX, 0L);
}
}

Expand Down

0 comments on commit cf365ac

Please sign in to comment.