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

#642 Support the conversion of String In Map To Enum #643

Merged
merged 5 commits into from Jun 11, 2018

Conversation

yuanpli
Copy link
Contributor

@yuanpli yuanpli commented Jun 6, 2018

Issue link

#642 Support the conversion of String In Map To Enum

Purpose

Support the conversion of String In Map To Enum

Approach

Make PrimitiveOrWrapperConverter accepts Enum type for destination object.

Open Questions and Pre-Merge TODOs

  • Issue created
  • Unit tests pass
  • Documentation updated
  • Travis build passed

|| Character.class.equals(aClass)
|| Boolean.class.equals(aClass)
|| java.util.Date.class.isAssignableFrom(aClass)
|| java.util.Calendar.class.isAssignableFrom(aClass);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add aClass.isEnum() at the end so the diff, is just 1 line, instead of 7

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Accepted

testEnumMapsToNonexistEnumValueEE.expectMessage("No enum constant com.github.dozermapper.core.vo.enumtest.DestType.BAR");
testEnumMapsToNonexistEnumValueEE.expect(IllegalArgumentException.class);
testEnumMapsToNonexistEnumValueEE.expectMessage("Cannot convert [BAR] to enum of type class com.github.dozermapper.core.vo.enumtest.DestType");
testEnumMapsToNonexistEnumValueEE.expect(MappingException.class);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whys this changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IllegalArgumentException is caught in com.github.dozermapper.core.converters.EnumConverter#convert and then it is wrapped in MappingException and threw out.
So the expected exception should be MappingException, not the original IllegalArgumentException.

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.

None yet

2 participants