#119: DataTransferNotificationTest.kt

plugins/org.projectforge.plugins.datatransfer/src/test/kotlin/org/projectforge/plugins/datatransfer/DataTransferNotificationTest.kt Path: plugins/...datatransfer/src/test/kotlin/.../DataTransferNotificationTest.kt · Lines: 108 · Type: Kotlin JUnit 5 unit test (no Spring context) 108 lines · 80 code · 22 comments · 6 blank

Pure unit test for the observer notification recipient logic — verifies who gets notified for each event type. Unlike DataTransferNotificationMailTest (which tests the full mail pipeline), this test isolates the recipient selection algorithm. Does not extend AbstractTestBase — runs without Spring context, making it fast.

Test method: registerRecipientsTest()

Uses a helper testAudit(uploadUserId, byUserId, eventType, observerIds, expected) that:

  1. Creates mock PFUserDO objects for uploader, the user performing the action, and observers
  2. Simulates an audit event by calling the notification logic directly
  3. Asserts that only the expected set of observer IDs receives a notification

Notification rules tested

The invariant: you never get notified about your own actions — only other people's activity triggers notifications.

Design note

This is a unit test (no database, no JCR, no Spring) that tests just the notification recipient logic. The testAudit helper directly calls the notification method with arranged inputs. The actual DataTransferNotificationJob + mail rendering is tested in DataTransferNotificationMailTest. This separation makes the notification logic test fast (milliseconds vs. seconds for integration tests).