Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public boolean accepts(Class<?> aClass) {
|| Character.class.equals(aClass)
|| Boolean.class.equals(aClass)
|| java.util.Date.class.isAssignableFrom(aClass)
|| java.util.Calendar.class.isAssignableFrom(aClass);
|| java.util.Calendar.class.isAssignableFrom(aClass)
|| aClass.isEnum();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.github.dozermapper.core.functional_tests;

import java.util.HashMap;
import java.util.Map;

import com.github.dozermapper.core.DozerBeanMapperBuilder;
Expand Down Expand Up @@ -91,6 +92,15 @@ public static void setup() {
.build();
}

@Test
public void canStringInMapMapsToEnum() {
Map src = newInstance(HashMap.class);
src.put("destType", "FOO");

MyBeanPrime dest = enumMappingOverriedEnumToBasedEnum.map(src, MyBeanPrime.class);
assertEquals("FOO", dest.getDestType().toString());
}

@Test
public void canOverriddenEnumMapsToBasedEnum() {
MyBean src = newInstance(MyBean.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public class EnumMapping_WithExceptionsLoggedTest extends AbstractFunctionalTest
public void testEnumMapsToNonexistEnumValue() {
LOG.error("WithExceptionsLoggedTest; 'IllegalArgumentException: No enum constant com.github.dozermapper.core.vo.enumtest.DestType.BAR'");

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
Copy Markdown
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
Copy Markdown
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.


mapper = getMapper("mappings/enumMapping.xml");

Expand Down