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

Allow DurationFormat and PeriodFormat to be used on parameters #22646

Closed
wants to merge 3 commits into from

Conversation

dreis2211
Copy link
Contributor

Hi,

this PR should close #22644 .

Cheers,
Christoph

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 29, 2020
@wilkinsona wilkinsona self-assigned this Jul 29, 2020
Comment on lines 796 to 797
assertThat(bean.getFormattedDuration()).isEqualTo(Duration.ofDays(15));
assertThat(bean.getFormattedPeriod()).isEqualTo(Period.ofYears(16));
Copy link
Member

Choose a reason for hiding this comment

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

These assertions succeed without @DurationFormat and @PeriodFormat on ConstructorParameterWithUnitProperties. I think that's because the converter successfully infers the style to use from the value that's being converted. To verify that the format annotations are working as expected, I think it would be necessary to trigger a failure by trying, for example, to bind an ISO-8601 value to a property that requires the simple style.

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 extended/reworked the testing a bit. Let me know if this is what you had in mind, @wilkinsona

Copy link
Member

Choose a reason for hiding this comment

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

Spot on. Thanks.

@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 30, 2020
@wilkinsona wilkinsona added this to the 2.4.x milestone Jul 30, 2020
@wilkinsona wilkinsona removed this from the 2.4.x milestone Jul 30, 2020
@wilkinsona wilkinsona added this to the 2.4.0-M2 milestone Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow DurationFormat and PeriodFormat to be used on parameters
3 participants