jackye1995 commented on code in PR #6559:
URL: https://github.com/apache/iceberg/pull/6559#discussion_r1161328092


##########
core/src/test/java/org/apache/iceberg/view/TestViewMetadata.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.view;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Collection;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.types.Types;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runners.Parameterized;
+
+public class TestViewMetadata {
+
+  private static ViewVersion version1 =
+      ImmutableViewVersion.builder()
+          .versionId(1)
+          .timestampMillis(4353L)
+          .operation("create")
+          .addRepresentations(
+              ImmutableSQLViewRepresentation.builder()
+                  .sql("select 'foo' foo")
+                  .dialect("spark-sql")
+                  .schemaId(1)
+                  .defaultCatalog("some-catalog")
+                  .build())
+          .build();
+  private static ViewHistoryEntry historyEntry1 =
+      
ImmutableViewHistoryEntry.builder().timestampMillis(4353L).versionId(1).build();
+
+  private static ViewVersion version2 =
+      ImmutableViewVersion.builder()
+          .versionId(2)
+          .timestampMillis(5555L)
+          .operation("replace")
+          .addRepresentations(
+              ImmutableSQLViewRepresentation.builder()
+                  .sql("select 1 id, 'abc' data")
+                  .defaultCatalog("some-catalog")
+                  .dialect("spark-sql")
+                  .schemaId(1)
+                  .build())
+          .build();
+  private static ViewHistoryEntry historyEntry2 =
+      
ImmutableViewHistoryEntry.builder().timestampMillis(5555L).versionId(2).build();
+  private static final Schema TEST_SCHEMA =
+      new Schema(
+          1,
+          Types.NestedField.required(1, "x", Types.LongType.get()),
+          Types.NestedField.required(2, "y", Types.LongType.get(), "comment"),
+          Types.NestedField.required(3, "z", Types.LongType.get()));
+
+  @Parameterized.Parameters
+  public static Collection<Object[]> parameters() {
+    return Arrays.asList(new Object[][] {});
+  }
+
+  @Test
+  public void testReadValidViewMetadata() throws Exception {
+    String json = readTableMetadataInputFile("ValidViewMetadata.json");
+    ViewMetadata expectedViewMetadata =
+        ImmutableViewMetadata.builder()
+            .currentSchemaId(1)
+            .schemas(ImmutableList.of(TEST_SCHEMA))
+            .versions(ImmutableList.of(version1, version2))
+            .history(ImmutableList.of(historyEntry1, historyEntry2))
+            .location("s3://bucket/test/location")
+            .properties(ImmutableMap.of("some-key", "some-value"))
+            .currentVersionId(2)
+            .formatVersion(1)
+            .build();
+    assertSameViewMetadata(expectedViewMetadata, 
ViewMetadataParser.fromJson(json));
+  }
+
+  private void assertSameViewMetadata(ViewMetadata expected, ViewMetadata 
actual) {
+    Assert.assertEquals(expected.currentSchemaId(), actual.currentSchemaId());

Review Comment:
   Prefer to use Assertions to deprecate usage of Junit4



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to