refactor(tests): unify constructor injection and remove @Autowired field usage#53
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the Spring Boot test suite to use constructor-based dependency injection instead of @Autowired field injection, leveraging Spring’s @TestConstructor to enable autowiring of JUnit 5 test constructors.
Changes:
- Added
@TestConstructor(autowireMode = ALL)and replaced@Autowiredfields withfinalconstructor-injected dependencies in tests. - Introduced constructor chaining through
AbstractIntegrationTest→KeycloakIntegrationTest/WireMockIntegrationTest→ concrete integration tests. - Preserved
@Qualifier("keycloakProperties")on concrete test constructors where bean ambiguity exists.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/lt/satsyuk/observability/LoggingCorrelationTest.java | Switches Tracer from field injection to constructor injection and enables constructor autowiring via @TestConstructor. |
| src/test/java/lt/satsyuk/api/util/AbstractIntegrationTest.java | Adds @TestConstructor and converts core shared dependencies (KeycloakProperties, CacheManager, RateLimitingFilter) to constructor-injected final fields. |
| src/test/java/lt/satsyuk/api/util/WireMockIntegrationTest.java | Adds a constructor to forward required dependencies to AbstractIntegrationTest. |
| src/test/java/lt/satsyuk/api/util/KeycloakIntegrationTest.java | Adds a constructor to forward required dependencies to AbstractIntegrationTest. |
| src/test/java/lt/satsyuk/api/integrationtest/RateLimitingIT.java | Adds constructor injection (with @Qualifier) and forwards dependencies to WireMockIntegrationTest. |
| src/test/java/lt/satsyuk/api/integrationtest/KeycloakNegativeIT.java | Adds constructor injection (with @Qualifier) and forwards dependencies to WireMockIntegrationTest. |
| src/test/java/lt/satsyuk/api/integrationtest/KeycloakIntegrationIT.java | Adds constructor injection (with @Qualifier) and forwards dependencies to KeycloakIntegrationTest. |
| src/test/java/lt/satsyuk/api/integrationtest/DpopIntegrationIT.java | Replaces @Autowired repository field with constructor-injected final field and forwards shared deps to WireMockIntegrationTest. |
| src/test/java/lt/satsyuk/api/integrationtest/ClientIntegrationIT.java | Replaces multiple @Autowired fields with constructor-injected final repositories and forwards shared deps to KeycloakIntegrationTest. |
| src/test/java/lt/satsyuk/api/integrationtest/AuthValidationIT.java | Adds constructor injection (with @Qualifier) and forwards dependencies to AbstractIntegrationTest. |
| src/test/java/lt/satsyuk/api/integrationtest/AccountIntegrationIT.java | Replaces @Autowired repository fields with constructor-injected final fields and forwards shared deps to KeycloakIntegrationTest. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🧪 Test ResultsUnit Tests
Integration Tests
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Refactor test suite to constructor injection, add @Testconstructor autowiring, keep @qualifier("keycloakProperties") where needed, and remove @Autowired usage across src/**/*.java. Verified with mvn verify (all green).