From 43daa45e1774b737e98dbb407216ad6523dad83e Mon Sep 17 00:00:00 2001
From: Sowmiya Ravikumar
Date: Tue, 29 Sep 2026 13:35:47 +0100
Subject: [PATCH 1/4] task: Add Adhoc Note to New Mentee Notification Email
---
.../configuration/GlobalExceptionHandler.java | 2 +
.../configuration/NotificationConfig.java | 1 +
.../MentorshipNotificationService.java | 7 +++-
src/main/resources/application.yml | 6 ++-
.../alert_new_mentees_applications_mentor.yml | 6 ++-
.../GlobalExceptionHandlerTest.java | 14 +++++++
.../MentorshipNotificationServiceTest.java | 42 +++++++++++++++++++
7 files changed, 74 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/wcc/platform/configuration/GlobalExceptionHandler.java b/src/main/java/com/wcc/platform/configuration/GlobalExceptionHandler.java
index d841238f9..1cc887981 100644
--- a/src/main/java/com/wcc/platform/configuration/GlobalExceptionHandler.java
+++ b/src/main/java/com/wcc/platform/configuration/GlobalExceptionHandler.java
@@ -15,6 +15,7 @@
import com.wcc.platform.domain.exceptions.ErrorDetails;
import com.wcc.platform.domain.exceptions.ForbiddenException;
import com.wcc.platform.domain.exceptions.InvalidCycleStatusTransitionException;
+import com.wcc.platform.domain.exceptions.InvalidMentorshipTypeException;
import com.wcc.platform.domain.exceptions.InvalidProgramTypeException;
import com.wcc.platform.domain.exceptions.InvalidTokenException;
import com.wcc.platform.domain.exceptions.MemberNotFoundException;
@@ -89,6 +90,7 @@ public ResponseEntity handleInternalError(
*/
@ExceptionHandler({
InvalidProgramTypeException.class,
+ InvalidMentorshipTypeException.class,
IllegalArgumentException.class,
TemplateValidationException.class
})
diff --git a/src/main/java/com/wcc/platform/configuration/NotificationConfig.java b/src/main/java/com/wcc/platform/configuration/NotificationConfig.java
index 259ea6e30..c00081215 100644
--- a/src/main/java/com/wcc/platform/configuration/NotificationConfig.java
+++ b/src/main/java/com/wcc/platform/configuration/NotificationConfig.java
@@ -21,4 +21,5 @@ public class NotificationConfig {
@NotBlank private String mentorProfileUrl;
@NotBlank private String volunteerUrl;
@NotBlank private String mentorshipEmail;
+ @NotBlank private String adhocMenteeNote;
}
diff --git a/src/main/java/com/wcc/platform/service/MentorshipNotificationService.java b/src/main/java/com/wcc/platform/service/MentorshipNotificationService.java
index 0a8558195..7f5ac6e43 100644
--- a/src/main/java/com/wcc/platform/service/MentorshipNotificationService.java
+++ b/src/main/java/com/wcc/platform/service/MentorshipNotificationService.java
@@ -153,13 +153,18 @@ public void sendNewMenteesNotification(final Mentor mentor, final MentorshipCycl
cycle.getCycleYear() != null
? cycle.getCycleYear().getValue()
: LocalDate.now(ZONE_ID).getYear();
+ final String adhocNote =
+ cycle.getMentorshipType() == MentorshipType.AD_HOC
+ ? notificationConfig.getAdhocMenteeNote()
+ : "";
sendNotification(
TemplateType.NEW_MENTEES_REVIEW,
Map.of(
"mentorName", mentor.getFullName(),
"year", year,
"cycleType", cycle.getMentorshipType().getDescription(),
- "mentorshipEmail", notificationConfig.getMentorshipEmail()),
+ "mentorshipEmail", notificationConfig.getMentorshipEmail(),
+ "adhocNote", adhocNote),
List.of(mentor.getEmail(), notificationConfig.getMentorshipEmail()));
}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index a91c04930..2e1b72e0b 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -44,6 +44,10 @@ notification:
mentorship-email: mentorship@womencodingcommunity.com
mentor-profile-url: https://mentorship.womencodingcommunity.com/mentorship/mentors?keyword=
volunteer-url: https://www.womencodingcommunity.com/volunteer
+ adhoc-mentee-note: >-
+ In an Ad-Hoc cycle, a mentee can apply to more than one mentor. Once any mentor accepts,
+ the application is no longer available to others. If you cannot find an application in your
+ dashboard, it may have already been accepted by another mentor.
logging:
level:
@@ -65,7 +69,7 @@ file:
app:
cors:
- allowed-origins: http://localhost:3000,https://localhost:3000
+ allowed-origins: http://localhost:4000,https://localhost:4000
email:
team-signature: |
Best Regards
diff --git a/src/main/resources/email-templates/alert_new_mentees_applications_mentor.yml b/src/main/resources/email-templates/alert_new_mentees_applications_mentor.yml
index e28de2cc9..15a114c1f 100644
--- a/src/main/resources/email-templates/alert_new_mentees_applications_mentor.yml
+++ b/src/main/resources/email-templates/alert_new_mentees_applications_mentor.yml
@@ -7,10 +7,12 @@ NEW_MENTEES_REVIEW:
- You have new mentee applications currently pending your review.
- Could you please log into your Mentor Dashboard today to check?
+ You have new mentee applications currently pending your review.
+ Could you please log into your Mentor Dashboard today to check?
+ {{adhocNote}}
+
As an action point, please approve the mentee(s) you'd like to accept, or reject so that their application(s) can be forwarded to other mentors.
diff --git a/src/test/java/com/wcc/platform/configuration/GlobalExceptionHandlerTest.java b/src/test/java/com/wcc/platform/configuration/GlobalExceptionHandlerTest.java
index f6755ee49..e1b0c3292 100644
--- a/src/test/java/com/wcc/platform/configuration/GlobalExceptionHandlerTest.java
+++ b/src/test/java/com/wcc/platform/configuration/GlobalExceptionHandlerTest.java
@@ -13,6 +13,7 @@
import com.wcc.platform.domain.exceptions.DuplicatedMemberException;
import com.wcc.platform.domain.exceptions.ErrorDetails;
import com.wcc.platform.domain.exceptions.ForbiddenException;
+import com.wcc.platform.domain.exceptions.InvalidMentorshipTypeException;
import com.wcc.platform.domain.platform.mentorship.TechnicalAreaProficiency;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
@@ -100,6 +101,19 @@ void shouldReturnConflictForDataAccessException() {
assertEquals(expectation, response.getBody());
}
+ @Test
+ @DisplayName(
+ "Given InvalidMentorshipTypeException, when handling, then return BAD_REQUEST")
+ void shouldReturnBadRequestForInvalidMentorshipTypeException() {
+ var exception = new InvalidMentorshipTypeException("Cycle type mismatch");
+
+ var response = globalExceptionHandler.handleProgramTypeError(exception, webRequest);
+
+ var expectation = new ErrorDetails(BAD_REQUEST.value(), "Cycle type mismatch", DETAILS);
+ assertEquals(BAD_REQUEST, response.getStatusCode());
+ assertEquals(expectation, response.getBody());
+ }
+
@Test
@DisplayName(
"Given malformed JSON with unknown field, "
diff --git a/src/test/java/com/wcc/platform/service/MentorshipNotificationServiceTest.java b/src/test/java/com/wcc/platform/service/MentorshipNotificationServiceTest.java
index 6215c5569..5a0d7fb13 100644
--- a/src/test/java/com/wcc/platform/service/MentorshipNotificationServiceTest.java
+++ b/src/test/java/com/wcc/platform/service/MentorshipNotificationServiceTest.java
@@ -16,7 +16,9 @@
import com.wcc.platform.domain.platform.mentorship.ApplicationStatus;
import com.wcc.platform.domain.platform.mentorship.MatchStatus;
import com.wcc.platform.domain.platform.mentorship.Mentor;
+import com.wcc.platform.domain.platform.mentorship.MentorshipCycleEntity;
import com.wcc.platform.domain.platform.mentorship.MentorshipMatch;
+import com.wcc.platform.domain.platform.mentorship.MentorshipType;
import com.wcc.platform.domain.template.RenderedTemplate;
import com.wcc.platform.domain.template.TemplateType;
import com.wcc.platform.repository.MemberRepository;
@@ -181,6 +183,46 @@ void shouldSendNotificationByMemberId() {
assertThat(emailRequest.getRecipients()).contains("team@test.com");
}
+ @Test
+ @DisplayName(
+ "Given an Ad-Hoc cycle, when sendNewMenteesNotification, then adhocNote is included in template params")
+ void shouldIncludeAdhocNoteForAdHocCycle() {
+ var adhocNote = "In an Ad-Hoc cycle, a mentee can apply to more than one mentor.
";
+ var cycle =
+ MentorshipCycleEntity.builder().mentorshipType(MentorshipType.AD_HOC).build();
+
+ when(notificationConfig.getMentorshipEmail()).thenReturn("team@test.com");
+ when(notificationConfig.getAdhocMenteeNote()).thenReturn(adhocNote);
+ when(emailTemplateService.renderTemplate(any(), any()))
+ .thenReturn(new RenderedTemplate("Subject", "Body"));
+
+ notificationService.sendNewMenteesNotification(mentor, cycle);
+
+ @SuppressWarnings("unchecked")
+ ArgumentCaptor