-
Notifications
You must be signed in to change notification settings - Fork 487
Fixed bug from #152. #154
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
Fixed bug from #152. #154
Conversation
What is the status of this pull request ? Regards, Kamil |
@KamilKrol ; can you rebase to force re-test please |
@KamilKrol ; any update? |
@garethahealy , done. Let me know if you need something additional before merging this pull request. Kamil |
@orange-buffalo ; can you review please |
@KamilKrol ; instead of using "expected=Exception", can you use the JUnit rule checker instead. As currently, MappingException is for everything, so we wouldn't know if this test was actually broken in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but it would be great to make some code improvements here and there.
@SuppressWarnings("unused") | ||
@Test(expected = MappingException.class) | ||
public void testByteMapsToEnumOutOfOrdinalRange() { | ||
mapper = getMapper(new String[] { "enumMapping.xml" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to explicitly create an array when calling the method. With varargs it is possible just to provide "enumMapping.xml"
as an argument, which makes code cleaner and more readable.
* Test on a mapping from short types to enum. | ||
*/ | ||
@SuppressWarnings("unused") | ||
@Test(expected = MappingException.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @garethahealy that ExpectedExceptionRule
is a better approach to test exceptions here.
/** | ||
* Test on a mapping from short types to enum. | ||
*/ | ||
@SuppressWarnings("unused") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These suppressions should be removed and the reasons for the warnings should be fixed. There is no need to assign a result of mapper.map()
if it is not used.
return enumClass; | ||
} | ||
|
||
private <T extends Enum<T>> boolean checkIfOverridenEnum(Class<T> enumClass) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor thing - the typo in Overriden
, should be Overridden
. It also would be great to have naming aligned in test code, i.e. from Overrided
to Overridden
.
} | ||
|
||
private <T extends Enum<T>> boolean checkIfOverridenEnum(Class<T> enumClass) { | ||
return Enum.class.isAssignableFrom(enumClass.getSuperclass()) && !Enum.class.equals(enumClass.getSuperclass()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum.class.isAssignableFrom(enumClass.getSuperclass())
is redundant. It is already guaranteed that this code will be executed only for enums (seeMappingUtils.isEnumType
before mapEnum
call).
@KamilKrol ; are you able to work on the suggested changes? |
@KamilKrol ; have you had chance to work on this? |
0c47261
to
003786c
Compare
Problem with overriden Enum serialization to Map.
@garethahealy , I fixed all comments from code review and committed latest version. |
@KamilKrol ; the OSGi failure was a test flake. |
LGTM |
@garethahealy , perfect that this OSGI failure is understood. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Problem with overriden Enum serialization to Map.
We added also tests confirming the problem.
Kamil Krol & Dreando