-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FPL-35: Send notifications to CAFCASS on case submission (#144)
- Loading branch information
1 parent
6990e2c
commit d380aaa
Showing
11 changed files
with
284 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ services: | |
- FPL_LOCAL_AUTHORITY_CODE_TO_NAME_MAPPING=SA=>Swansea Local Authority;HN=>Hillingdon Local Authority | ||
- FPL_LOCAL_AUTHORITY_USER_MAPPING=SA=>25,26,27;HN=>28,29 | ||
- FPL_LOCAL_AUTHORITY_CODE_TO_HMCTS_COURT_MAPPING=SA=>Swansea Family Court:[email protected];HN=>Portsmouth Combined Court:[email protected] | ||
- FPL_LOCAL_AUTHORITY_CODE_TO_CAFCASS_MAPPING=SA=>Cafcass Cymru:[email protected];HN=>Cafcass:[email protected] | ||
- NOTIFY_API_KEY | ||
- CCD_UI_BASE_URL=http://localhost:3451 | ||
# these environment variables are used by java-logging library | ||
|
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 |
---|---|---|
|
@@ -41,8 +41,9 @@ data: | |
CCD_UI_BASE_URL: "https://ccd-case-management-web-${SERVICE_FQDN}" | ||
FPL_LOCAL_AUTHORITY_EMAIL_TO_CODE_MAPPING: "swansea.gov.uk=>SA;hillingdon.gov.uk=>HN" | ||
FPL_LOCAL_AUTHORITY_CODE_TO_NAME_MAPPING: "SA=>Swansea Local Authority;HN=>Hillingdon Local Authority" | ||
FPL_LOCAL_AUTHORITY_USER_MAPPING: "SA=>25,26,27;HN=>28,29" | ||
FPL_LOCAL_AUTHORITY_USER_MAPPING: "SA=>22,23,24;HN=>25,26" | ||
FPL_LOCAL_AUTHORITY_CODE_TO_HMCTS_COURT_MAPPING: "SA=>Swansea Family Court:[email protected];HN=>Portsmouth Combined Court:[email protected]" | ||
FPL_LOCAL_AUTHORITY_CODE_TO_CAFCASS_MAPPING: "SA=>Cafcass Cymru:[email protected];HN=>Cafcass:[email protected]" | ||
NOTIFY_API_KEY: ${NOTIFY_API_KEY} | ||
|
||
--- | ||
|
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
import static uk.gov.hmcts.reform.fpl.CaseDefinitionConstants.CASE_TYPE; | ||
import static uk.gov.hmcts.reform.fpl.CaseDefinitionConstants.JURISDICTION; | ||
import static uk.gov.hmcts.reform.fpl.NotifyTemplates.CAFCASS_SUBMISSION_TEMPLATE; | ||
import static uk.gov.hmcts.reform.fpl.NotifyTemplates.HMCTS_COURT_SUBMISSION_TEMPLATE; | ||
import static uk.gov.hmcts.reform.fpl.utils.DocumentManagementStoreLoader.document; | ||
import static uk.gov.hmcts.reform.fpl.utils.ResourceReader.readBytes; | ||
|
@@ -103,10 +104,12 @@ void shouldReturnUnsuccessfulResponseWithMalformedData() throws Exception { | |
} | ||
|
||
@Test | ||
void shouldBuildTemplateWithCompleteValues() throws Exception { | ||
Map<String, String> expectedParameters = ImmutableMap.<String, String>builder() | ||
void shouldBuildNotificationTemplatesWithCompleteValues() throws Exception { | ||
Map<String, String> expectedHmctsParameters = ImmutableMap.<String, String>builder() | ||
.put("court", "Family Court") | ||
.put("localAuthority", "Example Local Authority") | ||
.put("dataPresent", "Yes") | ||
.put("fullStop", "No") | ||
.put("orders0", "^Emergency protection order") | ||
.put("orders1", "") | ||
.put("orders2", "") | ||
|
@@ -119,6 +122,21 @@ void shouldBuildTemplateWithCompleteValues() throws Exception { | |
.put("caseUrl", "http://fake-url/case/" + JURISDICTION + "/" + CASE_TYPE + "/12345") | ||
.build(); | ||
|
||
Map<String, String> expectedCafcassParameters = ImmutableMap.<String, String>builder() | ||
.put("cafcass", "cafcass") | ||
.put("localAuthority", "Example Local Authority") | ||
.put("dataPresent", "Yes") | ||
.put("fullStop", "No") | ||
.put("orders0", "^Emergency protection order") | ||
.put("orders1", "") | ||
.put("orders2", "") | ||
.put("orders3", "") | ||
.put("orders4", "") | ||
.put("directionsAndInterim", "^Information on the whereabouts of the child") | ||
.put("reference", "12345") | ||
.put("caseUrl", "http://fake-url/case/" + JURISDICTION + "/" + CASE_TYPE + "/12345") | ||
.build(); | ||
|
||
mockMvc | ||
.perform(post("/callback/case-submission/submitted") | ||
.header("authorization", AUTH_TOKEN) | ||
|
@@ -128,12 +146,16 @@ void shouldBuildTemplateWithCompleteValues() throws Exception { | |
.andExpect(status().isOk()); | ||
|
||
verify(notificationClient, times(1)).sendEmail( | ||
eq(HMCTS_COURT_SUBMISSION_TEMPLATE), eq("[email protected]"), eq(expectedParameters), eq("12345") | ||
eq(HMCTS_COURT_SUBMISSION_TEMPLATE), eq("[email protected]"), eq(expectedHmctsParameters), eq("12345") | ||
); | ||
|
||
verify(notificationClient, times(1)).sendEmail( | ||
eq(CAFCASS_SUBMISSION_TEMPLATE), eq("[email protected]"), eq(expectedCafcassParameters), eq("12345") | ||
); | ||
} | ||
|
||
@Test | ||
void shouldBuildTemplateWithValuesMissingInCallback() throws Exception { | ||
void shouldBuildNotificationTemplatesWithValuesMissingInCallback() throws Exception { | ||
CallbackRequest request = CallbackRequest.builder() | ||
.caseDetails(CaseDetails.builder() | ||
.id(12345L) | ||
|
@@ -142,9 +164,11 @@ void shouldBuildTemplateWithValuesMissingInCallback() throws Exception { | |
.build()) | ||
.build(); | ||
|
||
Map<String, String> expectedParameters = ImmutableMap.<String, String>builder() | ||
Map<String, String> expectedHmctsParameters = ImmutableMap.<String, String>builder() | ||
.put("court", "Family Court") | ||
.put("localAuthority", "Example Local Authority") | ||
.put("dataPresent", "No") | ||
.put("fullStop", "Yes") | ||
.put("orders0", "") | ||
.put("orders1", "") | ||
.put("orders2", "") | ||
|
@@ -157,6 +181,21 @@ void shouldBuildTemplateWithValuesMissingInCallback() throws Exception { | |
.put("caseUrl", "http://fake-url/case/" + JURISDICTION + "/" + CASE_TYPE + "/12345") | ||
.build(); | ||
|
||
Map<String, String> expectedCafcassParameters = ImmutableMap.<String, String>builder() | ||
.put("cafcass", "cafcass") | ||
.put("localAuthority", "Example Local Authority") | ||
.put("dataPresent", "No") | ||
.put("fullStop", "Yes") | ||
.put("orders0", "") | ||
.put("orders1", "") | ||
.put("orders2", "") | ||
.put("orders3", "") | ||
.put("orders4", "") | ||
.put("directionsAndInterim", "") | ||
.put("reference", "12345") | ||
.put("caseUrl", "http://fake-url/case/" + JURISDICTION + "/" + CASE_TYPE + "/12345") | ||
.build(); | ||
|
||
mockMvc | ||
.perform(post("/callback/case-submission/submitted") | ||
.header("authorization", AUTH_TOKEN) | ||
|
@@ -166,7 +205,11 @@ void shouldBuildTemplateWithValuesMissingInCallback() throws Exception { | |
.andExpect(status().isOk()); | ||
|
||
verify(notificationClient, times(1)).sendEmail( | ||
eq(HMCTS_COURT_SUBMISSION_TEMPLATE), eq("[email protected]"), eq(expectedParameters), eq("12345") | ||
eq(HMCTS_COURT_SUBMISSION_TEMPLATE), eq("[email protected]"), eq(expectedHmctsParameters), eq("12345") | ||
); | ||
|
||
verify(notificationClient, times(1)).sendEmail( | ||
eq(CAFCASS_SUBMISSION_TEMPLATE), eq("[email protected]"), eq(expectedCafcassParameters), eq("12345") | ||
); | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -17,4 +17,6 @@ fpl.local_authority_user.mapping=example=>1,2,3 | |
|
||
fpl.local_authority_code_to_hmcts_court.mapping=example=>Family Court:[email protected] | ||
|
||
fpl.local_authority_code_to_cafcass.mapping=example=>cafcass:[email protected] | ||
|
||
notify.api_key=testApiKey |
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
51 changes: 51 additions & 0 deletions
51
service/src/main/java/uk/gov/hmcts/reform/fpl/config/CafcassLookupConfiguration.java
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package uk.gov.hmcts.reform.fpl.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
import uk.gov.hmcts.reform.fpl.config.utils.LookupConfigParser; | ||
|
||
import java.util.Map; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
import static com.google.common.base.Strings.emptyToNull; | ||
|
||
@Configuration | ||
public class CafcassLookupConfiguration { | ||
|
||
private final Map<String, Cafcass> mapping; | ||
|
||
public CafcassLookupConfiguration(@Value("${fpl.local_authority_code_to_cafcass.mapping}") | ||
String config) { | ||
this.mapping = LookupConfigParser.parse(config, value -> { | ||
String[] entrySplit = value.split(":", 2); | ||
return new Cafcass( | ||
checkNotNull(emptyToNull(entrySplit[0]), "Cafcass name cannot be empty"), | ||
checkNotNull(emptyToNull(entrySplit[1]), "Cafcass email cannot be empty") | ||
); | ||
}); | ||
} | ||
|
||
public Cafcass getCafcass(String localAuthorityCode) { | ||
checkNotNull(localAuthorityCode, "Local authority code cannot be null"); | ||
|
||
return checkNotNull(mapping.get(localAuthorityCode), "Local authority '" + localAuthorityCode + "' not found"); | ||
} | ||
|
||
public static class Cafcass { | ||
private final String name; | ||
private final String email; | ||
|
||
public Cafcass(String name, String email) { | ||
this.name = name; | ||
this.email = email; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.