Skip to content

4.x: JPA testing-related improvements #9131

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

Merged
merged 4 commits into from
Sep 19, 2024

Conversation

ljnelson
Copy link
Member

@ljnelson ljnelson commented Aug 12, 2024

This PR introduces MicroProfile Config as a dependency of the JPA CDI integration and uses it to blend MicroProfile Config properties with persistence unit properties. It also allows a user to specify an alternate location for a JPA descriptor, which can be useful in unit testing scenarios.

May close and/or address #7552.

@ljnelson ljnelson added enhancement New feature or request MP P4 cdi CDI jpa/jta integration java Pull requests that update Java code 4.x Version 4.x labels Aug 12, 2024
@ljnelson ljnelson self-assigned this Aug 12, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 12, 2024
… locate persistence.xml resources

Signed-off-by: Laird Nelson <[email protected]>
…ig properties into the persistence unit properties

Signed-off-by: Laird Nelson <[email protected]>
@ljnelson ljnelson marked this pull request as ready for review August 16, 2024 18:29
@ljnelson
Copy link
Member Author

Still needs documentation updates but before I document it I'll see what people have to say.

Copy link
Member

@tjquinno tjquinno left a comment

Choose a reason for hiding this comment

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

Small changes (no functional difference) and a question about Config#getPropertyNames.

Comment on lines +320 to +323
this.enabled =
Boolean.parseBoolean(ConfigProvider.getConfig()
.getOptionalValue(this.getClass().getName() + ".enabled", String.class)
.orElse("false"));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
this.enabled =
Boolean.parseBoolean(ConfigProvider.getConfig()
.getOptionalValue(this.getClass().getName() + ".enabled", String.class)
.orElse("false"));
this.enabled =
ConfigProvider.getConfig()
.getOptionalValue(this.getClass().getName() + ".enabled", Boolean.class)
.orElse("false");

Perhaps slightly clearer/less wordy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sadly the contract of a MicroProfile Converter is all but undefined, so it's not guaranteed what will happen in the presence of null or empty String values. The contract of Boolean#parseBoolean(boolean), on the other hand, is rigorous.

Comment on lines +272 to +275
this.enabled =
Boolean.parseBoolean(getConfig()
.getOptionalValue(this.getClass().getName() + ".enabled", String.class)
.orElse("true"));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
this.enabled =
Boolean.parseBoolean(getConfig()
.getOptionalValue(this.getClass().getName() + ".enabled", String.class)
.orElse("true"));
this.enabled =
getConfig().getOptionalValue(this.getClass().getName() + ".enabled", Boolean.class)
.orElse("true");

Similar comment as earlier.

Config config = getOrDefault(instance.select(Config.class), namedSelectionQualifiers);
properties =
new StackedMap<>(List.of(properties.keySet()::stream,
() -> stream(config.getPropertyNames()::spliterator,
Copy link
Member

Choose a reason for hiding this comment

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

Similar thoughts about getPropertyNames as above.

@ljnelson ljnelson merged commit 4f40082 into helidon-io:main Sep 19, 2024
44 checks passed
@ljnelson
Copy link
Member Author

I'll follow this up with additional PRs around documentation and testing; thanks for the approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x cdi CDI enhancement New feature or request integration java Pull requests that update Java code jpa/jta MP OCA Verified All contributors have signed the Oracle Contributor Agreement. P4
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants