-
Notifications
You must be signed in to change notification settings - Fork 7
Replace Orika mapping with MapStruct #720
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
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #720 +/- ##
==========================================
- Coverage 37.22% 36.94% -0.28%
==========================================
Files 536 533 -3
Lines 23706 23560 -146
Branches 2857 2819 -38
==========================================
- Hits 8825 8705 -120
+ Misses 14003 13982 -21
+ Partials 878 873 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Also move question mappings into main ContentMapper interface
src/main/java/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java
Dismissed
Show dismissed
Hide dismissed
src/main/java/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java
Dismissed
Show dismissed
Hide dismissed
src/main/java/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java
Dismissed
Show dismissed
Hide dismissed
src/main/java/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java
Dismissed
Show dismissed
Hide dismissed
…mapping delegator
And rename some existing ones for clarity
src/main/java/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java
Dismissed
Show dismissed
Hide dismissed
src/main/java/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java
Dismissed
Show dismissed
Hide dismissed
src/main/java/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java
Dismissed
Show dismissed
Hide dismissed
src/main/java/uk/ac/cam/cl/dtg/segue/configuration/SegueGuiceConfigurationModule.java
Outdated
Show resolved
Hide resolved
Also call mapping to userSummaryWithGroupMembershipDTO directly for clarity
And remove now-unused mappings
This reverts commit d171bfa.
Only use "map" for DO <-> DTO mappings. For all other mappings, include the target type in the method name.
src/main/java/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java
Dismissed
Show dismissed
Hide dismissed
src/main/java/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java
Dismissed
Show dismissed
Hide dismissed
The implementation of the event booking mapper maps the userBooked to a userSummaryDTO anyway, so this explicit mapping is no longer needed
src/main/java/uk/ac/cam/cl/dtg/isaac/api/managers/GameManager.java
Outdated
Show resolved
Hide resolved
| UserSummaryWithGroupMembershipDTO newDTO = dtoMapper.map(dto, UserSummaryWithGroupMembershipDTO.class); | ||
| UserSummaryWithGroupMembershipDTO newDTO = dtoMapper.mapToUserSummaryWithGroupMembershipDTO(dto); | ||
| GroupMembershipDTO groupMembershipDTO = userMembershipMapforMap.get(newDTO.getId()); | ||
| newDTO.setGroupMembershipInformation(dtoMapper.map(groupMembershipDTO, GroupMembershipDTO.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.
Was this copy necessary?
This removes the old Orika converters & automappers and replaces them with MapStruct mappings.
Most of the mappings just define a source & target type and let the MapStruct auto-implementations handle the rest. The DTO <-> DO mappings are named
map(source)(orcopy(source)if the source & target classes are the same); any other mappings are named according to the target type.The mappers are split according to the kind of objects they map, but the
MainMapperinterface is used to provide a mapper object in most cases. For consistency, one of the new mappers is calledContentMapper, hence the existingContentMapperhas been renamed (toContentSubclassMapper).There are two new sets of tests: one for
ContentDO -> DTO mappings and one forQuestionValidationResponseDO -> DTO mappings. These are the only cases where there are lots of subclasses we can easily test at the same time, but we could have case-by-case tests for some/all of the other mappings too.