1. Extract MultipartUploader from FileApiImpl
Strong in-processcrm-file/…/api/FileApi.java (119 lines, 9 methods)
crm-file/…/service/impl/FileApiImplTest.java (763 lines)
Before
3 lifecycles mixed in one module. Tests need 8 mocks for any path.
After
Multipart protocol concentrated in one deep module.
FileApiImpl mixes three distinct lifecycles. The multipart upload protocol — Redis session management, chunk I/O, composeObject, cleanup — is self-contained but shares the same class as simple file put/get and thumbnail retrieval. FileApiImplTest is 763 lines because multipart tests, thumbnail tests, and simple upload tests all share the same 8-mock setup.
Extract a MultipartUploader module: 3-method interface (init, uploadChunk, completeMultipart) backed by ~200 lines of implementation. FileApiImpl delegates the 3 multipart methods; the multipart helpers (requireSession, listUploadedChunks, chunkKey, cleanupChunks, etc.) move behind the seam.
- • Locality: multipart protocol lives in one module, not interleaved with file I/O
- • Interface shrinks: FileApi 9 → 6 visible methods, 3 delegated
- • Tests isolate: multipart tests mock only MinIO + Redis, not 8 deps
- • Leverage: 3-method interface controls 210 lines of protocol