Skip to content

Commit

Permalink
Replace hasSize(0) with isEmpty()
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Nov 1, 2024
1 parent fee08fb commit 54b9b9e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public void testContainsAndRemove()
assertThat(queue.remove("test" + i)).isTrue();
}
assertThat(queue).isEmpty();
assertThat(queue).hasSize(0);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public void testAddLocation()
processor.setComplete(location2);
buffer.whenTaskFinished(task2).get(10, SECONDS);
assertThat(buffer.getFinishedTasks()).containsExactlyInAnyOrder(task1, task2);
assertThat(buffer.getPages().get(task2)).hasSize(0);
assertThat(buffer.getPages().get(task2)).isEmpty();

exchangeClient.addLocation(task3, location3);
assertThat(buffer.getAllTasks()).containsExactlyInAnyOrder(task1, task2, task3);
Expand Down Expand Up @@ -681,7 +681,7 @@ public void testTaskFailure()

assertThat(buffer.getFinishedTasks()).containsExactly(task1);
assertThat(buffer.getFailedTasks().keySet()).containsExactly(task2);
assertThat(buffer.getPages().get(task2)).hasSize(0);
assertThat(buffer.getPages().get(task2)).isEmpty();

exchangeClient.addLocation(task3, location3);
assertThat(buffer.getAllTasks()).containsExactlyInAnyOrder(task1, task2, task3);
Expand All @@ -694,8 +694,8 @@ public void testTaskFailure()

assertThat(buffer.getFinishedTasks()).containsExactly(task1);
assertThat(buffer.getFailedTasks().keySet()).containsExactlyInAnyOrder(task2, task3);
assertThat(buffer.getPages().get(task2)).hasSize(0);
assertThat(buffer.getPages().get(task3)).hasSize(0);
assertThat(buffer.getPages().get(task2)).isEmpty();
assertThat(buffer.getPages().get(task3)).isEmpty();

assertThat(latch.await(10, SECONDS)).isTrue();
assertThat(failedTasks).isEqualTo(ImmutableSet.of(task2, task3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ public void testTableHandleOfQueryCached()
assertThat(cachingJdbcClient.getTableHandle(SESSION, query))
.isEqualTo(cachedTable);
assertThat(getColumns(SESSION, cachingJdbcClient, cachedTable))
.hasSize(0); // phantom_table has no columns
.isEmpty(); // phantom_table has no columns
});
assertCacheStats(cachingJdbcClient)
// cache is not used, as the table handle has the columns list embedded
.afterRunning(() -> {
assertThat(getColumns(SESSION, cachingJdbcClient, cachedTable))
.hasSize(0); // phantom_table has no columns
.isEmpty(); // phantom_table has no columns
});
assertStatisticsCacheStats(cachingJdbcClient)
.hits(1)
Expand All @@ -247,13 +247,13 @@ public void testTableHandleOfQueryCached()
assertThat(cachingJdbcClient.getTableHandle(SESSION, query))
.isEqualTo(cachedTable);
assertThat(getColumns(SESSION, cachingJdbcClient, cachedTable))
.hasSize(0); // phantom_table has no columns
.isEmpty(); // phantom_table has no columns
});
assertCacheStats(cachingJdbcClient)
// cache is not used, as the table handle has the columns list embedded
.afterRunning(() -> {
assertThat(getColumns(SESSION, cachingJdbcClient, cachedTable))
.hasSize(0); // phantom_table has no columns
.isEmpty(); // phantom_table has no columns
});
assertStatisticsCacheStats(cachingJdbcClient)
.misses(1)
Expand All @@ -270,13 +270,13 @@ public void testTableHandleOfQueryCached()
assertThat(cachingJdbcClient.getTableHandle(SESSION, query))
.isEqualTo(cachedTable);
assertThat(getColumns(SESSION, cachingJdbcClient, cachedTable))
.hasSize(0); // phantom_table has no columns
.isEmpty(); // phantom_table has no columns
});
assertCacheStats(cachingJdbcClient)
// cache is not used, as the table handle has the columns list embedded
.afterRunning(() -> {
assertThat(getColumns(SESSION, cachingJdbcClient, cachedTable))
.hasSize(0); // phantom_table has no columns
.isEmpty(); // phantom_table has no columns
});
assertStatisticsCacheStats(cachingJdbcClient)
.misses(1)
Expand Down Expand Up @@ -304,7 +304,7 @@ public void testProcedureHandleCached()
.loads(1)
.calling(() -> cachingJdbcClient.getProcedureHandle(SESSION, query));
assertThat(cachedProcedure.getColumns().orElseThrow())
.hasSize(0);
.isEmpty();

dropProcedure("test_procedure");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ public void testCheckpointing()
assertUpdate(format("DELETE FROM %s WHERE a_string = 'kreta'", tableName), 1);

// sanity check
assertThat(listCheckpointFiles(transactionLogDirectory)).hasSize(0);
assertThat(listCheckpointFiles(transactionLogDirectory)).isEmpty();
assertQuery("SELECT * FROM " + tableName, "VALUES (1,'ala'), (3,'psa'), (2, 'bobra')");

// fill to first checkpoint which reads JSON files
Expand Down Expand Up @@ -1458,7 +1458,7 @@ public void testCreateOrReplaceCheckpointing()
String transactionLogDirectory = format("%s/_delta_log", tableName);

assertUpdate(format("INSERT INTO %s VALUES (2, 'kota'), (3, 'psa')", tableName), 2);
assertThat(listCheckpointFiles(transactionLogDirectory)).hasSize(0);
assertThat(listCheckpointFiles(transactionLogDirectory)).isEmpty();
assertQuery("SELECT * FROM " + tableName, "VALUES (1,'ala'), (2,'kota'), (3, 'psa')");

// replace table
Expand Down Expand Up @@ -1656,7 +1656,7 @@ public void testStatsSplitPruningBasedOnSepCreatedCheckpoint()
assertUpdate(format("INSERT INTO %s VALUES (10, 'kota')", tableName), 1);

// there should not be a checkpoint yet
assertThat(listCheckpointFiles(transactionLogDirectory)).hasSize(0);
assertThat(listCheckpointFiles(transactionLogDirectory)).isEmpty();
testCountQuery(format("SELECT count(*) FROM %s WHERE a_number <= 3", tableName), 3, 3);

// perform one more insert to ensure checkpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void removeTestData()
if (adlsDirectory != null) {
hiveHadoop.executeInContainerFailOnError("hadoop", "fs", "-rm", "-f", "-r", adlsDirectory);
}
assertThat(azureContainerClient.listBlobsByHierarchy(bucketName + "/").stream()).hasSize(0);
assertThat(azureContainerClient.listBlobsByHierarchy(bucketName + "/")).isEmpty();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,10 +887,10 @@ public void testDeletingEntirePartitionedTable()

assertThat(this.loadTable(tableName).newScan().planFiles()).hasSize(5);
assertUpdate("DELETE FROM " + tableName + " WHERE regionkey < 10", "SELECT count(*) FROM nation WHERE regionkey < 10");
assertThat(this.loadTable(tableName).newScan().planFiles()).hasSize(0);
assertThat(this.loadTable(tableName).newScan().planFiles()).isEmpty();
assertUpdate("DELETE FROM " + tableName + " WHERE regionkey < 10");
assertThat(query("SELECT * FROM " + tableName)).returnsEmptyResult();
assertThat(this.loadTable(tableName).newScan().planFiles()).hasSize(0);
assertThat(this.loadTable(tableName).newScan().planFiles()).isEmpty();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void testSparkCanReadTrinoCheckpoint()
row(4, "lwa"));

// sanity check
assertThat(listCheckpointFiles(bucketName, tableDirectory)).hasSize(0);
assertThat(listCheckpointFiles(bucketName, tableDirectory)).isEmpty();
assertThat(onDelta().executeQuery("SELECT * FROM default." + tableName))
.containsOnly(expectedRows);
assertThat(onTrino().executeQuery("SELECT * FROM delta.default." + tableName))
Expand Down Expand Up @@ -254,7 +254,7 @@ private void trinoUsesCheckpointInterval(String deltaTableProperties)

// sanity check
fillWithInserts("delta.default." + tableName, "(1, 'trino')", 4);
assertThat(listCheckpointFiles(bucketName, tableDirectory)).hasSize(0);
assertThat(listCheckpointFiles(bucketName, tableDirectory)).isEmpty();
assertThat(onTrino().executeQuery("SELECT * FROM delta.default." + tableName + " WHERE a_string <> 'trino'")).hasNoRows();

// fill to first checkpoint using Trino
Expand Down Expand Up @@ -301,7 +301,7 @@ public void testDatabricksUsesCheckpointInterval()
// sanity check
onDelta().executeQuery("INSERT INTO default." + tableName + " VALUES (1, 'databricks')");
onDelta().executeQuery("INSERT INTO default." + tableName + " VALUES (2, 'databricks')");
assertThat(listCheckpointFiles(bucketName, tableDirectory)).hasSize(0);
assertThat(listCheckpointFiles(bucketName, tableDirectory)).isEmpty();
assertThat(onTrino().executeQuery("SELECT * FROM delta.default." + tableName + " WHERE a_string <> 'databricks'")).hasNoRows();

// fill to first checkpoint using Databricks
Expand Down

0 comments on commit 54b9b9e

Please sign in to comment.