From 9ac577e587647e7b958143050f872520e1ba5089 Mon Sep 17 00:00:00 2001 From: Kyle Bendickson Date: Fri, 24 Jun 2022 09:33:12 -0700 Subject: [PATCH] PR feedback - remove making public last assigned partition id as we're not testing PartitionSpec anyway --- .../org/apache/iceberg/PartitionSpec.java | 3 +-- .../iceberg/rest/RequestResponseTestBase.java | 5 +++-- .../rest/responses/TestLoadTableResponse.java | 20 ++++++++----------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/api/src/main/java/org/apache/iceberg/PartitionSpec.java b/api/src/main/java/org/apache/iceberg/PartitionSpec.java index b217818b7f10..288445f82a17 100644 --- a/api/src/main/java/org/apache/iceberg/PartitionSpec.java +++ b/api/src/main/java/org/apache/iceberg/PartitionSpec.java @@ -102,8 +102,7 @@ public boolean isUnpartitioned() { return !isPartitioned(); } - // visible for testing - public int lastAssignedFieldId() { + int lastAssignedFieldId() { return lastAssignedFieldId; } diff --git a/core/src/test/java/org/apache/iceberg/rest/RequestResponseTestBase.java b/core/src/test/java/org/apache/iceberg/rest/RequestResponseTestBase.java index 4477736d3d7c..7aba92571d07 100644 --- a/core/src/test/java/org/apache/iceberg/rest/RequestResponseTestBase.java +++ b/core/src/test/java/org/apache/iceberg/rest/RequestResponseTestBase.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.assertj.core.api.Assertions; +import org.junit.Assert; import org.junit.Test; public abstract class RequestResponseTestBase { @@ -86,7 +87,7 @@ protected void assertRoundTripSerializesEquallyFrom(String json, T expected) thr T actual = deserialize(json); assertEquals(actual, expected); - // Check that the deserialized value serializes back into the original JSON - Assertions.assertThat(serialize(expected)).isEqualTo(json); + Assert.assertEquals("The serialized version of the Java record should match the original JSON", + serialize(expected), json); } } diff --git a/core/src/test/java/org/apache/iceberg/rest/responses/TestLoadTableResponse.java b/core/src/test/java/org/apache/iceberg/rest/responses/TestLoadTableResponse.java index 4fb114181073..ebddaaec6b2a 100644 --- a/core/src/test/java/org/apache/iceberg/rest/responses/TestLoadTableResponse.java +++ b/core/src/test/java/org/apache/iceberg/rest/responses/TestLoadTableResponse.java @@ -58,15 +58,15 @@ public class TestLoadTableResponse extends RequestResponseTestBase TABLE_PROPS = ImmutableMap.of( "format-version", "1", "owner", "hank"); @@ -98,7 +96,7 @@ public String[] allFieldsFromSpec() { @Override public LoadTableResponse createExampleInstance() { TableMetadata metadata = TableMetadata.newTableMetadata( - TEST_SCHEMA, SPEC_5, SORT_ORDER_3, TEST_TABLE_LOCATION, TABLE_PROPS); + SCHEMA_7, SPEC_5, SORT_ORDER_3, TEST_TABLE_LOCATION, TABLE_PROPS); // Add location TableMetadata metadataWithLocation = TableMetadata .buildFrom(metadata) @@ -132,7 +130,7 @@ public void testRoundTripSerDe() throws JsonProcessingException { // Build table metadata so that its uuid and last updated millis can be reused. TableMetadata metaV1 = TableMetadata.buildFrom( TableMetadata.newTableMetadata( - TEST_SCHEMA, SPEC_5, SORT_ORDER_3, TEST_TABLE_LOCATION, TABLE_PROPS)) + SCHEMA_7, SPEC_5, SORT_ORDER_3, TEST_TABLE_LOCATION, TABLE_PROPS)) .withMetadataLocation(TEST_METADATA_LOCATION) .build(); @@ -283,9 +281,9 @@ private TableMetadata buildV2TableMetadataWithTagsAndSnapshotHistory() { // there. TableMetadata expected = new TableMetadata(TEST_METADATA_LOCATION, 2, UUID.randomUUID().toString(), TEST_TABLE_LOCATION, - SEQ_NO, System.currentTimeMillis(), 3, - 7, ImmutableList.of(TEST_SCHEMA, schema), - 5, ImmutableList.of(SPEC_5), SPEC_5.lastAssignedFieldId(), + SEQ_NO, System.currentTimeMillis(), LAST_ASSIGNED_COLUMN_ID, + 7, ImmutableList.of(SCHEMA_7, schema), + 5, ImmutableList.of(SPEC_5), 999, 3, ImmutableList.of(SORT_ORDER_3), ImmutableMap.of("property", "value"), currentSnapshotId, Arrays.asList(previousSnapshot, currentSnapshot), snapshotLog, ImmutableList.of(), refs, ImmutableList.of()); @@ -330,8 +328,6 @@ void assertEqualTableMetadata(TableMetadata actual, TableMetadata expected) { expected.defaultSpecId(), actual.defaultSpecId()); Assert.assertEquals("PartitionSpec map should match", expected.specs(), actual.specs()); - Assert.assertEquals("lastAssignedFieldId across all PartitionSpecs should match", - expected.spec().lastAssignedFieldId(), actual.lastAssignedPartitionId()); Assert.assertEquals("Default Sort ID should match", expected.defaultSortOrderId(), actual.defaultSortOrderId()); Assert.assertEquals("Sort order should match",