-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle combined holiday calendars correctly in HolidaySafeReferenceData #2426
Conversation
@@ -280,7 +280,7 @@ public default int daysBetween(LocalDate startInclusive, LocalDate endExclusive) | |||
* Combines this holiday calendar with another. | |||
* <p> | |||
* The resulting calendar will declare a day as a business day if it is a | |||
* business day in both source calendars. | |||
* business day in either source calendar. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this correction is correct. combinedWith is where a business day only happens if both calendars agree that it is a business day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CombinedHolidayCalendar.isHoliday()
method is calendar1.isHoliday(date) || calendar2.isHoliday(date)
and the LinkedHolidayCalendar.isHoliday()
method is calendar1.isHoliday(date) && calendar2.isHoliday(date)
so I don't think this is correct? The changes here also line up with the existing JavaDoc for both CombinedHolidayCalendar and LinkedHolidayCalendar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code refers to holidays, the Javadoc to business days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, I did misread that, shall revert.
//------------------------------------------------------------------------- | ||
@Test | ||
public void coverage() { | ||
Map<ReferenceDataId<?>, Object> dataMap = ImmutableMap.of(ID1, VAL1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually testing HolidaySafeReferenceData
?
return ImmutableHolidayCalendar.of(id, ImmutableList.of(), WEEKEND_DAYS); | ||
} | ||
|
||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see tests using getValue
or findValue
in the super-interface as that is the main API that needs to be satisfied. eg. searching for GBLO+EUTA where GBLO is in reference data but EUTA is not should default EUTA and then combine it.
HolidayCalendar.combinedWith()
andHolidayCalendar.linkedWith()
HolidaySafeReferenceData
, don't default to creating anImmutableHolidayCalender
whenqueryValueOrNull()
andtryDefaultValue()
are called. If null is returned, thenHolidayCalendarId.create()
will handle splitting the IDs appropriately and try to get the calendar using the individual calendar IDs