Skip to content

Conversation

@axlewin
Copy link
Contributor

@axlewin axlewin commented Sep 3, 2025

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) (or copy(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 MainMapper interface is used to provide a mapper object in most cases. For consistency, one of the new mappers is called ContentMapper, hence the existing ContentMapper has been renamed (to ContentSubclassMapper).

There are two new sets of tests: one for Content DO -> DTO mappings and one for QuestionValidationResponse DO -> 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.

@codecov
Copy link

codecov bot commented Sep 3, 2025

Codecov Report

❌ Patch coverage is 53.54331% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.94%. Comparing base (09e797d) to head (8f83434).
⚠️ Report is 120 commits behind head on main.

Files with missing lines Patch % Lines
...cam/cl/dtg/segue/api/managers/QuestionManager.java 15.38% 11 Missing ⚠️
...e/configuration/SegueGuiceConfigurationModule.java 11.11% 8 Missing ⚠️
...java/uk/ac/cam/cl/dtg/util/mappers/UserMapper.java 40.00% 4 Missing and 2 partials ⚠️
...a/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java 61.53% 4 Missing and 1 partial ⚠️
.../ac/cam/cl/dtg/isaac/api/managers/GameManager.java 0.00% 4 Missing ⚠️
.../cl/dtg/segue/api/managers/UserAccountManager.java 69.23% 4 Missing ⚠️
.../java/uk/ac/cam/cl/dtg/isaac/api/EventsFacade.java 70.00% 3 Missing ⚠️
...tg/util/mappers/UnimplementedMappingException.java 0.00% 3 Missing ⚠️
...dtg/isaac/dao/PgQuizAttemptPersistenceManager.java 33.33% 2 Missing ⚠️
...ac/cam/cl/dtg/segue/api/managers/GroupManager.java 71.42% 2 Missing ⚠️
... and 10 more
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Also move question mappings into main ContentMapper interface
The implementation of the event booking mapper maps the userBooked to a userSummaryDTO anyway, so this explicit mapping is no longer needed
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));
Copy link
Member

Choose a reason for hiding this comment

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

Was this copy necessary?

@jsharkey13 jsharkey13 merged commit 11da6c7 into main Nov 12, 2025
5 checks passed
@jsharkey13 jsharkey13 deleted the improvement/orika-to-mapstruct branch November 12, 2025 13:50
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.

3 participants