Skip to content

fix(calendar): PSCalendarMonthModel.getEvents returns null per documented contract - #198

Merged
natechadwick-intsof merged 1 commit into
mainfrom
bugfix/197-fix-calendar-getevents-returns-null
Sep 8, 2026
Merged

fix(calendar): PSCalendarMonthModel.getEvents returns null per documented contract#198
natechadwick-intsof merged 1 commit into
mainfrom
bugfix/197-fix-calendar-getevents-returns-null

Conversation

@natechadwick-intsof

Copy link
Copy Markdown
Collaborator

Summary

PSCalendarMonthModel.getEvents(int) did not honor its documented contract: when setEvents(...) was called with a non-empty list and the requested day had no events, the method returned an empty collection instead of null. This caused PSCalendarMonthModelTest.testEmptyEvents to fail with expected null, but was:<[]>.

The fix normalizes the return value in getEvents itself (so an empty result becomes null) and corrects the JavaDoc, which had a typo where the "no" was missing before "events occur on the specified day".

Root cause

The JavaDoc reads:

"will be null if no events have been set or events occur on the specified day"

The second clause is nonsensical as a null condition. The intended meaning (corroborated by the @Ignored testEvents test which has assertNull(m_info.getEvents(1)) after setEvents(events)) is:

"will be null if no events have been set or no events occur on the specified day"

Changes

  • modules/extensions-sfp/src/main/java/com/percussion/fastforward/calendar/PSCalendarMonthModel.java
    • getEvents(int): when m_eventsByDay is non-null, also return null if the per-day collection is empty.
    • JavaDoc: fix typo, add "never empty" guarantee.

Testing

./mvn-env.sh test -Dtest=PSCalendarMonthModelTest -pl modules/extensions-sfp

Result: Tests run: 9, Failures: 0, Errors: 0, Skipped: 1 (the skipped test is the pre-existing @Ignored testEvents, which has separate issues unrelated to this fix).

Linked issue

Closes #197

Co-Authored by MiniMax Code 1.0 using MiniMax-M3 with agent mavis.

…nted contract

The JavaDoc on `getEvents(int)` states the method returns null when no
events have been set or no events occur on the specified day. In practice
the second case was broken: when `setEvents(...)` was called with a
non-empty list and the requested day had no events, the method returned
an empty collection instead of null. This caused
`PSCalendarMonthModelTest.testEmptyEvents` to fail with:

  java.lang.AssertionError: expected null, but was:<[]>

Normalize the return value in `getEvents` so an empty result becomes
null, and correct the JavaDoc (the original text read "or events occur
on the specified day", which is nonsensical; the intended clause is
"or no events occur on the specified day").

Closes #197

> Co-Authored by MiniMax Code 1.0 using MiniMax-M3 with agent mavis.
@natechadwick-intsof
natechadwick-intsof merged commit f517908 into main Sep 8, 2026
3 checks passed
@natechadwick-intsof
natechadwick-intsof deleted the bugfix/197-fix-calendar-getevents-returns-null branch September 8, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(calendar): PSCalendarMonthModel.getEvents returns null per documented contract

2 participants