Skip to content

refactor(di): constructor injection across resources, services, config#89

Merged
asm0dey merged 4 commits into
mainfrom
test/consolidate-testprofiles
Jul 5, 2026
Merged

refactor(di): constructor injection across resources, services, config#89
asm0dey merged 4 commits into
mainfrom
test/consolidate-testprofiles

Conversation

@asm0dey

@asm0dey asm0dey commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Stacks on the test-reboot consolidation already on this branch. Three commits into main:

  1. test: consolidate @TestProfile classes — cut Quarkus reboots (240s→172s)
  2. refactor(captcha): centralize config in CaptchaProviderConfig — spy in tests (172s→161s)
  3. refactor(di): constructor injection — this change

DI refactor

Convert field @Inject and @ConfigProperty injection to constructor injection project-wide, matching the existing service-layer convention (BookingService, google package): immutable final collaborators, fail-fast wiring, plain-unit-testable without CDI. Resources are @Singleton and services run under ArC, so no dummy no-arg ctor is needed.

  • 13 JAX-RS @Path resources: field @Inject → constructor
  • 15 services/filters/schedulers: field @Inject → constructor
  • 16 classes: @ConfigProperty fields → ctor params (merged into the above ctors, or new ctors on pure config holders)
  • SmtpHealthCheckTest: no-arg construction + final-field writes → ctor args

Left as-is by design

  • Event<>/Instance<> stay @Inject fields (BookingService plumbing convention)
  • OidcLoginResource @IdToken: quarkus-oidc verified id_token is field-only
  • EncryptedStringConverter: JPA AttributeConverter, reflective-instantiation risk

Follow-up (not in this PR)

  • CaptchaProviderConfig (7-arg ctor) and SiteInfo (4-arg) are pure config holders — better as @ConfigMapping interfaces than fat constructors.

Verification

  • mvn spotless:apply clean
  • mvn test-compile clean
  • 775 tests pass, 0 failures

🤖 Generated with Claude Code

asm0dey and others added 4 commits July 5, 2026 19:48
…172s)

Merge 13 distinct test profiles into 7 buckets so same-config @QuarkusTest
classes share one Dev Services boot instead of one cold boot (+ new Postgres
container) per profile. Cuts the full suite from ~240s to ~172s (-28%), 775
tests green, zero production changes.

- New shared profiles: CommonFeaturesProfile (signup + grace + verification
  meta + oidc admin-group), TurnstileProfile, AltchaProfile.
- Delete per-test inner profiles + SignupEnabledProfile/Grace120Profile.
- Buckets that can't merge stay separate: altcha/turnstile (mutually
  exclusive captcha.provider values), csrf + oidc (build-time config).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RMMHVVTHSRwgtu5iC9Nkkj
… tests (172s->161s)

Move all CAPTCHA config reads (altcha hmac-key/max-number, turnstile
secret/verify-url/site-key) out of scattered @ConfigProperty fields in
CaptchaVerifier, AltchaResource and PublicResource into accessor methods on
CaptchaProviderConfig — one source of truth. Property names and runtime
behavior are unchanged.

This lets the 5 altcha/turnstile tests run in the shared default Quarkus boot:
@InjectSpy the config bean and override provider()/keys per-test instead of a
@testprofile restart (which cold-booted a fresh app + Postgres container each).
Drops the suite from 7 boots to 5 (~172s -> ~161s), 775 tests green. Removes
AltchaProfile/TurnstileProfile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RMMHVVTHSRwgtu5iC9Nkkj
Convert field @Inject and @ConfigProperty injection to constructor
injection project-wide, matching the existing service-layer convention
(BookingService, google package): immutable final collaborators,
fail-fast wiring, plain-unit-testable without CDI. JAX-RS resources are
@singleton and services run under ArC, so no dummy no-arg ctor is needed.

- 13 JAX-RS @path resources: field @Inject -> constructor
- 15 services/filters/schedulers: field @Inject -> constructor
- 16 classes: @ConfigProperty fields -> ctor params (merged into the
  above ctors, or new ctors on pure config holders)
- SmtpHealthCheckTest: no-arg construction + final-field writes -> ctor args

Left as-is by design:
- Event<>/Instance<> stay @Inject fields (BookingService plumbing convention)
- OidcLoginResource @idtoken: quarkus-oidc verified id_token is field-only
- EncryptedStringConverter: JPA AttributeConverter, reflective-instantiation risk

775 tests pass; spotless-formatted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RMMHVVTHSRwgtu5iC9Nkkj
SonarCloud S1192: the Panache query
"ownerId = ?1 and status = ?2 order by startUtc" appeared 3x in
AdminResource. Extract to PENDING_BY_OWNER_QUERY constant.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RMMHVVTHSRwgtu5iC9Nkkj
@sonarqubecloud

sonarqubecloud Bot commented Jul 5, 2026

Copy link
Copy Markdown

@asm0dey asm0dey merged commit f4eacb7 into main Jul 5, 2026
10 checks passed
@asm0dey asm0dey deleted the test/consolidate-testprofiles branch July 5, 2026 19:07
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