test(attendance): verify compiled lombok contracts

This commit is contained in:
sechmachine
2026-08-15 11:45:08 +07:00
parent abc5208d67
commit 9023062477
2 changed files with 282 additions and 90 deletions
@@ -1,28 +1,35 @@
# Test Evidence: Attendance targeted Lombok boilerplate retrofit
- **Test type:** Unit source-contract audit
- **Test type:** Unit compiled-contract audit
- **Requirement IDs:** `ATT-001``ATT-012`, `CAL-001`, `CAL-006``CAL-009`
- **Scenario IDs:** `AC-ATT-001``AC-ATT-005`, `AC-CAL-003`, `AC-CAL-004`
- **Test class/method:** `com.lab.labtimesheet.feature.attendance.AttendanceLombokBoilerplateTest`
- **Test class/method:**
`com.lab.labtimesheet.feature.attendance.AttendanceLombokBoilerplateTest#generatedConstructorsPreserveParameterListsAndVisibility`,
`com.lab.labtimesheet.feature.attendance.AttendanceLombokBoilerplateTest#immutableModelsRemainRecordsWithTheirComponentContracts`,
`com.lab.labtimesheet.feature.attendance.AttendanceLombokBoilerplateTest#entitiesExposeOnlyIntentionalPublicAndProtectedDeclaredMethods`
- **Implementation commit:** `82ad8202fd31f77db8c3932a902dba07cee70894`
## Protected behavior
Attendance uses the installed Lombok processor only for mechanical constructors while preserving package-level
Spring injection access, protected JPA construction, immutable records, domain constructors and mutations, raw punch
and attached-policy history rules, composite-key identity, and existing public API names.
Attendance uses the installed Lombok processor only for mechanical constructors while preserving the compiled API:
package-level Spring injection, protected JPA construction, immutable record components, domain constructors and
mutations, raw punch and attached-policy history rules, composite-key identity, and existing public method names.
## Test method
The source-contract test inspects only `feature.attendance` production Java. It enumerates the exact injection-only
components and JPA/stateless no-argument constructors eligible for Lombok, rejects retained handwritten equivalents
and blanket `@Data`, and asserts that records and business-significant methods remain explicit.
Reflection inspects compiled `feature.attendance` classes rather than source spelling. It verifies every constructor's
parameter order and modifier, every immutable model's record components, and the exact public/protected declared method
surface of each Attendance entity. The entity surface prevents generated bean getters/setters or entity
`equals`/`hashCode`/`toString` widening while explicitly retaining `AttendanceRecordEntity#setCheckOutAt` and the
`LeaveRequestDayId` identity methods.
## Hand-derived expected result
Five injection-only components use package-scoped `@RequiredArgsConstructor`; six JPA/embeddable types use protected
`@NoArgsConstructor`; the stateless domain service uses a package-scoped `@NoArgsConstructor`. No record is replaced,
and no validated constructor, state mutation, identity method, or stable domain-style accessor is generated away.
Five injection-only components expose only their package-scoped dependency constructors. Six JPA/embeddable types
retain protected no-argument construction alongside their intentional domain constructors, and the stateless domain
service remains package-scoped. Seven immutable models remain records with the same component order and types. Entity
method surfaces contain only intentional domain conversion/access/mutation methods; only the composite key owns
`equals` and `hashCode`, and no Attendance entity declares `toString`.
## RED
@@ -38,10 +45,10 @@ export PATH="$JAVA_HOME/bin:$PATH"
```text
Tests run: 3, Failures: 2, Errors: 0, Skipped: 0
The injection-component assertion first failed on AttendanceController because the required package-scoped
@RequiredArgsConstructor and Lombok imports were absent. The JPA/stateless assertion first failed on
AttendancePolicyEntity because the protected @NoArgsConstructor and Lombok imports were absent. The record and
business-method retention guard passed.
The initial source audit first failed on AttendanceController because its mechanical dependency constructor remained,
and on AttendancePolicyEntity because its mechanical protected JPA constructor remained. The immutable-record and
business-method retention guard passed. After this RED established the retrofit gap, the permanent regression was
replaced with compiled reflection/API checks so formatting or annotation spelling cannot affect the result.
BUILD FAILURE
Process exited 1.
```
@@ -81,9 +88,9 @@ Process exited 0.
## External-test boundaries
The source audit does not replace compilation, reflection/JPA bootstrapping, MVC property access, PostgreSQL
persistence, or Javadoc/doclint. Those checks are required as affected verification after the source contract turns
GREEN. No application behavior or public API is intentionally changed by this retrofit.
The reflection audit does not replace Spring/JPA bootstrapping, MVC property access, PostgreSQL persistence, or
Javadoc/doclint. Those checks remain affected verification. No application behavior or public API is intentionally
changed by this retrofit.
Additional verification on the same source tree:
@@ -99,7 +106,8 @@ BUILD SUCCESS
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
PostgreSQL 18.4; BUILD SUCCESS
javadoc -quiet -Xdoclint:all -d target/attendance-javadocs -classpath "target/classes:<Maven dependency classpath>" -sourcepath src/main/java -subpackages com.lab.labtimesheet.feature.attendance
./mvnw -q -DskipTests compile dependency:build-classpath -Dmdep.outputFile=target/attendance-javadoc-classpath.txt
javadoc -quiet -Xdoclint:all -d target/attendance-javadocs -classpath "target/classes:$(tr -d '\n' < target/attendance-javadoc-classpath.txt)" -sourcepath src/main/java -subpackages com.lab.labtimesheet.feature.attendance
Process exited 0. The source frontend reported seven generated-constructor missing-comment warnings because it does not
expand Lombok constructors; repository policy exempts generated trivial constructors from duplicate Javadoc.
```