Skip to content

refactor(tests): unify constructor injection and remove @Autowired field usage#53

Merged
igorsatsyuk merged 1 commit into
masterfrom
refactor/test-constructor-injection
May 25, 2026
Merged

refactor(tests): unify constructor injection and remove @Autowired field usage#53
igorsatsyuk merged 1 commit into
masterfrom
refactor/test-constructor-injection

Conversation

@igorsatsyuk
Copy link
Copy Markdown
Owner

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).

Copilot AI review requested due to automatic review settings May 25, 2026 13:33
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 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 @Autowired fields with final constructor-injected dependencies in tests.
  • Introduced constructor chaining through AbstractIntegrationTestKeycloakIntegrationTest / 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.

@igorsatsyuk igorsatsyuk self-assigned this May 25, 2026
@github-actions
Copy link
Copy Markdown

🧪 Test Results

Unit Tests

  • Total:
  • Passed: 100
  • Failed: 0
  • Skipped: 0

Integration Tests

  • Total:
  • Passed: 54
  • Failed: 0
  • Skipped: 0

@igorsatsyuk igorsatsyuk merged commit ece3760 into master May 25, 2026
3 checks passed
@sonarqubecloud
Copy link
Copy Markdown

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