feat: Mentee registration end-to-end#541
Merged
dricazenck merged 20 commits intoWomen-Coding-Community:mainfrom Mar 7, 2026
Merged
feat: Mentee registration end-to-end#541dricazenck merged 20 commits intoWomen-Coding-Community:mainfrom
dricazenck merged 20 commits intoWomen-Coding-Community:mainfrom
Conversation
…andling - Added logic to handle mentee updates or creation based on registration inputs. - Introduced duplicate application detection and suppression during registration. - Updated test cases to validate the new behaviors, including integration tests.
- Eliminated unused `menteeId` parameter from `MenteeApplicationDto`. - Updated integration, unit tests, and serialization logic to reflect the change. - Added `@Schema` annotation to auto-generate member ID with a description in `Member`.
…ackend into fix_mentee_registration
- ensure Mentee exists before persistency - Added unit tests to verify fallback to existing member by email when the provided ID does not exist during mentee registration. - Included test to ensure existing mentee is used directly if the ID exists, avoiding unnecessary email lookups.
…and mentor operations - Added checks to reuse existing mentors and mentees by ID or email before creation. - Updated repositories to handle null or empty query results gracefully, defaulting values when necessary. - Introduced new custom exceptions for clearer error messages (e.g., MentorNotFoundException, ContentNotFoundException). - Enhanced test coverage for updated repository behavior, including fallback scenarios and null-handling logic. - Replaced deprecated JdbcTemplate methods with more resilient query implementations. - Minor refactors for code readability and maintenance.
Remove unused Image and ImageType imports that became stale after earlier refactoring. Replace hardcoded image fixtures with empty lists since image create/update behaviour is out of scope for this test and tracked separately. Add isWomen field to the update member builder to align with the current Member schema.
These changes address PMD static analysis violations across several
repository and exception classes. Ternary expressions inside
ResultSetExtractor lambdas are expanded to block statements to comply
with PMD rules, a `final` modifier is added to a method parameter in
MentorNotFoundException, and `!isPresent()` is replaced with the more
idiomatic `isEmpty()` in PostgresMenteeRepository. A
`@SuppressWarnings("PMD.TooManyMethods")` annotation is added to
PostgresMentorshipMatchRepository where the method count is
architecturally justified. CLAUDE.md is updated to document the
pre-commit hook and PMD checklist for future contributors.
The pre-commit hook was incomplete — it only handled frontend lint-staged but did not enforce Java code quality checks. This adds automated PMD analysis on staged Java files, blocking commits when violations are found. README and CLAUDE.md are updated to document the hook. MenteeService gets a class-level Javadoc. MenteeServiceIntegrationTest is refactored to extract shared setup/assertion helpers, eliminate duplication, and use named constants for years and limits, improving readability.
src/main/java/com/wcc/platform/repository/postgres/PostgresCountryRepository.java
Show resolved
Hide resolved
The cycleYear field in MenteeRegistration was annotated with @NotNull, which prevented registrations without an explicit year. This change removes the @NotNull constraint and adds a fallback in MenteeService to use the current year when cycleYear is null, making the field optional for clients. A unit test is added to verify the default year behaviour.
The inline mentee persistence logic in saveRegistration was complex and did not preserve existing member types when a member with other roles (e.g. MENTOR) registered as a mentee. Extracting into dedicated private methods (createOrUpdateMentee, handleMenteeWithId, handleMenteeWithoutId, mergeMemberTypes) improves readability and correctness. A test covering the member-type merge scenario is added to prevent regressions. PMD thresholds for TooManyMethods and CouplingBetweenObjects are relaxed to accommodate the grown service and test class.
The comment "Check if member exists and preserve member types" restated what the surrounding code already made clear through its structure and variable names. Removing it keeps the codebase consistent with the project convention of avoiding obvious inline comments.
…lure The findCountryIdByCode method was silently returning a hardcoded default ID of 1L when a country code was not found, which could cause incorrect data associations downstream. Replace this with a proper ContentNotFoundException to surface the error early. Add a full unit test suite for PostgresCountryRepositoryTest covering all CRUD operations and the new exception behaviour, fixing an InvalidUseOfMatchersException caused by using ArgumentMatchers.any() in a static field initializer outside of a Mockito stubbing context.
src/main/java/com/wcc/platform/repository/postgres/mentorship/PostgresMentorRepository.java
Show resolved
Hide resolved
src/main/java/com/wcc/platform/repository/postgres/mentorship/PostgresMentorRepository.java
Show resolved
Hide resolved
src/main/java/com/wcc/platform/repository/postgres/PostgresMemberMemberTypeRepository.java
Outdated
Show resolved
Hide resolved
src/main/java/com/wcc/platform/repository/postgres/mentorship/PostgresMenteeRepository.java
Show resolved
Hide resolved
src/main/java/com/wcc/platform/domain/platform/mentorship/MenteeRegistration.java
Outdated
Show resolved
Hide resolved
src/test/java/com/wcc/platform/repository/postgres/PostgresCountryRepositoryTest.java
Outdated
Show resolved
Hide resolved
Prevents mentees from submitting applications with duplicate priority orders, both within a single request and against existing applications in the same mentorship cycle. Introduces DuplicatedPriorityException, registers it in GlobalExceptionHandler to return 409 Conflict, and covers both scenarios with unit tests. Also introduces DuplicatedException as a common base class for all duplicated-record exceptions to reduce coupling in GlobalExceptionHandler.
- Fix misleading MentorNotFoundException messages in PostgresMentorRepository: create now says "not found after save for id" and update uses mentorId not the object - Replace SELECT COUNT + INSERT with INSERT ON CONFLICT DO NOTHING in PostgresMemberMemberTypeRepository to eliminate the race condition - Ensure provisionUserRole is called even when mentee already has applications in the cycle (early-return path previously skipped role provisioning) - Remove no-op toRegistration() from MenteeRegistration record - Fix PostgresCountryRepositoryTest to invoke the actual ResultSetExtractor lambda via doAnswer so the not-found code path is properly exercised
The timelineLongTermPage.json had stale 2025 dates; updated to reflect the 2026 mentorship cycle with more flexible/accurate durations. Also adds @transactional to PostgresMenteeApplicationRepository.create to ensure the duplicate-check and insert run atomically, preventing a partial state if the insert fails after the check succeeds.
|
womencodingcommunity
approved these changes
Mar 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Implements the full mentee registration flow, including mentor validation,
duplicate handling, cycle resolution, and role provisioning.
Key changes:
Registration logic (MenteeService):
applications (DuplicatedPriorityException → 409 Conflict)
when the mentee already has applications in the cycle
Repository fixes:
silently returning a default ID when a country code is not found
INSERT ... ON CONFLICT DO NOTHING to eliminate the race condition
make the duplicate-check and insert atomic
not object toString; distinguish save failure from not-found)
Exception hierarchy:
exceptions, reducing import count in GlobalExceptionHandler
Quality and tooling:
with duplicate priority and existing-application scenarios
Change Type
Pull request checklist
Please check if your PR fulfills the following requirements: