Skip to content

[#00] refactor backend test DI style and align Quartz job wiring#157

Merged
igorsatsyuk merged 2 commits into
mainfrom
fix/#00-autowired-injection-cleanup
May 25, 2026
Merged

[#00] refactor backend test DI style and align Quartz job wiring#157
igorsatsyuk merged 2 commits into
mainfrom
fix/#00-autowired-injection-cleanup

Conversation

@igorsatsyuk
Copy link
Copy Markdown
Owner

@igorsatsyuk igorsatsyuk commented May 25, 2026

What changed

  • Replaced @Autowired private-field injection with constructor injection in backend test classes across command-service, event-store-service, audit-writer-service, and query-service.
  • Added @TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) where tests now rely on constructor-based test dependency injection.
  • Refactored ReconciliationQuartzJob to a Quartz-safe setter-only injection path (no-args constructor + @Autowired setDependencies(...)).
  • Updated ReconciliationQuartzJobTest to instantiate the job with no-args constructor and wire collaborators through setDependencies(...).
  • Aligned IntegrityCheckIntegrationTest with constructor-based test injection style.

Files in scope

  • backend/audit-writer-service/src/test/java/lt/satsyuk/distributed/audit/auditwriter/consumer/AuditEventConsumerKafkaTestcontainersTest.java
  • backend/command-service/src/test/java/lt/satsyuk/distributed/audit/command/api/AuthControllerWebFluxTest.java
  • backend/command-service/src/test/java/lt/satsyuk/distributed/audit/command/api/CommandControllerWebFluxValidationTest.java
  • backend/command-service/src/test/java/lt/satsyuk/distributed/audit/command/config/KafkaProducerConfigIntegrationTest.java
  • backend/command-service/src/test/java/lt/satsyuk/distributed/audit/command/service/UserLoginCommandServiceKafkaIntegrationTest.java
  • backend/event-store-service/src/test/java/lt/satsyuk/distributed/audit/eventstore/EventStoreKafkaToPostgresIntegrationTest.java
  • backend/query-service/src/main/java/lt/satsyuk/distributed/audit/query/jobs/ReconciliationQuartzJob.java
  • backend/query-service/src/test/java/lt/satsyuk/distributed/audit/query/integration/IntegrityCheckIntegrationTest.java
  • backend/query-service/src/test/java/lt/satsyuk/distributed/audit/query/jobs/ReconciliationQuartzJobTest.java

Why

  • Enforces a consistent DI style and removes field injection anti-patterns in tests.
  • Keeps Quartz runtime instantiation behavior stable while preserving explicit dependency wiring in ReconciliationQuartzJob.
  • Fixes test-compile mismatch caused by constructor signature changes in the Quartz job.

Verification

  • mvn test passes locally.
  • mvn verify passes locally.

Copilot AI review requested due to automatic review settings May 25, 2026 12:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates query-service tests to match recent DI/wiring changes, resolving test compilation issues caused by mismatched construction patterns for Spring-managed components.

Changes:

  • Updated IntegrityCheckIntegrationTest to use constructor-based injection via @TestConstructor.
  • Updated ReconciliationQuartzJobTest to construct the Quartz job via no-args constructor and inject dependencies through setDependencies(...).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
backend/query-service/src/test/java/lt/satsyuk/distributed/audit/query/jobs/ReconciliationQuartzJobTest.java Aligns test job creation with the job’s no-args + setter-based dependency wiring.
backend/query-service/src/test/java/lt/satsyuk/distributed/audit/query/integration/IntegrityCheckIntegrationTest.java Migrates from field injection to constructor injection for JwtService and DatabaseClient in the integration test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@igorsatsyuk igorsatsyuk requested a review from Copilot May 25, 2026 12:29
@igorsatsyuk igorsatsyuk changed the title [#00] align query-service tests with DI refactor [#00] refactor backend test DI style and align Quartz job wiring May 25, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

@igorsatsyuk igorsatsyuk self-assigned this May 25, 2026
@igorsatsyuk igorsatsyuk merged commit 65b0713 into main May 25, 2026
9 checks passed
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.

2 participants