Skip to content

Add unit tests for EnvironmentRepositoryImpl#133

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/environment-repository-tests
Jun 13, 2026
Merged

Add unit tests for EnvironmentRepositoryImpl#133
dmccoystephenson merged 1 commit into
mainfrom
feature/environment-repository-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • Adds EnvironmentRepositoryImplTest covering all 16 public methods of EnvironmentRepositoryImpl, the last repository implementation without tests.
  • Mirrors the established Mockito pattern of EntityRepositoryImplTest / GridRepositoryImplTest (@SpringBootTest + @MockBean DbInteractions); no real database, no Testcontainers.
  • Coverage per method group:
    • findAll / findById / findByName / findByEntityId — row(s) present, empty result, and SQLException-handled-gracefully paths.
    • findEntityIdsByEnvironmentId / findLocationIdsByEnvironmentId / findGridIdsByEnvironmentId — non-empty, empty, and SQLException paths.
    • save — returns the same instance and touches no DB (current passthrough behaviour).
    • deleteById, updateName, and the six delete delegators (deleteEntityLocation, deleteLocationGrid, deleteGridEnvironment, deleteEntity, deleteLocation, deleteGrid) — true/false delegation, asserting the exact SQL string passed to DbInteractions.update.

Characterization note

Unlike its sibling repositories, EnvironmentRepositoryImpl does not guard against a null ResultSet and currently throws NullPointerException for that input. These tests characterize the current behaviour, so null-ResultSet cases are intentionally omitted rather than asserting an incorrect "returns empty". The underlying inconsistency is filed as #132 for a separate fix cycle (no production code is changed here).

Scope note

The diff is a single new test file of ~561 LOC — above the soft ~400 LOC guideline but a single cohesive test class for one repository, with zero production changes and well under the hard ceiling. Splitting one class's tests across two PRs would add churn without benefit.

Test plan

  • ./mvnw test -Dtest=EnvironmentRepositoryImplTest — 38/38 pass (Java 21)
  • ./mvnw test (full suite) — 206/206 pass, no regressions
  • Python client — not applicable (no src/main/python change)

Closes #129

🤖 Generated with Claude Code

Cover all 16 public methods of EnvironmentRepositoryImpl with Mockito-based
unit tests mirroring EntityRepositoryImplTest: find* (found/empty/SQLException),
the id-list queries, save passthrough, and the boolean delete/update delegators
(true/false). DbInteractions is mocked via @MockBean; no real database.

Null-ResultSet cases are intentionally omitted because, unlike its sibling
repositories, EnvironmentRepositoryImpl does not guard against a null ResultSet
and currently throws NullPointerException for that input; tracked separately.

Closes #129

Co-Authored-By: Claude Sonnet 4.6 <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 (adversarial; anchored on green CI run 27466755010 + the diff):

  • Scope: PASS — gh pr diff --name-only shows exactly one new file under src/test/java/.../repositories/; no production, formatting, or unrelated changes.
  • Tests-new: PASS — all 16 public methods of EnvironmentRepositoryImpl are exercised (verified by grepping distinct repository.<m>( call sites: findAll, findById, findByName, findByEntityId, save, deleteById, updateName, the three id-list finders, and the six delete delegators).
  • Tests-fix: N/A — test-only PR, no bug fix.
  • Sibling structure: PASS — mirrors GridRepositoryImplTest (section comments, @SpringBootTest + @MockBean DbInteractions, compact arrange/act/assert).
  • Sibling renames: N/A — no identifiers renamed.
  • Docs: N/A — no API/DTO/endpoint surface changed; no Phase 7 doc source-of-truth row is affected.
  • Issue resolution: PASS — #129's remaining surface (per its own comment, only EnvironmentRepositoryImpl) is fully covered.
  • CI: PASS — build green on PR head.
  • DTO boundary / Spec alignment: N/A — no controller or endpoint change.
  • Java/Python parallelism: PASS — repository layer is Java-only; the Python client has no repository mirror, so no parallel change is required.
  • Override correctness: PASS — zero @Override annotations in the test file.

Substantive finding (filed, not silenced): EnvironmentRepositoryImpl lacks the null-ResultSet guard its sibling repositories have and throws NullPointerException on a null ResultSet. Per test-cycle rules production code is not changed here; the tests characterize current behaviour and omit null cases. Filed as #132 for a dedicated fix cycle.

Summary: ready to merge as a characterization/regression baseline; the one real issue surfaced during review is tracked in #132.

@dmccoystephenson dmccoystephenson merged commit 43b4911 into main Jun 13, 2026
1 check passed
@dmccoystephenson dmccoystephenson deleted the feature/environment-repository-tests branch June 13, 2026 12:29
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.

Add repository integration tests for Environment, Grid, and Location

1 participant