Skip to content
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

Merged
merged 4 commits into from
Feb 15, 2022

Conversation

skitini
Copy link
Contributor

@skitini skitini commented Feb 11, 2022

  • Fix JavaDocs for HolidayCalendar.combinedWith() and HolidayCalendar.linkedWith()
  • If a combined/linked holiday calendar ID is not present in the reference data used for HolidaySafeReferenceData, don't default to creating an ImmutableHolidayCalender when queryValueOrNull() and tryDefaultValue() are called. If null is returned, then HolidayCalendarId.create() will handle splitting the IDs appropriately and try to get the calendar using the individual calendar IDs

@@ -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.
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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
Copy link
Member

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.

@skitini skitini added the auto-merge Merge when build finishes label Feb 15, 2022
@mergify mergify bot merged commit 5056cc2 into main Feb 15, 2022
@delete-merged-branch delete-merged-branch bot deleted the topic/handle-combined-holidays branch February 15, 2022 17:34
@jodastephen jodastephen removed the auto-merge Merge when build finishes label May 9, 2022
@jodastephen jodastephen added this to the v2.12 milestone May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants