-
Notifications
You must be signed in to change notification settings - Fork 7
FPL-35: Send notifications to CAFCASS on case submission #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FPL-35: Send notifications to CAFCASS on case submission #144
Conversation
Added mappings between LA code and Cafcass. Added template id for Cafcass
@@ -17,4 +17,6 @@ fpl.local_authority_user.mapping=example=>1,2,3 | |||
|
|||
fpl.local_authority_code_to_hmcts_court.mapping=example=>Family Court:admin@family-court.com | |||
|
|||
fpl.local_authority_code_to_cafcass.mapping=example=>example:cafcass@cafcass.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change CAFCASS name so that it does not look like LA code.
import static com.google.common.base.Strings.emptyToNull; | ||
|
||
@Configuration | ||
public class CafcassEmailLookupConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename as it is not about looking up for email anymore.
|
||
private Map<String, String> buildHmctsSubmissionNotification(CaseDetails caseDetails, String localAuthorityCode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should extract this to separate classes that are well unit tested taking all options into consideration. Let's do that next sprint as tech debt.
Class itself could be called EmailContentProvider ;)
|
||
List orderType = (List) Optional.ofNullable(orders.get("orderType")).orElse(ImmutableList.builder().build()); | ||
logger.debug( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we extract couple of lines (starting with debug, ending with exception handling) into separate method and reuse across both notification method. Logging logic is same.
@@ -87,6 +109,8 @@ public void sendNotificationToHmctsAdmin(SubmittedCaseEvent event) { | |||
return ImmutableMap.<String, String>builder() | |||
.put("court", hmctsCourtLookupConfiguration.getCourt(localAuthorityCode).getName()) | |||
.put("localAuthority", localAuthorityNameLookupConfiguration.getLocalAuthorityName(localAuthorityCode)) | |||
.put("dataPresent", (orderType.isEmpty()) ? ("No") : ("Yes")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove these curly brackets , that add no value.
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
class CafcassEmailLookupConfigurationTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test rename should follow proposed class rename as well.
|
||
@Test | ||
void shouldReturnCafcassEmailWhenLocalAuthorityCodeExists() { | ||
CafcassEmailLookupConfiguration.Cafcass cafcass = configuration.getCafcass(LOCAL_AUTHORITY_CODE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do static import so we see Cafcass cafcass
.
@@ -6,5 +6,6 @@ private NotifyTemplates() { | |||
//NO-OP | |||
} | |||
|
|||
public static final String HMCTS_COURT_SUBMISSION_TEMPLATE = "1b1be684-9b0a-4e58-8e51-f0c3c2dba37c"; | |||
public static final String HMCTS_COURT_SUBMISSION_TEMPLATE = "c76d4fb2-d2b0-4ac5-9c3a-fb1fb964a257"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
.put("timeFrameValue", Optional.ofNullable((String) hearing.get("timeFrame")).orElse("")) | ||
.put("reference", String.valueOf(caseDetails.getId())) | ||
.put("caseUrl", uiBaseUrl + "/case/" + JURISDICTION + "/" + CASE_TYPE + "/" + caseDetails.getId()) | ||
.build(); | ||
} | ||
|
||
private Map<String, String> buildCafcassSubmissionNotification(CaseDetails caseDetails, String localAuthorityCode) { | ||
final String name = cafcassLookupConfiguration.getCafcass(localAuthorityCode).getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove final
before we merge.
} | ||
|
||
@Test | ||
void shouldReturnCafcassEmailWhenLocalAuthorityCodeExists() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename as now whole Cafcass object is returned, not only an email.
.build(); | ||
|
||
given(cafcassLookupConfiguration.getCafcass(LOCAL_AUTHORITY_CODE)) | ||
.willReturn(new CafcassLookupConfiguration.Cafcass(CAFCASS_NAME, CAFCASS_EMAIL_ADDRESS)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please static import CafcassLookupConfiguration.Cafcass
so that we do not see CafcassLookupConfiguration
part.
…mcts/fpl-ccd-configuration into FPL-35-notify-cafcass-after-submission
JIRA link (if applicable)
https://tools.hmcts.net/jira/browse/FPL-35
Change description
Added mappings between LA code and Cafcass. Added template id for Cafcass
Does this PR introduce a breaking change? (check one with "x")