diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHive.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHive.java index 61f6e8a1933f..e35b868a7168 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHive.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHive.java @@ -1282,17 +1282,15 @@ protected void assertExpectedTableProperties(ConnectorTableProperties actualProp protected void assertExpectedPartitions(ConnectorTableHandle table, Iterable expectedPartitions) { Iterable actualPartitions = ((HiveTableHandle) table).getPartitions().orElseThrow(AssertionError::new); - Map actualById = uniqueIndex(actualPartitions, HivePartition::getPartitionId); - for (Object expected : expectedPartitions) { - assertInstanceOf(expected, HivePartition.class); - HivePartition expectedPartition = (HivePartition) expected; + Map actualById = uniqueIndex(actualPartitions, HivePartition::getPartitionId); + Map expectedById = uniqueIndex(expectedPartitions, HivePartition::getPartitionId); - Object actual = actualById.get(expectedPartition.getPartitionId()); - assertEquals(actual, expected); - assertInstanceOf(actual, HivePartition.class); - HivePartition actualPartition = (HivePartition) actual; + assertThat(actualById).isEqualTo(expectedById); - assertNotNull(actualPartition, "partition " + expectedPartition.getPartitionId()); + // HivePartition.equals doesn't compare all the fields, so let's check them + for (Map.Entry expected : expectedById.entrySet()) { + HivePartition actualPartition = actualById.get(expected.getKey()); + HivePartition expectedPartition = expected.getValue(); assertEquals(actualPartition.getPartitionId(), expectedPartition.getPartitionId()); assertEquals(actualPartition.getKeys(), expectedPartition.getKeys()); assertEquals(actualPartition.getTableName(), expectedPartition.getTableName());