Skip to content

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

Description

@natechadwick-intsof

Problem

com.percussion.fastforward.calendar.PSCalendarMonthModel.getEvents(int day) does not honor its documented contract.

The JavaDoc states the method will return null "if no events have been set or no events occur on the specified day". In practice, the second case is broken: when setEvents(...) has been called with a non-empty list and the requested day simply has no events, the method returns an empty collection instead of null.

This causes PSCalendarMonthModelTest.testEmptyEvents to fail:

java.lang.AssertionError: expected null, but was:<[]>
    at com.percussion.fastforward.calendar.PSCalendarMonthModelTest.testEmptyEvents(PSCalendarMonthModelTest.java:252)

Fix

Normalize the return value in getEvents itself so an empty result is converted to null, and correct the JavaDoc typo (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").

Files

  • modules/extensions-sfp/src/main/java/com/percussion/fastforward/calendar/PSCalendarMonthModel.java

Testing

./mvn-env.sh test -Dtest=PSCalendarMonthModelTest -pl modules/extensions-sfp → 9 run, 0 failures, 1 skipped (pre-existing @Ignored testEvents).

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions