zratkai commented on code in PR #5421:
URL: https://github.com/apache/hive/pull/5421#discussion_r1744029258


##########
common/src/test/org/apache/hive/common/util/TestDateParser.java:
##########
@@ -45,19 +45,19 @@ void checkInvalidCase(String strValue) {
 
   @Test
   public void testValidCases() throws Exception {
-    checkValidCase("1945-12-31", Date.valueOf("1945-12-31"));
-    checkValidCase("1946-01-01", Date.valueOf("1946-01-01"));
-    checkValidCase("2001-11-12", Date.valueOf("2001-11-12"));
-    checkValidCase("0004-05-06", Date.valueOf("0004-05-06"));
-    checkValidCase("1678-09-10", Date.valueOf("1678-09-10"));
-    checkValidCase("9999-10-11", Date.valueOf("9999-10-11"));
+    checkValidCase("1945-12-31", Date.of(1945,12,31));
+    checkValidCase("1946-01-01", Date.of(1946,1,1));
+    checkValidCase("2001-11-12", Date.of(2001,11,12));
+    checkValidCase("0004-05-06", Date.of(4,5,6));
+    checkValidCase("1678-09-10", Date.of(1678,9,10));
+    checkValidCase("9999-10-11", Date.of(9999,10,11));

Review Comment:
   Actually it checked itself...
   Here is the checkValidCase implementation:
     void checkValidCase(String strValue, Date expected) {
       Date dateValue = DateParser.parseDate(strValue);
       assertEquals(expected, dateValue);
   
       assertTrue(DateParser.parseDate(strValue, date));
       assertEquals(expected, date);
     }
     
     in the first row:
         Date dateValue = DateParser.parseDate(strValue);
    
   then the implementation of DateParser.parseDate :
   
   public static Date parseDate(final String text) {
       Objects.requireNonNull(text);
   
       // Date is a mutable class; do not return cached value
       Date result = new Date();
       return (parseDate(text, result)) ? result : null;
     }
       
   and parseDate uses:
   
      Date date = DATE_CACHE.get(text);
      
    and:
    
      private static final LoadingCache<String, Date> DATE_CACHE =
         CacheBuilder.newBuilder().maximumSize(10 * 365).build(new 
CacheLoader<String, Date>() {
           @Override
           public Date load(final String text) throws Exception {
             return Date.valueOf(text);
           }
         });
         
   So on both sides Date.valueOf was actually used, so it tested itself, which 
makes no sense for a test to test itself.



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to