Skip to content

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

Merged
merged 1 commit into from
Feb 25, 2018
Merged

Fixed bug from #152. #154

merged 1 commit into from
Feb 25, 2018

Conversation

KamilKrol
Copy link
Contributor

Problem with overriden Enum serialization to Map.
We added also tests confirming the problem.

Kamil Krol & Dreando

@KamilKrol
Copy link
Contributor Author

What is the status of this pull request ?
Will it be merged to master ?

Regards, Kamil

@garethahealy
Copy link
Collaborator

@KamilKrol ; can you rebase to force re-test please

@garethahealy
Copy link
Collaborator

@KamilKrol ; any update?

@KamilKrol
Copy link
Contributor Author

@garethahealy , done. Let me know if you need something additional before merging this pull request.

Kamil

@garethahealy
Copy link
Collaborator

@orange-buffalo ; can you review please

@garethahealy
Copy link
Collaborator

@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.

Copy link
Contributor

@orange-buffalo orange-buffalo left a 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" });
Copy link
Contributor

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)
Copy link
Contributor

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")
Copy link
Contributor

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) {
Copy link
Contributor

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());
Copy link
Contributor

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).

@garethahealy
Copy link
Collaborator

@KamilKrol ; are you able to work on the suggested changes?

@garethahealy
Copy link
Collaborator

@KamilKrol ; have you had chance to work on this?

@KamilKrol KamilKrol force-pushed the master branch 3 times, most recently from 0c47261 to 003786c Compare February 22, 2018 15:45
Problem with overriden Enum serialization to Map.
@KamilKrol
Copy link
Contributor Author

@garethahealy , I fixed all comments from code review and committed latest version.
But it seems that some OSGI tests are failing.

@garethahealy
Copy link
Collaborator

@KamilKrol ; the OSGi failure was a test flake.

@garethahealy
Copy link
Collaborator

LGTM

@orange-buffalo ?

@garethahealy
Copy link
Collaborator

#152

@KamilKrol
Copy link
Contributor Author

@garethahealy , perfect that this OSGI failure is understood.
Let me know if I can do anything more for this pull requests.

Copy link
Contributor

@orange-buffalo orange-buffalo left a comment

Choose a reason for hiding this comment

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

LGTM

@garethahealy garethahealy merged commit 527a001 into DozerMapper:master Feb 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants