bito-code-review[bot] commented on PR #15612:
URL: https://github.com/apache/grails-core/pull/15612#issuecomment-4354665418

   <!-- Bito Reply -->
   The suggestion modifies the test to pass null as the date value when date is 
null, and uses the captured calendar time as the default parameter in 
getDatePickerOutput. This preserves the original defaulting logic inside the 
datePicker tag (treating null as 'no value provided' that defaults to now) 
while eliminating the race condition by using a single captured instant for 
both the tag output and assertions. Applying it improves the test's reliability 
without altering the intended behavior.
   
   
**grails-gsp/plugin/src/test/groovy/org/grails/web/taglib/FormTagLib2Tests.groovy**
   ```
   Calendar calendar = new GregorianCalendar()
           Object resolvedDate = date
           if (date == null) {
               resolvedDate = calendar.getTime()
           } else if (date instanceof Date) {
               calendar.setTime(date)
           } /*else if (date instanceof TemporalAccessor) {
               ZonedDateTime zonedDateTime
               if (date instanceof LocalDateTime) {
                   zonedDateTime = ZonedDateTime.of(date, 
ZoneId.systemDefault())
               } else if (date instanceof LocalDate) {
                   zonedDateTime = ZonedDateTime.of(date, LocalTime.MIN, 
ZoneId.systemDefault())
               } else {
                   zonedDateTime = ZonedDateTime.from(date)
               }
               calendar = GregorianCalendar.from(zonedDateTime)
           }*/
   
           Document document = getDatePickerOutput(resolvedDate, precision, 
null)
   ```
   
   
**grails-gsp/plugin/src/test/groovy/org/grails/web/taglib/FormTagLib2Tests.groovy**
   ```
   Calendar calendar = new GregorianCalendar()
           Document document
           if (date == null) {
               document = getDatePickerOutput(null, precision, 
calendar.getTime())
           } else {
               Object resolvedDate = date
               if (date instanceof Date) {
                   calendar.setTime(date)
               } /*else if (date instanceof TemporalAccessor) {
                   ZonedDateTime zonedDateTime
                   if (date instanceof LocalDateTime) {
                       zonedDateTime = ZonedDateTime.of(date, 
ZoneId.systemDefault())
                   } else if (date instanceof LocalDate) {
                       zonedDateTime = ZonedDateTime.of(date, LocalTime.MIN, 
ZoneId.systemDefault())
                   } else {
                       zonedDateTime = ZonedDateTime.from(date)
                   }
                   calendar = GregorianCalendar.from(zonedDateTime)
               }*/
               document = getDatePickerOutput(resolvedDate, precision, null)
           }
   ```


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