generated from ministryofjustice/hmpps-template-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2250 from ministryofjustice/feature/aps-1264-send…
…-placement-request-booking-email-to-pr-creator APS-1264 - send placement request booking email to placement request creator
- Loading branch information
Showing
3 changed files
with
84 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.factory.ApprovedPremises | |
import uk.gov.justice.digital.hmpps.approvedpremisesapi.factory.ApprovedPremisesEntityFactory | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.factory.BookingEntityFactory | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.factory.Cas1ApplicationUserDetailsEntityFactory | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.factory.PlacementApplicationEntityFactory | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.factory.PlacementRequestEntityFactory | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.factory.ProbationRegionEntityFactory | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.factory.UserEntityFactory | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.ApAreaEntity | ||
|
@@ -23,6 +25,7 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.unit.service.cas1.Cas1Bo | |
import uk.gov.justice.digital.hmpps.approvedpremisesapi.unit.service.cas1.Cas1BookingEmailServiceTest.TestConstants.AP_AREA_EMAIL | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.unit.service.cas1.Cas1BookingEmailServiceTest.TestConstants.CASE_MANAGER_EMAIL | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.unit.service.cas1.Cas1BookingEmailServiceTest.TestConstants.CRN | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.unit.service.cas1.Cas1BookingEmailServiceTest.TestConstants.PLACEMENT_APPLICATION_CREATOR_EMAIL | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.unit.service.cas1.Cas1BookingEmailServiceTest.TestConstants.PREMISES_EMAIL | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.unit.service.cas1.Cas1BookingEmailServiceTest.TestConstants.PREMISES_NAME | ||
import uk.gov.justice.digital.hmpps.approvedpremisesapi.unit.service.cas1.Cas1BookingEmailServiceTest.TestConstants.REGION_NAME | ||
|
@@ -36,6 +39,7 @@ class Cas1BookingEmailServiceTest { | |
private object TestConstants { | ||
const val AP_AREA_EMAIL = "[email protected]" | ||
const val APPLICANT_EMAIL = "[email protected]" | ||
const val PLACEMENT_APPLICATION_CREATOR_EMAIL = "[email protected]" | ||
const val CRN = "CRN123" | ||
const val PREMISES_EMAIL = "[email protected]" | ||
const val PREMISES_NAME = "The Premises Name" | ||
|
@@ -96,7 +100,6 @@ class Cas1BookingEmailServiceTest { | |
PREMISES_EMAIL, | ||
notifyConfig.templates.bookingMadePremises, | ||
mapOf( | ||
"name" to applicant.name, | ||
"apName" to PREMISES_NAME, | ||
"applicationUrl" to "http://frontend/applications/${application.id}", | ||
"bookingUrl" to "http://frontend/premises/${premises.id}/bookings/${booking.id}", | ||
|
@@ -112,7 +115,7 @@ class Cas1BookingEmailServiceTest { | |
|
||
@SuppressWarnings("CyclomaticComplexMethod") | ||
@Test | ||
fun `bookingMade sends email to applicant and premises email addresses when defined, when length of stay whole number of weeks`() { | ||
fun `bookingMade sends email to applicant, premises email addresses when defined, when length of stay whole number of weeks`() { | ||
val applicant = UserEntityFactory() | ||
.withUnitTestControlProbationRegion() | ||
.withEmail(APPLICANT_EMAIL) | ||
|
@@ -130,7 +133,6 @@ class Cas1BookingEmailServiceTest { | |
mockEmailNotificationService.assertEmailRequestCount(2) | ||
|
||
val personalisation = mapOf( | ||
"name" to applicant.name, | ||
"apName" to PREMISES_NAME, | ||
"applicationUrl" to "http://frontend/applications/${application.id}", | ||
"bookingUrl" to "http://frontend/premises/${premises.id}/bookings/${booking.id}", | ||
|
@@ -193,6 +195,73 @@ class Cas1BookingEmailServiceTest { | |
application, | ||
) | ||
} | ||
|
||
@SuppressWarnings("CyclomaticComplexMethod") | ||
@Test | ||
fun `bookingMade sends email to applicant, placement application creator and premises email addresses for request for placements`() { | ||
val applicant = UserEntityFactory() | ||
.withUnitTestControlProbationRegion() | ||
.withEmail(APPLICANT_EMAIL) | ||
.produce() | ||
|
||
val (application, booking) = createApplicationAndBooking( | ||
applicant, | ||
premises, | ||
arrivalDate = LocalDate.of(2023, 2, 1), | ||
departureDate = LocalDate.of(2023, 2, 14), | ||
) | ||
|
||
booking.placementRequest = PlacementRequestEntityFactory() | ||
.withDefaults() | ||
.withPlacementApplication( | ||
PlacementApplicationEntityFactory() | ||
.withDefaults() | ||
.withCreatedByUser( | ||
UserEntityFactory() | ||
.withUnitTestControlProbationRegion() | ||
.withEmail(PLACEMENT_APPLICATION_CREATOR_EMAIL) | ||
.produce(), | ||
) | ||
.produce(), | ||
) | ||
.produce() | ||
|
||
service.bookingMade(application, booking) | ||
|
||
mockEmailNotificationService.assertEmailRequestCount(3) | ||
|
||
val personalisation = mapOf( | ||
"apName" to PREMISES_NAME, | ||
"applicationUrl" to "http://frontend/applications/${application.id}", | ||
"bookingUrl" to "http://frontend/premises/${premises.id}/bookings/${booking.id}", | ||
"crn" to CRN, | ||
"startDate" to "2023-02-01", | ||
"endDate" to "2023-02-14", | ||
"lengthStay" to 2, | ||
"lengthStayUnit" to "weeks", | ||
) | ||
|
||
mockEmailNotificationService.assertEmailRequested( | ||
APPLICANT_EMAIL, | ||
notifyConfig.templates.bookingMade, | ||
personalisation, | ||
application, | ||
) | ||
|
||
mockEmailNotificationService.assertEmailRequested( | ||
PLACEMENT_APPLICATION_CREATOR_EMAIL, | ||
notifyConfig.templates.bookingMade, | ||
personalisation, | ||
application, | ||
) | ||
|
||
mockEmailNotificationService.assertEmailRequested( | ||
PREMISES_EMAIL, | ||
notifyConfig.templates.bookingMadePremises, | ||
personalisation, | ||
application, | ||
) | ||
} | ||
} | ||
|
||
@Nested | ||
|