Skip to content

Add repository unit tests for Grid and Location#131

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/repo-tests-grid-location
Jun 13, 2026
Merged

Add repository unit tests for Grid and Location#131
dmccoystephenson merged 1 commit into
mainfrom
feature/repo-tests-grid-location

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • Adds GridRepositoryImplTest (12 tests) and LocationRepositoryImplTest (17 tests), covering every public method of the two repositories.
  • Mirrors the established EntityRepositoryImplTest pattern: @SpringBootTest + @MockBean DbInteractions + a mocked ResultSet. No Testcontainers / no real database — so these run anywhere CI does.
  • Cases per method: happy path (single + multiple rows), empty result set, null result set, SQLException handling, and update(...) delegation for the entity_location mutators (addEntityToLocation, removeEntityFromLocation, removeEntityFromCurrentLocation).
  • Characterization tests only — they assert current behavior; no production code is touched.

Note on the tracking issue

#129 describes the existing test as a "Testcontainers/JDBC approach." That's inaccurate — EntityRepositoryImplTest actually mocks DbInteractions with Mockito and uses no container. These new tests follow the real sibling pattern. (The cascade-delete / one-entity-per-location scenarios #129 mentions live in the Environment repository, which is deferred below.)

Scope

Partially addresses #129 — Grid + Location only. EnvironmentRepositoryImpl (16 public methods, ~800 LOC of tests) is deferred to a follow-up to stay within the per-PR scope ceiling; #129 remains open to track it.

No Python-client changes: repositories are Java-only JDBC and have no Python mirror.

Test plan

  • ./mvnw test -B (JDK 21) — full suite green: 168 tests, 0 failures, 0 errors
  • New classes alone: 29 tests, 0 failures
  • No production code modified (test-only diff)

Partially addresses #129

Mirror the existing EntityRepositoryImplTest pattern (@SpringBootTest +
@MockBean DbInteractions + mocked ResultSet) to cover every public method
of GridRepositoryImpl (12 tests) and LocationRepositoryImpl (17 tests):
happy path, empty result set, null result set, SQLException handling, and
update-delegation for the entity-location mutators. Characterization tests
only — no production code changed.

Partially addresses #129 (Grid + Location); EnvironmentRepositoryImpl
deferred to a follow-up to respect the scope ceiling.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@dmccoystephenson dmccoystephenson left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review rubric (CI green on head — external anchor satisfied):

  • Scope: PASS — diff is exactly 2 new files under src/test/java/.../repositories/, 457 insertions, zero production or unrelated changes.
  • Tests-new: PASS — all 12 public methods across the two repos are exercised; 29 assertions-bearing tests, all green locally and in CI.
  • Tests-fix: N/A — no bug fix in this PR (characterization tests only).
  • Sibling structure: PASS — both classes mirror EntityRepositoryImplTest (package, imports, @SpringBootTest + @MockBean DbInteractions, mocked ResultSet, testMethod_Condition naming).
  • Sibling renames: N/A — no identifiers renamed.
  • Docs: PASS — no API/behavior change, so no doc source-of-truth row is affected.
  • Issue resolution: PASS — #129's Grid + Location surface is actually added; PR claims only partial progress, not closure.
  • DTO boundary / Spec alignment / Java-Python parallelism / Override: N/A — no controller, endpoint, Python, or override changes.

One issue found (deliberate scoping, not a defect): the SQLException error path is covered for findAll on both repos and for GridRepositoryImpl.findById, but not exhaustively for every finder (e.g. findByEnvironmentId, findByEntityId, findByGridId). The catch blocks there are structurally identical boilerplate, so additional cases would be redundant LOC against an already-over-soft-ceiling diff. Flagging so a reviewer can disagree; happy to expand if exhaustive error-path coverage is preferred.

Summary: green, scope-clean, mirrors the real (Mockito, not Testcontainers) sibling pattern; ready pending review.

@dmccoystephenson dmccoystephenson merged commit d228b61 into main Jun 13, 2026
1 check passed
@dmccoystephenson dmccoystephenson deleted the feature/repo-tests-grid-location branch June 13, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant