-
Notifications
You must be signed in to change notification settings - Fork 827
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
Refactoring: use namedJdbcTemplate bean instead of internal new object #2864
Conversation
Allow to mock the objects in future e.g. if jdbcTemplate is a mock then sometimes such pattern new NamedParameterJdbcTemplate(jdbcTemplate) causes a not testable code block like in JdbcScimUserProvisioning For jdbcTemplate we create one instance and re-use it, therefore if NamedParameterJdbcTemplate is used in several beans, then we should do the same
We have created an issue in Pivotal Tracker to manage this: https://www.pivotaltracker.com/story/show/187536573 The labels on this github issue will be updated when the story is started. |
Hi! I don't think I understand this point. Could you elaborate? What code block is not testable under It looks like the main advantage of |
The change is, that classes which use this can now be mocked, as done with #2863 Another reason why I wanted this refactoring is that I was wondering for a while, why we create a datasource and jdbcTemplate in a single place -> data-source.xml and re-use this reference in all needed places but the enhance jdbc class NamedParameterJdbcTemplate is always newly generated with each bean creating, see I think we will re-use NamedParameterJdbcTemplate more often therefore good to use it in same way we do with underlying jdbcTemplate/datasource |
…tor/NamedJdbcTemplate # Conflicts: # server/src/main/java/org/cloudfoundry/identity/uaa/resources/jdbc/AbstractQueryable.java # server/src/main/java/org/cloudfoundry/identity/uaa/scim/jdbc/JdbcScimUserProvisioning.java # server/src/test/java/org/cloudfoundry/identity/uaa/scim/jdbc/JdbcScimUserProvisioningTests.java
Allow to mock the objects in future
e.g. if jdbcTemplate is a mock then sometimes such pattern new NamedParameterJdbcTemplate(jdbcTemplate) causes a not testable code block like in JdbcScimUserProvisioning
For jdbcTemplate we create one instance and re-use it, therefore if NamedParameterJdbcTemplate is used in several beans, then we should do the same