gemini-code-assist[bot] commented on code in PR #39287:
URL: https://github.com/apache/beam/pull/39287#discussion_r3561503590


##########
sdks/java/io/iceberg/src/test/java/org/apache/beam/sdk/io/iceberg/BeamRowWrapperTest.java:
##########
@@ -85,6 +85,8 @@ public class BeamRowWrapperTest {
                   Types.NestedField.required(1, "nested_int", 
Types.IntegerType.get()))),
           Types.NestedField.required(14, "pass_through_field", 
Types.IntegerType.get()));
   private static final UUID TEST_UUID = UUID.randomUUID();
+  private static final Instant TEST_MICROS_INSTANT =
+      Instant.ofEpochSecond(1_609_459_200L, 123_456_000);

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Using `Instant.parse` with an ISO-8601 UTC string is much more readable and 
self-documenting than manually calculating epoch seconds and nanoseconds with 
`Instant.ofEpochSecond`.
   
   ```suggestion
     private static final Instant TEST_MICROS_INSTANT =
         Instant.parse("2021-01-01T00:00:00.123456Z");
   ```



##########
sdks/java/io/iceberg/src/test/java/org/apache/beam/sdk/io/iceberg/BeamRowWrapperTest.java:
##########
@@ -180,10 +182,7 @@ public void testDateTimeConversion() {
 
   @Test
   public void testMicrosInstantLogicalTypeConversion() {
-    Instant javaInstant = ROW.getLogicalTypeValue(7, Instant.class);
-    long expectedMicrosInstant =
-        TimeUnit.SECONDS.toMicros(javaInstant.getEpochSecond()) + 
javaInstant.getNano() / 1000;
-    assertEquals(expectedMicrosInstant, (long) WRAPPER.get(7, Long.class));
+    assertEquals(1_609_459_200_123_456L, (long) WRAPPER.get(7, Long.class));

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   By explicitly casting the result of `WRAPPER.get(7, Long.class)` to 
`(long)`, any `null` value returned will cause a `NullPointerException` during 
unboxing. Removing the explicit cast allows JUnit to handle the comparison 
directly via autoboxing, which provides a much clearer assertion failure 
message (e.g., showing `null` instead of throwing an NPE) and simplifies the 
code.
   
   ```suggestion
       assertEquals(1_609_459_200_123_456L, WRAPPER.get(7, Long.class));
   ```



-- 
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]

Reply via email to