Skip to content

Add Locale conversion format configuration property #4492

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

scordio
Copy link
Contributor

@scordio scordio commented Apr 19, 2025

Overview


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@scordio

This comment was marked as outdated.

Comment on lines 53 to 58
public static final DefaultArgumentConverter INSTANCE = new DefaultArgumentConverter();
private static final String DEFAULT_LOCALE_CONVERSION_FORMAT_PROPERTY_NAME = "junit.jupiter.params.arguments.conversion.locale.format";

private DefaultArgumentConverter() {
// nothing to initialize
private static final Function<String, LocaleConversionFormat> CONFIGURATION_TRANSFORMER = value -> LocaleConversionFormat.valueOf(
value.trim().toUpperCase(Locale.ROOT));
Copy link
Contributor Author

@scordio scordio Apr 19, 2025

Choose a reason for hiding this comment

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

To reduce the change's footprint, I included the property and the converter here instead of in JupiterConfiguration (which isn't accessible right now in DefaultArgumentConverter).

Let me know if you see any limitations with this approach!

@scordio

This comment was marked as outdated.

Comment on lines +94 to +96
if (targetType == Locale.class && getLocaleConversionFormat() == LocaleConversionFormat.BCP_47) {
return Locale.forLanguageTag((String) source);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm delaying the format retrieval via getLocaleConversionFormat() because I'm unsure if it would be safe to grab that value in the constructor and keep it internally.

If you think it could be fetched earlier, I'm happy to refactor it.

@scordio scordio marked this pull request as ready for review April 20, 2025 17:39
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.

Locale argument conversion not setting language and country properly
1 participant