This is an automated email from the ASF dual-hosted git repository.

timbrown pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-xtable.git


The following commit(s) were added to refs/heads/main by this push:
     new 3dd2f4b4 Improved all tests in TestHudiInstantUtils by parameterising 
and adding more test cases (#703)
3dd2f4b4 is described below

commit 3dd2f4b4df25f43ad032035f1719f9d8e459f3da
Author: Monil <mon...@uci.edu>
AuthorDate: Fri May 30 14:07:49 2025 -0700

    Improved all tests in TestHudiInstantUtils by parameterising and adding 
more test cases (#703)
    
    * imprved 2 tests in TestHudiInstantUtils by parameterizing and adding more 
test cases
    
    * fixed style issues
---
 .../apache/xtable/hudi/TestHudiInstantUtils.java   | 73 +++++++++++++++++-----
 1 file changed, 56 insertions(+), 17 deletions(-)

diff --git 
a/xtable-core/src/test/java/org/apache/xtable/hudi/TestHudiInstantUtils.java 
b/xtable-core/src/test/java/org/apache/xtable/hudi/TestHudiInstantUtils.java
index a471c27b..b05b2173 100644
--- a/xtable-core/src/test/java/org/apache/xtable/hudi/TestHudiInstantUtils.java
+++ b/xtable-core/src/test/java/org/apache/xtable/hudi/TestHudiInstantUtils.java
@@ -21,28 +21,67 @@ package org.apache.xtable.hudi;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.time.Instant;
+import java.util.stream.Stream;
 
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
 public class TestHudiInstantUtils {
 
-  @Test
-  public void testParseCommitTimeToInstant() {
-    assertEquals(
-        Instant.parse("2023-01-20T04:43:31.843Z"),
-        HudiInstantUtils.parseFromInstantTime("20230120044331843"));
-    assertEquals(
-        Instant.parse("2023-01-20T04:43:31.999Z"),
-        HudiInstantUtils.parseFromInstantTime("20230120044331"));
+  @ParameterizedTest
+  @MethodSource("instantTimeParseTestCases")
+  public void testParseCommitTimeToInstant(String commitTime, Instant 
expectedInstant) {
+    assertEquals(expectedInstant, 
HudiInstantUtils.parseFromInstantTime(commitTime));
   }
 
-  @Test
-  public void testInstantToCommit() {
-    assertEquals(
-        "20230120044331843",
-        
HudiInstantUtils.convertInstantToCommit(Instant.parse("2023-01-20T04:43:31.843Z")));
-    assertEquals(
-        "20230120044331000",
-        
HudiInstantUtils.convertInstantToCommit(Instant.parse("2023-01-20T04:43:31Z")));
+  private static Stream<Arguments> instantTimeParseTestCases() {
+    return Stream.of(
+        // Original test cases
+        Arguments.of("20230120044331843", 
Instant.parse("2023-01-20T04:43:31.843Z")),
+        Arguments.of("20230120044331", 
Instant.parse("2023-01-20T04:43:31.999Z")),
+
+        // Additional test cases
+        Arguments.of("19700101000000000", 
Instant.parse("1970-01-01T00:00:00.000Z")), // Unix epoch
+        Arguments.of(
+            "19700101000000",
+            Instant.parse("1970-01-01T00:00:00.999Z")), // Unix epoch without 
millis
+        Arguments.of(
+            "20251224235959123",
+            Instant.parse("2025-12-24T23:59:59.123Z")), // Future date with 
millis
+        Arguments.of(
+            "20251224235959",
+            Instant.parse("2025-12-24T23:59:59.999Z")), // Future date without 
millis
+        Arguments.of("20200229235959123", 
Instant.parse("2020-02-29T23:59:59.123Z")), // Leap year
+        Arguments.of(
+            "20200229235959", Instant.parse("2020-02-29T23:59:59.999Z")) // 
Leap year without millis
+        );
+  }
+
+  @ParameterizedTest
+  @MethodSource("instantToCommitTestCases")
+  public void testInstantToCommit(Instant instant, String expectedCommitTime) {
+    assertEquals(expectedCommitTime, 
HudiInstantUtils.convertInstantToCommit(instant));
+  }
+
+  private static Stream<Arguments> instantToCommitTestCases() {
+    return Stream.of(
+        // Original test cases
+        Arguments.of(Instant.parse("2023-01-20T04:43:31.843Z"), 
"20230120044331843"),
+        Arguments.of(Instant.parse("2023-01-20T04:43:31Z"), 
"20230120044331000"),
+
+        // Additional test cases
+        Arguments.of(Instant.parse("1970-01-01T00:00:00Z"), 
"19700101000000000"), // Unix epoch
+        Arguments.of(
+            Instant.parse("1970-01-01T00:00:00.123Z"),
+            "19700101000000123"), // Unix epoch with millis
+        Arguments.of(Instant.parse("2025-12-24T23:59:59Z"), 
"20251224235959000"), // Future date
+        Arguments.of(
+            Instant.parse("2025-12-24T23:59:59.999Z"),
+            "20251224235959999"), // Future date with max millis
+        Arguments.of(Instant.parse("2020-02-29T23:59:59Z"), 
"20200229235959000"), // Leap year
+        Arguments.of(
+            Instant.parse("2021-12-31T23:59:59.555Z"), "20211231235959555") // 
Year end with millis
+        );
   }
 }

Reply via email to