#121: DataTransferTestService.kt

plugins/org.projectforge.plugins.datatransfer/src/test/kotlin/org/projectforge/plugins/datatransfer/DataTransferTestService.kt Path: plugins/...datatransfer/src/test/kotlin/.../DataTransferTestService.kt · Lines: 222 · Type: Kotlin @Service — test helper bean 222 lines · 175 code · 23 comments · 24 blank

Shared test fixture service used by every DataTransfer integration test (#114, #115, #116, #117, #119). Provides reusable methods for creating test users, areas, audit entries, mock files, and mock HTTP interactions. Registered as a Spring @Service so all tests get the same instance via @Autowired.

Key methods

Design pattern

This follows the Test Service Object pattern — a Spring bean that encapsulates test data setup, keeping test classes focused on assertions. All DataTransfer tests autowire this service, call its factory methods to create their test scenario, then verify behavior. The addPluginEntitiesForTestMode() static call in init {} ensures entity registration happens before any @PostConstruct methods or @BeforeEach/beforeAll() lifecycle hooks.

The @PostConstruct postConstruct() method calls pluginAdminService.initializeAllPluginsForUnitTest() — ensures all plugins (not just DataTransfer) have their entities and services initialized before any test runs.