turcsanyip commented on a change in pull request #4781:
URL: https://github.com/apache/nifi/pull/4781#discussion_r564103224



##########
File path: 
nifi-nar-bundles/nifi-extension-utils/nifi-database-utils/src/test/java/org/apache/nifi/util/db/TestJdbcCommon.java
##########
@@ -679,11 +680,12 @@ public void 
testConvertToAvroStreamForDateTimeAsLogicalType() throws SQLExceptio
 
         testConvertToAvroStreamForDateTime(options,
                 (record, date) -> {
+                    java.sql.Date expected = 
DataTypeUtils.convertDateToUTC(date);
                     final int daysSinceEpoch = (int) record.get("date");
                     final long millisSinceEpoch = 
TimeUnit.MILLISECONDS.convert(daysSinceEpoch, TimeUnit.DAYS);
-                    java.sql.Date actual = 
java.sql.Date.valueOf(Instant.ofEpochMilli(millisSinceEpoch).atZone(ZoneOffset.UTC).toLocalDate());
-                    LOGGER.debug("comparing dates, expecting '{}', actual 
'{}'", date, actual);
-                    assertEquals(date, actual);
+                    java.sql.Date actual = new java.sql.Date(millisSinceEpoch);
+                    LOGGER.debug("comparing dates, expecting '{}', actual 
'{}'", expected, actual);
+                    assertEquals(expected, actual);

Review comment:
       These tests (historically) do not assert the raw value (int / long) from 
the Avro record but reconstruct the Date/Time/Timestamp objects and compare 
them with the original objects (which were the inputs of the test cases).
   I believe the reason was to avoid to calculate the days/millis/etc. from the 
test input data which would be a similarly complicated method.
   
   As the test inputs are literals, it is not needed to calculate the expected 
value from code, but it can be determined once and hard coded as literals too. 
What do you think?
   I mean:
   ```
   int expectedDaysSinceEpoch = 17444;
   assertDate.accept(record, expectedDaysSinceEpoch);
   ```




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

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


Reply via email to