Skip to content

Commit

Permalink
Fix warnings displayed by IntelliJ (#1124)
Browse files Browse the repository at this point in the history
  • Loading branch information
brfrn169 authored Oct 11, 2023
1 parent 1864773 commit 73ba63b
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static Properties getProperties(String testName) {
if (databasePrefix.isPresent()) {
// Add the prefix and testName as a metadata database suffix
props.setProperty(
CosmosConfig.TABLE_METADATA_DATABASE,
CosmosConfig.METADATA_DATABASE,
databasePrefix.get() + CosmosAdmin.METADATA_DATABASE + "_" + testName);

props.setProperty(
Expand All @@ -41,7 +41,7 @@ public static Properties getProperties(String testName) {
} else {
// Add testName as a metadata database suffix
props.setProperty(
CosmosConfig.TABLE_METADATA_DATABASE, CosmosAdmin.METADATA_DATABASE + "_" + testName);
CosmosConfig.METADATA_DATABASE, CosmosAdmin.METADATA_DATABASE + "_" + testName);
}

return props;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static Properties getProperties(String testName) {

// Add testName as a metadata namespace suffix
props.setProperty(
DynamoConfig.TABLE_METADATA_NAMESPACE, DynamoAdmin.METADATA_NAMESPACE + "_" + testName);
DynamoConfig.METADATA_NAMESPACE, DynamoAdmin.METADATA_NAMESPACE + "_" + testName);

return props;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static Properties getProperties(String testName) {
props.setProperty(DatabaseConfig.STORAGE, "jdbc");

// Add testName as a metadata schema suffix
props.setProperty(JdbcConfig.TABLE_METADATA_SCHEMA, JdbcAdmin.METADATA_SCHEMA + "_" + testName);
props.setProperty(JdbcConfig.METADATA_SCHEMA, JdbcAdmin.METADATA_SCHEMA + "_" + testName);

return props;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public static Properties getPropertiesForJdbc(String testName) {
properties.setProperty(DatabaseConfig.STORAGE, "jdbc");

// Add testName as a metadata schema suffix
properties.setProperty(
JdbcConfig.TABLE_METADATA_SCHEMA, JdbcAdmin.METADATA_SCHEMA + "_" + testName);
properties.setProperty(JdbcConfig.METADATA_SCHEMA, JdbcAdmin.METADATA_SCHEMA + "_" + testName);

return properties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public interface DistributedStorageAdmin extends Admin {
* @throws IllegalArgumentException if the table does not exist
* @throws IllegalStateException if the table does not meet the requirement of ScalarDB table
* @throws ExecutionException if the operation fails
* @return import table metadata in the ScalarDB format
*/
TableMetadata getImportTableMetadata(String namespace, String table) throws ExecutionException;

Expand All @@ -58,6 +59,8 @@ public interface DistributedStorageAdmin extends Admin {
*
* @param namespace namespace name of import table
* @param table import table name
* @param columnName name of the column to be added
* @param columnType type of the column to be added
* @throws IllegalArgumentException if the table does not exist
* @throws ExecutionException if the operation fails
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public static boolean isTransactionTableMetadata(TableMetadata tableMetadata) {
/**
* Get non-primary key columns from the specified table metadata.
*
* @param tableMetadata a table metadata
* @return a set of non-primary key column names
*/
public static Set<String> getNonPrimaryKeyColumns(TableMetadata tableMetadata) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
/**
* Abstraction that defines unit tests for the {@link CosmosAdmin}. The class purpose is to be able
* to run the {@link CosmosAdmin} unit tests with different values for the {@link CosmosConfig},
* notably {@link CosmosConfig#TABLE_METADATA_DATABASE}.
* notably {@link CosmosConfig#METADATA_DATABASE}.
*/
public abstract class CosmosAdminTestBase {
@Mock private CosmosClient client;
Expand All @@ -81,10 +81,9 @@ public void setUp() throws Exception {
}

/**
* This sets the {@link CosmosConfig#TABLE_METADATA_DATABASE} value that will be used to run the
* tests.
* This sets the {@link CosmosConfig#METADATA_DATABASE} value that will be used to run the tests.
*
* @return {@link CosmosConfig#TABLE_METADATA_DATABASE} value
* @return {@link CosmosConfig#METADATA_DATABASE} value
*/
abstract Optional<String> getTableMetadataDatabaseConfig();

Expand Down Expand Up @@ -464,6 +463,7 @@ public void dropTable_WithNoMetadataLeft_ShouldDropContainerAndDeleteTableMetada
verify(metadataContainer).delete();
}

@Test
public void dropTable_WithMetadataLeft_ShouldDropContainerAndOnlyDeleteMetadata()
throws ExecutionException {
// Arrange
Expand Down Expand Up @@ -513,6 +513,7 @@ public void dropTable_WithMetadataLeft_ShouldDropContainerAndOnlyDeleteMetadata(
CosmosContainer namespacesContainer = mock(CosmosContainer.class);
when(metadataDatabase.getContainer(anyString())).thenReturn(namespacesContainer);

@SuppressWarnings("unchecked")
CosmosPagedIterable<Object> pagedIterable = mock(CosmosPagedIterable.class);
when(namespacesContainer.queryItems(anyString(), any(), any())).thenReturn(pagedIterable);
when(pagedIterable.stream()).thenReturn(Stream.empty());
Expand Down Expand Up @@ -540,6 +541,7 @@ public void dropNamespace_WithExistingDatabaseAndSomeNamespacesLeft_ShouldDropDa
CosmosContainer namespacesContainer = mock(CosmosContainer.class);
when(metadataDatabase.getContainer(anyString())).thenReturn(namespacesContainer);

@SuppressWarnings("unchecked")
CosmosPagedIterable<Object> pagedIterable = mock(CosmosPagedIterable.class);
when(namespacesContainer.queryItems(anyString(), any(), any())).thenReturn(pagedIterable);
when(pagedIterable.stream()).thenReturn(Stream.of(mock(Object.class)));
Expand Down Expand Up @@ -964,6 +966,8 @@ public void getNamespaceNames_ShouldWorkProperly() throws ExecutionException {
CosmosContainer namespacesContainer = mock(CosmosContainer.class);
when(client.getDatabase(anyString())).thenReturn(metadataDatabase);
when(metadataDatabase.getContainer(anyString())).thenReturn(namespacesContainer);

@SuppressWarnings("unchecked")
CosmosPagedIterable<CosmosNamespace> pagedIterable = mock(CosmosPagedIterable.class);
when(namespacesContainer.queryItems(anyString(), any(), eq(CosmosNamespace.class)))
.thenReturn(pagedIterable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2463,15 +2463,6 @@ private void getNamespaceNames_forX_ShouldReturnNamespaceNames(
assertThat(actualNamespaceNames).containsOnly(namespace1, namespace2);
}

private List<Statement> prepareMockStatements(int count) {
List<Statement> statements = new ArrayList<>();
for (int i = 0; i < count; i++) {
Statement statement = mock(Statement.class);
statements.add(statement);
}
return statements;
}

@Test
public void getImportTableMetadata_ForX_ShouldWorkProperly()
throws SQLException, ExecutionException {
Expand Down Expand Up @@ -2982,6 +2973,7 @@ private String getBooleanString(RdbEngine rdbEngine, boolean value) {
private RdbEngineStrategy getRdbEngineStrategy(RdbEngine rdbEngine) {
return RDB_ENGINES.getOrDefault(rdbEngine, RdbEngineFactory.create("jdbc:mysql:"));
}

// Utility class used to mock ResultSet for a "select * from" query on the metadata table
static class SelectAllFromMetadataTableResultSetMocker
implements org.mockito.stubbing.Answer<Object> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Integer call() throws SchemaLoaderException {
// For test
if (tableMetadataDatabasePrefix != null) {
props.setProperty(
CosmosConfig.TABLE_METADATA_DATABASE,
CosmosConfig.METADATA_DATABASE,
tableMetadataDatabasePrefix + CosmosAdmin.METADATA_DATABASE);
}
if (coordinatorNamespacePrefix != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public static Properties getServer1Properties(String testName) {
properties.setProperty(ServerConfig.PROMETHEUS_EXPORTER_PORT, "-1");

// Add testName as a metadata schema suffix
properties.setProperty(
JdbcConfig.TABLE_METADATA_SCHEMA, JdbcAdmin.METADATA_SCHEMA + "_" + testName);
properties.setProperty(JdbcConfig.METADATA_SCHEMA, JdbcAdmin.METADATA_SCHEMA + "_" + testName);

return properties;
}
Expand Down

0 comments on commit 73ba63b

Please sign in to comment.