Commit 66d01c4
refactor(schedule10): split document assembly out of Schedule10Service
Clears the last two SonarCloud findings on PR #305.
USE containsEntry (Minor). One assertion was left on the old shape by the earlier
mechanical pass, because it spanned lines and carried an .as(...) description.
Converted, and folded together with the assertion below it so the pair cannot
return as a "join assertions" flag.
MONSTER CLASS (21 dependencies against a limit of 20). Sonar's suggested fix was
to split the class, and that is what this does rather than trimming one incidental
dependency to get under the threshold. Schedule10Service had grown to 1137 lines
doing two genuinely separate jobs, and the seam between them was clean: nothing in
the assembly touches a request DTO, and nothing in the write path touches a
response DTO beyond returning one.
Schedule10Service 1137 -> 786 lines the seven writes, validation,
Check Status entry point
Schedule10DocumentAssembler 378 lines (new) assembly and read-side derivation
Schedule10CostItems 52 lines (new) the 12 cost-item ordinals and 3
column scales BOTH halves need
Service imports fall from 38 to 23 -- fifteen became unused the moment the
assembly left, which is precisely the coupling Sonar was measuring.
Schedule10CostItems exists because the ordinals and scales are genuinely shared;
the alternatives were declaring the same twelve magic numbers twice, or having the
assembler reach back into the service.
This also closes a separate code-review finding at no extra cost. The write paths
previously read the track status TWICE -- once for requireDraft's gate, then again
inside assembly to compute editable. The service now reads it once and passes both
the status and the derived editability to the assembler, so there is one read per
request. Safe to change: the service test uses lenient mocks with no call-count
verification.
The assembler is constructed by the service rather than injected as a bean. It is
an implementation detail with no independent lifecycle, and constructing it keeps
the existing single-argument constructor every test already uses, so no test
wiring changed.
Verification: 1151 unit + 881 integration tests, 0 failures; 0 checkstyle
violations in schedule10. Schedule10DocumentIT -- which asserts the assembled
document byte-for-byte against the pinned contract, and covers the code that
moved -- passes unchanged, which is the evidence that the extraction preserved
behaviour.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent dbd0a19 commit 66d01c4
4 files changed
Lines changed: 515 additions & 400 deletions
File tree
- backend/src
- main/java/ca/bc/gov/nrs/ilcr/schedule10
- test/java/ca/bc/gov/nrs/ilcr/schedule10
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
0 commit comments