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

Delegate to ConversionService in DefaultInputObjectMapper #1735

Merged
merged 4 commits into from
Jan 3, 2024

Conversation

kilink
Copy link
Member

@kilink kilink commented Dec 8, 2023

Switch to using a ConversionService from Spring to perform conversion in DefaultInputObjectMapper; this greatly simplifies the implementation, and allows for extensibility in the future.

Switch to using a ConversionService from Spring to perform conversion in DefaultInputObjectMapper; this
greatly simplifies the implementation, and allows for extensibility in the future.
@@ -156,28 +156,6 @@ internal class InputObjectMapperTest {
assertThat(mapToObject.simpleString).isEqualTo("hello")
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these tests not relevant anymore? Did the behavior change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the behavior is different now that we're delegating to the ConversionService; if there's a registered type converter for the source and target type, we will perform a conversion instead of failing if possible, whereas previously the conversion was explicitly implemented for a narrower set of types (Map, Collections, Enum).

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a test case for this new behavior.

} else {
trySetField(declaredField, instance, newList)
}
} else if (fieldClass.isEnum) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't have a test covering the enum field case. Should we add one for that as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is coverage for Enums already in InputArgumentTest.

Copy link
Member Author

Choose a reason for hiding this comment

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

I went ahead and added an additional test case for this.

@srinivasankavitha
Copy link
Contributor

Since this is close to the quiet period freeze, should we perhaps hold off on merging this till after?

Add a test case covering an Enum field, as well as conversion of an input type that
doesn't match the target type exactly (e.g., List<String> -> Set<Int>).
Copy link
Contributor

@srinivasankavitha srinivasankavitha left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! The implementation does look much simpler now.

@kilink kilink merged commit 6117c0d into master Jan 3, 2024
3 checks passed
@kilink kilink deleted the input-object-mapper-conversion-service branch January 9, 2024 19: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.

2 participants