Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MockBean for KafkaTemplate in KafkaProducerConfigTest #88

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

aamirxshaikh
Copy link
Member

Description:

This pull request introduces changes to the KafkaProducerConfigTest class to mock the KafkaTemplate dependency using the @MockBean annotation. By mocking KafkaTemplate, the test class no longer relies on an actual Kafka instance, making the tests more isolated and easier to maintain.

Changes:

  • Added @MockBean annotation for KafkaTemplate in the KafkaProducerConfigTest class to enable mocking.
  • Removed KafkaTemplate from the constructor of KafkaProducerConfigTest since it is now handled by @MockBean.
  • Updated the testKafkaTemplateConfiguration method to remove the assertion on KafkaTemplate's producerFactory property.
  • Simplified the dependency injection process by replacing direct injection with a mocked KafkaTemplate.

Purpose:

The purpose of this pull request is to improve the testability of KafkaProducerConfigTest by introducing a mocked KafkaTemplate. This change eliminates the dependency on an actual Kafka environment, ensuring that tests can run independently and focus solely on validating the configuration logic. It enhances the reliability and maintainability of the test suite.

This PR solves #87.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
This commit introduces the following changes to the codebase:

- Added `@MockBean` annotation for KafkaTemplate in the KafkaProducerConfigTest class to mock its behavior during testing.
- Removed KafkaTemplate from the constructor of KafkaProducerConfigTest as it is now mocked using `@MockBean`.
- Updated the testKafkaTemplateConfiguration method to remove the assertion on KafkaTemplate's producerFactory.
- Simplified dependency injection by relying on `@MockBean` for KafkaTemplate instead of injecting it directly.
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

@aamirxshaikh aamirxshaikh merged commit 52d13af into main Nov 16, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Resolve Failing Unit and Integration Tests in ClinicWave User Management Service
1 participant