Summary
Replace repetitive per-field assertThat(...) chains with AssertJ's recursive object comparison where it makes the test clearer.
Current State
Several unit tests assert an object by comparing each attribute in its own assertThat statement, stacked one after another:
assertThat(result.id).isEqualTo(expected.id)
assertThat(result.name).isEqualTo(expected.name)
assertThat(result.status).isEqualTo(expected.status)
// ...N calls for one object
This is verbose, easy to leave incomplete (a new field silently goes unasserted), and noisy to read.
Desired State
A single assertion per object where a full-object comparison is intended:
assertThat(result)
.usingRecursiveComparison()
.isEqualTo(expected)
Added Value
- Readability — one assertion expresses "this object equals that object".
- Maintainability — new fields are covered automatically; no forgotten
assertThat line.
- Cleaner diffs — failures report all differing fields at once.
Technical Notes
- Apply only where a whole-object equality check is the intent — keep targeted single-field assertions where that's what the test actually means.
- Use
.ignoringFields(...) / .ignoringFieldsOfTypes(...) for generated or non-deterministic fields (ids, timestamps).
- Scope: backend unit + application-service tests under
service/app.
- Keep the mutation-testing gate (80) green — recursive comparison still kills the same mutants as long as the compared object is fully built.
Summary
Replace repetitive per-field
assertThat(...)chains with AssertJ's recursive object comparison where it makes the test clearer.Current State
Several unit tests assert an object by comparing each attribute in its own
assertThatstatement, stacked one after another:assertThat(result.id).isEqualTo(expected.id) assertThat(result.name).isEqualTo(expected.name) assertThat(result.status).isEqualTo(expected.status) // ...N calls for one objectThis is verbose, easy to leave incomplete (a new field silently goes unasserted), and noisy to read.
Desired State
A single assertion per object where a full-object comparison is intended:
assertThat(result) .usingRecursiveComparison() .isEqualTo(expected)Added Value
assertThatline.Technical Notes
.ignoringFields(...)/.ignoringFieldsOfTypes(...)for generated or non-deterministic fields (ids, timestamps).service/app.