From 891a28d662fb26d59464315708c365516f3b2eac Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Mon, 28 Oct 2024 13:07:22 +0000 Subject: [PATCH 01/18] Implement logic to handle international addresses for Docmosis templates. Update references to new TB-SCS-LET-ENG-Appeal-Lodged-Representative-IB template. --- cftlib_log_file_IS_UNDEFINED | 0 dump.rdb | Bin 0 -> 88 bytes .../config/NotificationConfigTestIt.java | 16 +-- .../NotificationsDelayedNotificationsIt.java | 10 +- .../GenericLetterPlaceholderService.java | 2 +- .../placeholders/PlaceholderService.java | 29 ++--- .../placeholders/PlaceholderUtility.java | 2 +- .../tyanotifications/service/LetterUtils.java | 17 ++- .../service/SendNotificationService.java | 28 +++-- .../service/docmosis/PdfLetterService.java | 32 ++---- src/main/resources/config/application.yaml | 8 +- .../service/LetterUtilsTest.java | 99 ++++++++++++++++++ 12 files changed, 166 insertions(+), 77 deletions(-) create mode 100644 cftlib_log_file_IS_UNDEFINED create mode 100644 dump.rdb diff --git a/cftlib_log_file_IS_UNDEFINED b/cftlib_log_file_IS_UNDEFINED new file mode 100644 index 00000000000..e69de29bb2d diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 0000000000000000000000000000000000000000..e19054dfa040a5f8406121e22d67c63add85b413 GIT binary patch literal 88 zcmWG?b@2=~FfcUy#aWb^l3A= placeholders) { String[] lines = lines(address); + List addressConstants = List.of(RECIPIENT_ADDRESS_LINE_1_LITERAL, RECIPIENT_ADDRESS_LINE_2_LITERAL, RECIPIENT_ADDRESS_LINE_3_LITERAL, + RECIPIENT_ADDRESS_LINE_4_LITERAL, RECIPIENT_ADDRESS_LINE_5_LITERAL); - if (lines.length >= 1) { - placeholders.put(RECIPIENT_ADDRESS_LINE_1_LITERAL, truncateAddressLine(defaultToEmptyStringIfNull(lines[0]))); - } - if (lines.length >= 2) { - placeholders.put(RECIPIENT_ADDRESS_LINE_2_LITERAL, truncateAddressLine(defaultToEmptyStringIfNull(lines[1]))); - } - if (lines.length >= 3) { - placeholders.put(RECIPIENT_ADDRESS_LINE_3_LITERAL, truncateAddressLine(defaultToEmptyStringIfNull(lines[2]))); - } - if (lines.length >= 4) { - placeholders.put(RECIPIENT_ADDRESS_LINE_4_LITERAL, truncateAddressLine(defaultToEmptyStringIfNull(lines[3]))); - } - if (lines.length >= 5) { - placeholders.put(RECIPIENT_ADDRESS_LINE_5_LITERAL, truncateAddressLine(defaultToEmptyStringIfNull(lines[4]))); + for (int i = 0; i < lines.length; i++) { + placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); } } - - public static String[] lines(Address address) { - return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getCounty(), address.getPostcode()) - .filter(Objects::nonNull) - .toArray(String[]::new); - } - } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java index 1acb0a9ce81..bfa59f6ea78 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java @@ -4,7 +4,7 @@ import static org.apache.commons.lang3.StringUtils.isNoneBlank; import static uk.gov.hmcts.reform.sscs.ccd.domain.YesNo.isYes; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderService.lines; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java index e99e9151aae..632b0bb06b0 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java @@ -11,10 +11,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import java.util.stream.Stream; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.Pair; @@ -322,4 +319,16 @@ static boolean isValidOtherPartyRepresentative(String subscriptionPartyId, Strin } return false; } + + public static String[] lines(Address address) { + if (isYes(address.getInMainlandUk()) || address.getInMainlandUk() == null) { + return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getCounty(), address.getPostcode()) + .filter(x -> x != null) + .toArray(String[]::new); + } else { + return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getPostcode(), address.getCountry()) + .filter(x -> x != null) + .toArray(String[]::new); + } + } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java index ca299aef2e8..d9f19e46a94 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java @@ -1,9 +1,13 @@ package uk.gov.hmcts.reform.sscs.tyanotifications.service; import static java.util.Objects.nonNull; -import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.apache.commons.lang3.StringUtils.isNotBlank; import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.*; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_1; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_2; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_3; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_4; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_POSTCODE; import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.*; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.*; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.CORRECTION_GRANTED; @@ -20,11 +24,13 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -228,13 +234,14 @@ protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Noti if (addressToUse != null) { Map placeholders = notification.getPlaceholders(); String fullNameNoTitle = getNameToUseForLetter(wrapper, subscriptionWithType); + placeholders.put(ADDRESS_NAME, fullNameNoTitle); - placeholders.put(ADDRESS_LINE_1, fullNameNoTitle); - placeholders.put(ADDRESS_LINE_2, addressToUse.getLine1()); - placeholders.put(ADDRESS_LINE_3, isEmpty(addressToUse.getLine2()) ? " " : addressToUse.getLine2()); - placeholders.put(ADDRESS_LINE_4, addressToUse.getTown() == null ? " " : addressToUse.getTown()); - placeholders.put(ADDRESS_LINE_5, addressToUse.getCounty() == null ? " " : addressToUse.getCounty()); - placeholders.put(POSTCODE_LITERAL, addressToUse.getPostcode()); + String[] lines = lines(addressToUse); + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); + for (int i = 0; i < lines.length; i++) { + placeholders.put(addressConstants.get(i), defaultToEmptyStringIfNull(lines[i])); + } placeholders.put(NAME, fullNameNoTitle); if (SubscriptionType.REPRESENTATIVE.equals(subscriptionWithType.getSubscriptionType())) { @@ -250,7 +257,6 @@ protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Noti } log.info("In sendLetterNotificationToAddress method notificationSender is available {} ", notificationSender != null); - notificationLog(notification, "GovNotify letter", addressToUse.getPostcode(), wrapper); notificationSender.sendLetter( @@ -263,7 +269,7 @@ protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Noti ); } } - + private static boolean isValidLetterAddress(Address addressToUse) { return null != addressToUse && isNotBlank(addressToUse.getLine1()) @@ -404,4 +410,8 @@ private static String getDocumentForType(AbstractDocument sscsDocument) { return null; } + private static String defaultToEmptyStringIfNull(String value) { + return (value == null) ? StringUtils.EMPTY : value; + } + } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java index aaa7d891d98..4c1035737ab 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java @@ -1,5 +1,10 @@ package uk.gov.hmcts.reform.sscs.tyanotifications.service.docmosis; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_1; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_2; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_3; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_4; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_POSTCODE; import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.*; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.APPEAL_RECEIVED; import static uk.gov.hmcts.reform.sscs.tyanotifications.personalisation.Personalisation.translateToWelshDate; @@ -12,7 +17,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; @@ -114,6 +118,7 @@ public byte[] generateLetter(NotificationWrapper wrapper, Notification notificat Address addressToUse = getAddressToUseForLetter(wrapper, subscriptionWithType); buildRecipientAddressPlaceholders(addressToUse, placeholders); + placeholders.put(docmosisTemplatesConfig.getHmctsImgKey(), docmosisTemplatesConfig.getHmctsImgVal()); placeholders.put(docmosisTemplatesConfig.getHmctsWelshImgKey(), docmosisTemplatesConfig.getHmctsWelshImgVal()); @@ -129,28 +134,12 @@ public byte[] generateLetter(NotificationWrapper wrapper, Notification notificat private void buildRecipientAddressPlaceholders(Address address, Map placeholders) { String[] lines = lines(address); + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - if (lines.length >= 1) { - placeholders.put(LETTER_ADDRESS_LINE_1, truncateAddressLine(defaultToEmptyStringIfNull(lines[0]))); - } - if (lines.length >= 2) { - placeholders.put(LETTER_ADDRESS_LINE_2, truncateAddressLine(defaultToEmptyStringIfNull(lines[1]))); - } - if (lines.length >= 3) { - placeholders.put(LETTER_ADDRESS_LINE_3, truncateAddressLine(defaultToEmptyStringIfNull(lines[2]))); - } - if (lines.length >= 4) { - placeholders.put(LETTER_ADDRESS_LINE_4, truncateAddressLine(defaultToEmptyStringIfNull(lines[3]))); + for (int i = 0; i < lines.length; i++) { + placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); } - if (lines.length >= 5) { - placeholders.put(LETTER_ADDRESS_POSTCODE, truncateAddressLine(defaultToEmptyStringIfNull(lines[4]))); - } - } - - private static String[] lines(Address address) { - return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getCounty(), address.getPostcode()) - .filter(x -> x != null) - .toArray(String[]::new); } private static String defaultToEmptyStringIfNull(String value) { @@ -162,4 +151,3 @@ private static String truncateAddressLine(String addressLine) { } } - diff --git a/src/main/resources/config/application.yaml b/src/main/resources/config/application.yaml index 67962fdedf9..936606d8e80 100644 --- a/src/main/resources/config/application.yaml +++ b/src/main/resources/config/application.yaml @@ -526,7 +526,7 @@ notification: emailId: d5fd9f65-1283-4533-a1be-10043dae7af6 smsId: ede384aa-0b6e-4311-9f01-ee547573a07b letterId: 91143b85-dd9d-430c-ba23-e42ec90f44f8 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx representative: emailId: 3d05393a-e593-400a-963f-a26893a0b672 smsId: 99bd4a56-256c-4de8-b187-d43a8dde466f @@ -536,7 +536,7 @@ notification: emailId: 78cf9c9c-e2b8-44d7-bcf1-220311f114cb smsId: ede384aa-0b6e-4311-9f01-ee547573a07b letterId: 747d026e-1bec-4e96-8a34-28f36e30bba5 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx hearingAdjourned: appellant: emailId: 77ea995b-9744-4167-9250-e627c85e5eda @@ -692,7 +692,7 @@ notification: appellant: emailId: 01293b93-b23e-40a3-ad78-2c6cd01cd21c smsId: f41222ef-c05c-4682-9634-6b034a166368 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx representative: emailId: 652753bf-59b4-46eb-9c24-bd762338a098 smsId: a6c09fad-6265-4c7c-8b95-36245ffa5352 @@ -700,7 +700,7 @@ notification: appointee: emailId: 362d9a85-e0e4-412b-b874-020c0464e2b4 smsId: f41222ef-c05c-4682-9634-6b034a166368 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx struckOut: docmosisId: TB-SCS-GNO-ENG-00466.docx processAudioVideo: diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java index 54282682ef9..4ad641fc8a6 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java @@ -672,4 +672,103 @@ public NotificationSscsCaseDataWrapper buildBaseWrapperWithCaseData(SscsCaseData .build(); return caseDataWrapper; } + + @DisplayName("lines returns expected values when given a valid UK address object.") + @Test + public void lines_returns_expected_for_UK_address() { + Address testAddress = Address.builder() + .line1("Somerset House") + .line2("Strand") + .town("London") + .county("Greater London") + .postcode("WC2R 1LA") + .build(); + + String[] addressLines = lines(testAddress); + List expectedLines = List.of("Somerset House", "Strand", "London", "Greater London", "WC2R 1LA"); + + for (int i = 0; i < addressLines.length; i++) { + assertEquals(expectedLines.get(i), addressLines[i]); + } + } + + @DisplayName("lines returns expected values when given a valid UK address object with inMainlandUK YES.") + @Test + public void lines_returns_expected_for_UK_address_with_inMainlandUK() { + Address testAddress = Address.builder() + .line1("Somerset House") + .line2("Strand") + .town("London") + .county("Greater London") + .postcode("WC2R 1LA") + .inMainlandUk(YesNo.YES) + .build(); + + String[] addressLines = lines(testAddress); + List expectedLines = List.of("Somerset House", "Strand", "London", "Greater London", "WC2R 1LA"); + + for (int i = 0; i < addressLines.length; i++) { + assertEquals(expectedLines.get(i), addressLines[i]); + } + } + + @DisplayName("lines returns expected values when given a valid international address object.") + @Test + public void lines_returns_expected_for_International_address() { + Address testAddress = Address.builder() + .line1("Catherdrale Notre-Dame de Paris") + .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") + .town("Paris") + .county("Ile-de_France") + .postcode("75004") + .country("France") + .inMainlandUk(YesNo.NO) + .build(); + + String[] addressLines = lines(testAddress); + List expectedLines = List.of("Catherdrale Notre-Dame de Paris", "6 Parvis Notre-dame - Pl. Jean-Paul II", "Paris", "75004", "France"); + + for (int i = 0; i < addressLines.length; i++) { + assertEquals(expectedLines.get(i), addressLines[i]); + } + } + + @DisplayName("lines returns expected values when international address object doesn't include postcode.") + @Test + public void lines_returns_expected_for_International_address_without_Postcode() { + Address testAddress = Address.builder() + .line1("Catherdrale Notre-Dame de Paris") + .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") + .town("Paris") + .county("Ile-de_France") + .country("France") + .inMainlandUk(YesNo.NO) + .build(); + + String[] addressLines = lines(testAddress); + List expectedLines = List.of("Catherdrale Notre-Dame de Paris", "6 Parvis Notre-dame - Pl. Jean-Paul II", "Paris", "France"); + + for (int i = 0; i < addressLines.length; i++) { + assertEquals(expectedLines.get(i), addressLines[i]); + } + } + + @DisplayName("lines filters out null address lines for UK addresses.") + @Test + public void lines_removes_null_values() { + Address testAddress = Address.builder() + .line1("Test House") + .line2(null) + .town("Test Town") + .county("Test County") + .postcode("Test Postcode") + .build(); + + String[] addressLines = lines(testAddress); + List expectedLines = List.of("Test House", "Test Town", "Test County", "Test Postcode"); + + for (int i = 0; i < addressLines.length; i++) { + assertEquals(expectedLines.get(i), addressLines[i]); + } + } } From 1233555c9941925a9384de503faaf7ba6c3afe51 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Mon, 28 Oct 2024 16:22:17 +0000 Subject: [PATCH 02/18] Implement logic to handle international addresses for Docmosis templates. Update references to new TB-SCS-LET-ENG-Appeal-Lodged-Representative-IB template. --- .../tyanotifications/config/NotificationConfigTestIt.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java index f7a2f6506aa..08336a6ae97 100644 --- a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java +++ b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java @@ -626,10 +626,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{REQUEST_FOR_INFORMATION, true, JOINT_PARTY, PAPER, LIST_ASSIST, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, new Object[]{REQUEST_FOR_INFORMATION, true, REPRESENTATIVE, PAPER, LIST_ASSIST, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, ORAL, LIST_ASSIST, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, PAPER, LIST_ASSIST, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, From f06697c82f53a1eb60214b96f65b7dfa3eeea2c7 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Mon, 28 Oct 2024 17:58:34 +0000 Subject: [PATCH 03/18] Remove unused files. --- cftlib_log_file_IS_UNDEFINED | 0 dump.rdb | Bin 88 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 cftlib_log_file_IS_UNDEFINED delete mode 100644 dump.rdb diff --git a/cftlib_log_file_IS_UNDEFINED b/cftlib_log_file_IS_UNDEFINED deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/dump.rdb b/dump.rdb deleted file mode 100644 index e19054dfa040a5f8406121e22d67c63add85b413..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 88 zcmWG?b@2=~FfcUy#aWb^l3A= Date: Tue, 29 Oct 2024 19:15:35 +0000 Subject: [PATCH 04/18] update path for APPEAL_RECEIVED docmosis letter template --- .../tya/NotificationsDelayedNotificationsIt.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/tya/NotificationsDelayedNotificationsIt.java b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/tya/NotificationsDelayedNotificationsIt.java index 83a3b0b2f3b..d90ed46aa29 100644 --- a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/tya/NotificationsDelayedNotificationsIt.java +++ b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/tya/NotificationsDelayedNotificationsIt.java @@ -256,7 +256,7 @@ private Object[] generateRepsNotificationScenariosForDelayedNotifications() { "paper", Collections.emptyList(), Collections.emptyList(), - Arrays.asList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"), + Arrays.asList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"), "no", "no", "no", From 66d66450e121957fc3407826872891a802c3f042 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Tue, 29 Oct 2024 20:53:38 +0000 Subject: [PATCH 05/18] update LetterUtils imports and revert appeal-received letter template name --- .../config/NotificationConfigTestIt.java | 24 +++++++++---------- .../NotificationsDelayedNotificationsIt.java | 12 +++++----- .../tyanotifications/service/LetterUtils.java | 5 +++- src/main/resources/config/application.yaml | 8 +++---- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java index 08336a6ae97..ad238315d24 100644 --- a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java +++ b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java @@ -102,10 +102,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, ORAL, GAPS, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, PAPER, GAPS, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, - new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, GAPS, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, GAPS, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, GAPS, "validAppeal", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, PAPER, GAPS, null, "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, - new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, GAPS, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, GAPS, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, GAPS, "validAppeal", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, PAPER, GAPS, null, "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, REPRESENTATIVE, ORAL, GAPS, "readyToList", "3d05393a-e593-400a-963f-a26893a0b672", List.of("99bd4a56-256c-4de8-b187-d43a8dde466f"), "77ea8a2f-06df-4279-9c1f-0f23cb2d9bbf", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, @@ -314,10 +314,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{REQUEST_FOR_INFORMATION, true, JOINT_PARTY, PAPER, GAPS, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, new Object[]{REQUEST_FOR_INFORMATION, true, REPRESENTATIVE, PAPER, GAPS, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, ORAL, GAPS, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, PAPER, GAPS, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, @@ -414,10 +414,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, ORAL, LIST_ASSIST, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, PAPER, LIST_ASSIST, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, - new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, LIST_ASSIST, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, LIST_ASSIST, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, LIST_ASSIST, "validAppeal", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, PAPER, LIST_ASSIST, null, "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, - new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, LIST_ASSIST, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, LIST_ASSIST, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, LIST_ASSIST, "validAppeal", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, REPRESENTATIVE, ORAL, LIST_ASSIST, "readyToList", "3d05393a-e593-400a-963f-a26893a0b672", List.of("99bd4a56-256c-4de8-b187-d43a8dde466f"), "77ea8a2f-06df-4279-9c1f-0f23cb2d9bbf", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, @@ -626,10 +626,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{REQUEST_FOR_INFORMATION, true, JOINT_PARTY, PAPER, LIST_ASSIST, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, new Object[]{REQUEST_FOR_INFORMATION, true, REPRESENTATIVE, PAPER, LIST_ASSIST, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, ORAL, LIST_ASSIST, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, PAPER, LIST_ASSIST, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, diff --git a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/tya/NotificationsDelayedNotificationsIt.java b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/tya/NotificationsDelayedNotificationsIt.java index d90ed46aa29..b98152edae7 100644 --- a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/tya/NotificationsDelayedNotificationsIt.java +++ b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/tya/NotificationsDelayedNotificationsIt.java @@ -106,7 +106,7 @@ private Object[] generateAppointeeNotificationScenariosForDelayedNotifications() "paper", Collections.singletonList("78cf9c9c-e2b8-44d7-bcf1-220311f114cb"), Collections.singletonList("ede384aa-0b6e-4311-9f01-ee547573a07b"), - Collections.singletonList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"), + Collections.singletonList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"), "yes", "yes", "1", @@ -119,7 +119,7 @@ private Object[] generateAppointeeNotificationScenariosForDelayedNotifications() "oral", Collections.singletonList("78cf9c9c-e2b8-44d7-bcf1-220311f114cb"), Collections.singletonList("ede384aa-0b6e-4311-9f01-ee547573a07b"), - Collections.singletonList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"), + Collections.singletonList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"), "yes", "yes", "1", @@ -132,7 +132,7 @@ private Object[] generateAppointeeNotificationScenariosForDelayedNotifications() "paper", Collections.emptyList(), Collections.emptyList(), - Collections.singletonList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"), + Collections.singletonList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"), "no", "no", "0", @@ -228,7 +228,7 @@ private Object[] generateRepsNotificationScenariosForDelayedNotifications() { "oral", Arrays.asList("d5fd9f65-1283-4533-a1be-10043dae7af6", "3d05393a-e593-400a-963f-a26893a0b672"), Arrays.asList("ede384aa-0b6e-4311-9f01-ee547573a07b", "99bd4a56-256c-4de8-b187-d43a8dde466f"), - Arrays.asList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"), + Arrays.asList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"), "yes", "yes", "yes", @@ -242,7 +242,7 @@ private Object[] generateRepsNotificationScenariosForDelayedNotifications() { "paper", Collections.singletonList("3d05393a-e593-400a-963f-a26893a0b672"), Arrays.asList("ede384aa-0b6e-4311-9f01-ee547573a07b", "99bd4a56-256c-4de8-b187-d43a8dde466f"), - Arrays.asList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"), + Arrays.asList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"), "no", "yes", "yes", @@ -256,7 +256,7 @@ private Object[] generateRepsNotificationScenariosForDelayedNotifications() { "paper", Collections.emptyList(), Collections.emptyList(), - Arrays.asList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"), + Arrays.asList("TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"), "no", "no", "no", diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java index 632b0bb06b0..090f419849a 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java @@ -11,7 +11,10 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; import java.util.stream.Stream; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.Pair; diff --git a/src/main/resources/config/application.yaml b/src/main/resources/config/application.yaml index 936606d8e80..67962fdedf9 100644 --- a/src/main/resources/config/application.yaml +++ b/src/main/resources/config/application.yaml @@ -526,7 +526,7 @@ notification: emailId: d5fd9f65-1283-4533-a1be-10043dae7af6 smsId: ede384aa-0b6e-4311-9f01-ee547573a07b letterId: 91143b85-dd9d-430c-ba23-e42ec90f44f8 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx representative: emailId: 3d05393a-e593-400a-963f-a26893a0b672 smsId: 99bd4a56-256c-4de8-b187-d43a8dde466f @@ -536,7 +536,7 @@ notification: emailId: 78cf9c9c-e2b8-44d7-bcf1-220311f114cb smsId: ede384aa-0b6e-4311-9f01-ee547573a07b letterId: 747d026e-1bec-4e96-8a34-28f36e30bba5 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx hearingAdjourned: appellant: emailId: 77ea995b-9744-4167-9250-e627c85e5eda @@ -692,7 +692,7 @@ notification: appellant: emailId: 01293b93-b23e-40a3-ad78-2c6cd01cd21c smsId: f41222ef-c05c-4682-9634-6b034a166368 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx representative: emailId: 652753bf-59b4-46eb-9c24-bd762338a098 smsId: a6c09fad-6265-4c7c-8b95-36245ffa5352 @@ -700,7 +700,7 @@ notification: appointee: emailId: 362d9a85-e0e4-412b-b874-020c0464e2b4 smsId: f41222ef-c05c-4682-9634-6b034a166368 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx struckOut: docmosisId: TB-SCS-GNO-ENG-00466.docx processAudioVideo: From c8d87e5a2413214a4f40bb6f629b0704ce1a4b6a Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Thu, 31 Oct 2024 12:20:44 +0000 Subject: [PATCH 06/18] Update appeal-received letter template name to IBA --- src/main/resources/config/application.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/config/application.yaml b/src/main/resources/config/application.yaml index 67962fdedf9..936606d8e80 100644 --- a/src/main/resources/config/application.yaml +++ b/src/main/resources/config/application.yaml @@ -526,7 +526,7 @@ notification: emailId: d5fd9f65-1283-4533-a1be-10043dae7af6 smsId: ede384aa-0b6e-4311-9f01-ee547573a07b letterId: 91143b85-dd9d-430c-ba23-e42ec90f44f8 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx representative: emailId: 3d05393a-e593-400a-963f-a26893a0b672 smsId: 99bd4a56-256c-4de8-b187-d43a8dde466f @@ -536,7 +536,7 @@ notification: emailId: 78cf9c9c-e2b8-44d7-bcf1-220311f114cb smsId: ede384aa-0b6e-4311-9f01-ee547573a07b letterId: 747d026e-1bec-4e96-8a34-28f36e30bba5 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx hearingAdjourned: appellant: emailId: 77ea995b-9744-4167-9250-e627c85e5eda @@ -692,7 +692,7 @@ notification: appellant: emailId: 01293b93-b23e-40a3-ad78-2c6cd01cd21c smsId: f41222ef-c05c-4682-9634-6b034a166368 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx representative: emailId: 652753bf-59b4-46eb-9c24-bd762338a098 smsId: a6c09fad-6265-4c7c-8b95-36245ffa5352 @@ -700,7 +700,7 @@ notification: appointee: emailId: 362d9a85-e0e4-412b-b874-020c0464e2b4 smsId: f41222ef-c05c-4682-9634-6b034a166368 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx struckOut: docmosisId: TB-SCS-GNO-ENG-00466.docx processAudioVideo: From 9c1b6a7b06ca8888cf4a095be3e47bcb894402b9 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Thu, 31 Oct 2024 13:03:51 +0000 Subject: [PATCH 07/18] Update notification tests. --- .../config/NotificationConfigTestIt.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java index ad238315d24..08336a6ae97 100644 --- a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java +++ b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java @@ -102,10 +102,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, ORAL, GAPS, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, PAPER, GAPS, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, - new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, GAPS, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, GAPS, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, GAPS, "validAppeal", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, PAPER, GAPS, null, "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, - new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, GAPS, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, GAPS, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, GAPS, "validAppeal", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, PAPER, GAPS, null, "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, REPRESENTATIVE, ORAL, GAPS, "readyToList", "3d05393a-e593-400a-963f-a26893a0b672", List.of("99bd4a56-256c-4de8-b187-d43a8dde466f"), "77ea8a2f-06df-4279-9c1f-0f23cb2d9bbf", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, @@ -314,10 +314,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{REQUEST_FOR_INFORMATION, true, JOINT_PARTY, PAPER, GAPS, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, new Object[]{REQUEST_FOR_INFORMATION, true, REPRESENTATIVE, PAPER, GAPS, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, ORAL, GAPS, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, PAPER, GAPS, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, @@ -414,10 +414,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, ORAL, LIST_ASSIST, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, PAPER, LIST_ASSIST, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, - new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, LIST_ASSIST, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, LIST_ASSIST, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, LIST_ASSIST, "validAppeal", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, PAPER, LIST_ASSIST, null, "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, - new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, LIST_ASSIST, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, LIST_ASSIST, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, LIST_ASSIST, "validAppeal", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, REPRESENTATIVE, ORAL, LIST_ASSIST, "readyToList", "3d05393a-e593-400a-963f-a26893a0b672", List.of("99bd4a56-256c-4de8-b187-d43a8dde466f"), "77ea8a2f-06df-4279-9c1f-0f23cb2d9bbf", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, @@ -626,10 +626,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{REQUEST_FOR_INFORMATION, true, JOINT_PARTY, PAPER, LIST_ASSIST, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, new Object[]{REQUEST_FOR_INFORMATION, true, REPRESENTATIVE, PAPER, LIST_ASSIST, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, ORAL, LIST_ASSIST, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, PAPER, LIST_ASSIST, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, From 250b932c434392b31941480265c0182d90e4fbb6 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Fri, 1 Nov 2024 20:11:41 +0000 Subject: [PATCH 08/18] Refactor to use Address method getFullAddress. --- cftlib_log_file_IS_UNDEFINED | 0 .../GenericLetterPlaceholderService.java | 16 +-- .../placeholders/PlaceholderService.java | 10 +- .../placeholders/PlaceholderUtility.java | 16 +-- .../tyanotifications/service/LetterUtils.java | 12 --- .../service/SendNotificationService.java | 22 ++--- .../service/docmosis/PdfLetterService.java | 9 +- .../GenericLetterPlaceholderServiceTest.java | 1 - .../service/LetterUtilsTest.java | 99 ------------------- 9 files changed, 42 insertions(+), 143 deletions(-) create mode 100644 cftlib_log_file_IS_UNDEFINED diff --git a/cftlib_log_file_IS_UNDEFINED b/cftlib_log_file_IS_UNDEFINED new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java index 382bb37439e..9188055443d 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java @@ -5,10 +5,11 @@ import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.defaultToEmptyStringIfNull; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.truncateAddressLine; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; import java.time.LocalDateTime; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -104,13 +105,16 @@ private String getAppealReference(SscsCaseData caseData) { private Map getAddressPlaceHolders(Address address) { var addressPlaceHolders = new HashMap(); - String[] lines = lines(address); - String[] addressConstants = {LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, - LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE}; + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - for (int i = 0; i < lines.length; i++) { - addressPlaceHolders.put(addressConstants[i], truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); + String addressString = address.getFullAddress(); + List addressList = !addressString.isEmpty() ? Arrays.asList(addressString.split(", ")) : List.of(); + + for (int i = 0; i < addressList.size(); i++) { + addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(addressList.get(i)))); } + System.out.printf(addressPlaceHolders.toString()); return addressPlaceHolders; } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java index d0eb0f1ecc0..7ee99112c16 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java @@ -4,9 +4,9 @@ import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.defaultToEmptyStringIfNull; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.truncateAddressLine; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; import java.time.LocalDateTime; +import java.util.Arrays; import java.util.List; import java.util.Map; import lombok.extern.slf4j.Slf4j; @@ -113,12 +113,14 @@ public boolean hasRegionalProcessingCenter(SscsCaseData ccdResponse) { } private void buildRecipientAddressPlaceholders(Address address, Map placeholders) { - String[] lines = lines(address); List addressConstants = List.of(RECIPIENT_ADDRESS_LINE_1_LITERAL, RECIPIENT_ADDRESS_LINE_2_LITERAL, RECIPIENT_ADDRESS_LINE_3_LITERAL, RECIPIENT_ADDRESS_LINE_4_LITERAL, RECIPIENT_ADDRESS_LINE_5_LITERAL); - for (int i = 0; i < lines.length; i++) { - placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); + String addressString = address.getFullAddress(); + List addressList = !addressString.isEmpty() ? Arrays.asList(addressString.split(", ")) : List.of(); + + for (int i = 0; i < addressList.size(); i++) { + placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(addressList.get(i)))); } } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java index bfa59f6ea78..a99c66cb296 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java @@ -4,9 +4,10 @@ import static org.apache.commons.lang3.StringUtils.isNoneBlank; import static uk.gov.hmcts.reform.sscs.ccd.domain.YesNo.isYes; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; import lombok.extern.slf4j.Slf4j; @@ -174,14 +175,15 @@ private static boolean isValidName(Name name) { static Map getAddressPlaceHolders(Address address) { var addressPlaceHolders = new HashMap(); - String[] lines = lines(address); - String[] addressConstants = {LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, - LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE}; + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - for (int i = 0; i < lines.length; i++) { - addressPlaceHolders.put(addressConstants[i], truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); - } + String addressString = address.getFullAddress(); + List addressList = !addressString.isEmpty() ? Arrays.asList(addressString.split(", ")) : List.of(); + for (int i = 0; i < addressList.size(); i++) { + addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(addressList.get(i)))); + } return addressPlaceHolders; } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java index 090f419849a..e99e9151aae 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java @@ -322,16 +322,4 @@ static boolean isValidOtherPartyRepresentative(String subscriptionPartyId, Strin } return false; } - - public static String[] lines(Address address) { - if (isYes(address.getInMainlandUk()) || address.getInMainlandUk() == null) { - return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getCounty(), address.getPostcode()) - .filter(x -> x != null) - .toArray(String[]::new); - } else { - return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getPostcode(), address.getCountry()) - .filter(x -> x != null) - .toArray(String[]::new); - } - } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java index d9f19e46a94..b121b3b3682 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java @@ -23,10 +23,7 @@ import java.io.IOException; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; @@ -230,17 +227,20 @@ private boolean sendMandatoryLetterNotification(NotificationWrapper wrapper, Not return false; } - protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Notification notification, final Address addressToUse, SubscriptionWithType subscriptionWithType) throws NotificationClientException { - if (addressToUse != null) { + protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Notification notification, final Address address, SubscriptionWithType subscriptionWithType) throws NotificationClientException { + if (address != null) { Map placeholders = notification.getPlaceholders(); String fullNameNoTitle = getNameToUseForLetter(wrapper, subscriptionWithType); placeholders.put(ADDRESS_NAME, fullNameNoTitle); - String[] lines = lines(addressToUse); List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - for (int i = 0; i < lines.length; i++) { - placeholders.put(addressConstants.get(i), defaultToEmptyStringIfNull(lines[i])); + + String addressString = address.getFullAddress(); + List addressList = !addressString.isEmpty() ? Arrays.asList(addressString.split(", ")) : List.of(); + + for (int i = 0; i < addressList.size(); i++) { + placeholders.put(addressConstants.get(i), defaultToEmptyStringIfNull(addressList.get(i))); } placeholders.put(NAME, fullNameNoTitle); @@ -257,11 +257,11 @@ protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Noti } log.info("In sendLetterNotificationToAddress method notificationSender is available {} ", notificationSender != null); - notificationLog(notification, "GovNotify letter", addressToUse.getPostcode(), wrapper); + notificationLog(notification, "GovNotify letter", address.getPostcode(), wrapper); notificationSender.sendLetter( notification.getLetterTemplate(), - addressToUse, + address, notification.getPlaceholders(), wrapper.getNotificationType(), fullNameNoTitle, diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java index 4c1035737ab..b698ce938dc 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java @@ -13,6 +13,7 @@ import java.io.IOException; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -133,12 +134,14 @@ public byte[] generateLetter(NotificationWrapper wrapper, Notification notificat } private void buildRecipientAddressPlaceholders(Address address, Map placeholders) { - String[] lines = lines(address); List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - for (int i = 0; i < lines.length; i++) { - placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); + String addressString = address.getFullAddress(); + List addressList = !addressString.isEmpty() ? Arrays.asList(addressString.split(", ")) : List.of(); + + for (int i = 0; i < addressList.size(); i++) { + placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(addressList.get(i)))); } } diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderServiceTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderServiceTest.java index acd7f84b2c6..0ecd5081aed 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderServiceTest.java @@ -154,7 +154,6 @@ void shouldReturnEmptyAddressPlaceholdersGivenEmptyAddress() { Map placeholders = genericLetterPlaceholderService.populatePlaceholders(caseData, APPELLANT_LETTER, null); - assertNotNull(placeholders); assertFalse(placeholders.containsKey(LETTER_ADDRESS_LINE_1)); assertFalse(placeholders.containsKey(LETTER_ADDRESS_LINE_2)); diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java index 4ad641fc8a6..54282682ef9 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java @@ -672,103 +672,4 @@ public NotificationSscsCaseDataWrapper buildBaseWrapperWithCaseData(SscsCaseData .build(); return caseDataWrapper; } - - @DisplayName("lines returns expected values when given a valid UK address object.") - @Test - public void lines_returns_expected_for_UK_address() { - Address testAddress = Address.builder() - .line1("Somerset House") - .line2("Strand") - .town("London") - .county("Greater London") - .postcode("WC2R 1LA") - .build(); - - String[] addressLines = lines(testAddress); - List expectedLines = List.of("Somerset House", "Strand", "London", "Greater London", "WC2R 1LA"); - - for (int i = 0; i < addressLines.length; i++) { - assertEquals(expectedLines.get(i), addressLines[i]); - } - } - - @DisplayName("lines returns expected values when given a valid UK address object with inMainlandUK YES.") - @Test - public void lines_returns_expected_for_UK_address_with_inMainlandUK() { - Address testAddress = Address.builder() - .line1("Somerset House") - .line2("Strand") - .town("London") - .county("Greater London") - .postcode("WC2R 1LA") - .inMainlandUk(YesNo.YES) - .build(); - - String[] addressLines = lines(testAddress); - List expectedLines = List.of("Somerset House", "Strand", "London", "Greater London", "WC2R 1LA"); - - for (int i = 0; i < addressLines.length; i++) { - assertEquals(expectedLines.get(i), addressLines[i]); - } - } - - @DisplayName("lines returns expected values when given a valid international address object.") - @Test - public void lines_returns_expected_for_International_address() { - Address testAddress = Address.builder() - .line1("Catherdrale Notre-Dame de Paris") - .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") - .town("Paris") - .county("Ile-de_France") - .postcode("75004") - .country("France") - .inMainlandUk(YesNo.NO) - .build(); - - String[] addressLines = lines(testAddress); - List expectedLines = List.of("Catherdrale Notre-Dame de Paris", "6 Parvis Notre-dame - Pl. Jean-Paul II", "Paris", "75004", "France"); - - for (int i = 0; i < addressLines.length; i++) { - assertEquals(expectedLines.get(i), addressLines[i]); - } - } - - @DisplayName("lines returns expected values when international address object doesn't include postcode.") - @Test - public void lines_returns_expected_for_International_address_without_Postcode() { - Address testAddress = Address.builder() - .line1("Catherdrale Notre-Dame de Paris") - .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") - .town("Paris") - .county("Ile-de_France") - .country("France") - .inMainlandUk(YesNo.NO) - .build(); - - String[] addressLines = lines(testAddress); - List expectedLines = List.of("Catherdrale Notre-Dame de Paris", "6 Parvis Notre-dame - Pl. Jean-Paul II", "Paris", "France"); - - for (int i = 0; i < addressLines.length; i++) { - assertEquals(expectedLines.get(i), addressLines[i]); - } - } - - @DisplayName("lines filters out null address lines for UK addresses.") - @Test - public void lines_removes_null_values() { - Address testAddress = Address.builder() - .line1("Test House") - .line2(null) - .town("Test Town") - .county("Test County") - .postcode("Test Postcode") - .build(); - - String[] addressLines = lines(testAddress); - List expectedLines = List.of("Test House", "Test Town", "Test County", "Test Postcode"); - - for (int i = 0; i < addressLines.length; i++) { - assertEquals(expectedLines.get(i), addressLines[i]); - } - } } From 04254d54fa438a7269b739874b877e613f735b0d Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Fri, 1 Nov 2024 20:12:25 +0000 Subject: [PATCH 09/18] Refactor to use Address method getFullAddress. --- .../service/placeholders/GenericLetterPlaceholderService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java index 9188055443d..976651c9492 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java @@ -114,8 +114,6 @@ private Map getAddressPlaceHolders(Address address) { for (int i = 0; i < addressList.size(); i++) { addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(addressList.get(i)))); } - System.out.printf(addressPlaceHolders.toString()); - return addressPlaceHolders; } } From 9c49a7092e3a02fd1d467c681abd4de9748f6fe1 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Mon, 4 Nov 2024 13:59:17 +0000 Subject: [PATCH 10/18] Revert back to using lines for addresses to satisfy IssueFurtherEvidenceServiceIt. --- .../config/NotificationConfigTestIt.java | 24 ++--- .../GenericLetterPlaceholderService.java | 10 +- .../placeholders/PlaceholderService.java | 9 +- .../placeholders/PlaceholderUtility.java | 9 +- .../tyanotifications/service/LetterUtils.java | 12 +++ .../service/SendNotificationService.java | 12 ++- .../service/docmosis/PdfLetterService.java | 9 +- src/main/resources/config/application.yaml | 8 +- .../service/LetterUtilsTest.java | 100 ++++++++++++++++++ 9 files changed, 151 insertions(+), 42 deletions(-) diff --git a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java index 08336a6ae97..ad238315d24 100644 --- a/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java +++ b/src/IntegrationTests/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/NotificationConfigTestIt.java @@ -102,10 +102,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, ORAL, GAPS, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, PAPER, GAPS, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, - new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, GAPS, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, GAPS, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, GAPS, "validAppeal", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, PAPER, GAPS, null, "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, - new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, GAPS, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, GAPS, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, GAPS, "validAppeal", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, PAPER, GAPS, null, "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, REPRESENTATIVE, ORAL, GAPS, "readyToList", "3d05393a-e593-400a-963f-a26893a0b672", List.of("99bd4a56-256c-4de8-b187-d43a8dde466f"), "77ea8a2f-06df-4279-9c1f-0f23cb2d9bbf", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, @@ -314,10 +314,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{REQUEST_FOR_INFORMATION, true, JOINT_PARTY, PAPER, GAPS, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, new Object[]{REQUEST_FOR_INFORMATION, true, REPRESENTATIVE, PAPER, GAPS, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, GAPS, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, GAPS, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, ORAL, GAPS, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, PAPER, GAPS, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, @@ -414,10 +414,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, ORAL, LIST_ASSIST, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, new Object[]{APPEAL_LAPSED, true, REPRESENTATIVE, PAPER, LIST_ASSIST, null, "dc8164a8-b923-4896-9308-3bf8e74d5665", List.of("77180ecb-c7e8-407c-8d74-618ae37b47b6","ee58f7d0-8de7-4bee-acd4-252213db6b7b"), null, "TB-SCS-GNO-WEL-00658.docx"}, - new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, LIST_ASSIST, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, LIST_ASSIST, "readyToList", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, ORAL, LIST_ASSIST, "validAppeal", "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, new Object[]{APPEAL_RECEIVED, false, APPELLANT, PAPER, LIST_ASSIST, null, "d5fd9f65-1283-4533-a1be-10043dae7af6", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "91143b85-dd9d-430c-ba23-e42ec90f44f8", null}, - new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, LIST_ASSIST, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, LIST_ASSIST, "readyToList", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, ORAL, LIST_ASSIST, "validAppeal", "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "78cf9c9c-e2b8-44d7-bcf1-220311f114cb", List.of("ede384aa-0b6e-4311-9f01-ee547573a07b"), "747d026e-1bec-4e96-8a34-28f36e30bba5", null}, new Object[]{APPEAL_RECEIVED, false, REPRESENTATIVE, ORAL, LIST_ASSIST, "readyToList", "3d05393a-e593-400a-963f-a26893a0b672", List.of("99bd4a56-256c-4de8-b187-d43a8dde466f"), "77ea8a2f-06df-4279-9c1f-0f23cb2d9bbf", "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, @@ -626,10 +626,10 @@ private static Object[] templateIdsWithHearingAndEventTypes() { new Object[]{REQUEST_FOR_INFORMATION, true, JOINT_PARTY, PAPER, LIST_ASSIST, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, new Object[]{REQUEST_FOR_INFORMATION, true, REPRESENTATIVE, PAPER, LIST_ASSIST, null, null, Collections.emptyList(), null, "TB-SCS-GNO-WEL-00589.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, - new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, ORAL, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPELLANT, PAPER, LIST_ASSIST, null, "01293b93-b23e-40a3-ad78-2c6cd01cd21c", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, ORAL, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, + new Object[]{RESEND_APPEAL_CREATED, false, APPOINTEE, PAPER, LIST_ASSIST, null, "362d9a85-e0e4-412b-b874-020c0464e2b4", List.of("f41222ef-c05c-4682-9634-6b034a166368"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, ORAL, LIST_ASSIST, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, new Object[]{RESEND_APPEAL_CREATED, false, REPRESENTATIVE, PAPER, LIST_ASSIST, null, "652753bf-59b4-46eb-9c24-bd762338a098", List.of("a6c09fad-6265-4c7c-8b95-36245ffa5352"), null, "TB-SCS-LET-ENG-Appeal-Lodged-Representative.docx"}, diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java index 976651c9492..a2608e6f16c 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java @@ -5,9 +5,9 @@ import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.defaultToEmptyStringIfNull; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.truncateAddressLine; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; import java.time.LocalDateTime; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -108,11 +108,11 @@ private Map getAddressPlaceHolders(Address address) { List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - String addressString = address.getFullAddress(); - List addressList = !addressString.isEmpty() ? Arrays.asList(addressString.split(", ")) : List.of(); + String[] lines = lines(address); - for (int i = 0; i < addressList.size(); i++) { - addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(addressList.get(i)))); + + for (int i = 0; i < lines.length; i++) { + addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); } return addressPlaceHolders; } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java index 7ee99112c16..39d0a7aaaaa 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java @@ -4,9 +4,9 @@ import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.defaultToEmptyStringIfNull; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.truncateAddressLine; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; import java.time.LocalDateTime; -import java.util.Arrays; import java.util.List; import java.util.Map; import lombok.extern.slf4j.Slf4j; @@ -116,11 +116,10 @@ private void buildRecipientAddressPlaceholders(Address address, Map addressConstants = List.of(RECIPIENT_ADDRESS_LINE_1_LITERAL, RECIPIENT_ADDRESS_LINE_2_LITERAL, RECIPIENT_ADDRESS_LINE_3_LITERAL, RECIPIENT_ADDRESS_LINE_4_LITERAL, RECIPIENT_ADDRESS_LINE_5_LITERAL); - String addressString = address.getFullAddress(); - List addressList = !addressString.isEmpty() ? Arrays.asList(addressString.split(", ")) : List.of(); + String[] lines = lines(address); - for (int i = 0; i < addressList.size(); i++) { - placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(addressList.get(i)))); + for (int i = 0; i < lines.length; i++) { + placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); } } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java index a99c66cb296..c590179fcd6 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java @@ -4,8 +4,8 @@ import static org.apache.commons.lang3.StringUtils.isNoneBlank; import static uk.gov.hmcts.reform.sscs.ccd.domain.YesNo.isYes; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -178,11 +178,10 @@ static Map getAddressPlaceHolders(Address address) { List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - String addressString = address.getFullAddress(); - List addressList = !addressString.isEmpty() ? Arrays.asList(addressString.split(", ")) : List.of(); + String[] lines = lines(address); - for (int i = 0; i < addressList.size(); i++) { - addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(addressList.get(i)))); + for (int i = 0; i < lines.length; i++) { + addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); } return addressPlaceHolders; } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java index e99e9151aae..090f419849a 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java @@ -322,4 +322,16 @@ static boolean isValidOtherPartyRepresentative(String subscriptionPartyId, Strin } return false; } + + public static String[] lines(Address address) { + if (isYes(address.getInMainlandUk()) || address.getInMainlandUk() == null) { + return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getCounty(), address.getPostcode()) + .filter(x -> x != null) + .toArray(String[]::new); + } else { + return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getPostcode(), address.getCountry()) + .filter(x -> x != null) + .toArray(String[]::new); + } + } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java index b121b3b3682..f290a0140cb 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java @@ -23,7 +23,10 @@ import java.io.IOException; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.*; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; @@ -236,11 +239,10 @@ protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Noti List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - String addressString = address.getFullAddress(); - List addressList = !addressString.isEmpty() ? Arrays.asList(addressString.split(", ")) : List.of(); + String[] lines = lines(address); - for (int i = 0; i < addressList.size(); i++) { - placeholders.put(addressConstants.get(i), defaultToEmptyStringIfNull(addressList.get(i))); + for (int i = 0; i < lines.length; i++) { + placeholders.put(addressConstants.get(i), defaultToEmptyStringIfNull(lines[i])); } placeholders.put(NAME, fullNameNoTitle); diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java index b698ce938dc..21bad163a3a 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java @@ -13,7 +13,6 @@ import java.io.IOException; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -136,12 +135,10 @@ public byte[] generateLetter(NotificationWrapper wrapper, Notification notificat private void buildRecipientAddressPlaceholders(Address address, Map placeholders) { List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); + String[] lines = lines(address); - String addressString = address.getFullAddress(); - List addressList = !addressString.isEmpty() ? Arrays.asList(addressString.split(", ")) : List.of(); - - for (int i = 0; i < addressList.size(); i++) { - placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(addressList.get(i)))); + for (int i = 0; i < lines.length; i++) { + placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); } } diff --git a/src/main/resources/config/application.yaml b/src/main/resources/config/application.yaml index 936606d8e80..67962fdedf9 100644 --- a/src/main/resources/config/application.yaml +++ b/src/main/resources/config/application.yaml @@ -526,7 +526,7 @@ notification: emailId: d5fd9f65-1283-4533-a1be-10043dae7af6 smsId: ede384aa-0b6e-4311-9f01-ee547573a07b letterId: 91143b85-dd9d-430c-ba23-e42ec90f44f8 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx representative: emailId: 3d05393a-e593-400a-963f-a26893a0b672 smsId: 99bd4a56-256c-4de8-b187-d43a8dde466f @@ -536,7 +536,7 @@ notification: emailId: 78cf9c9c-e2b8-44d7-bcf1-220311f114cb smsId: ede384aa-0b6e-4311-9f01-ee547573a07b letterId: 747d026e-1bec-4e96-8a34-28f36e30bba5 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx hearingAdjourned: appellant: emailId: 77ea995b-9744-4167-9250-e627c85e5eda @@ -692,7 +692,7 @@ notification: appellant: emailId: 01293b93-b23e-40a3-ad78-2c6cd01cd21c smsId: f41222ef-c05c-4682-9634-6b034a166368 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx representative: emailId: 652753bf-59b4-46eb-9c24-bd762338a098 smsId: a6c09fad-6265-4c7c-8b95-36245ffa5352 @@ -700,7 +700,7 @@ notification: appointee: emailId: 362d9a85-e0e4-412b-b874-020c0464e2b4 smsId: f41222ef-c05c-4682-9634-6b034a166368 - docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant-IB.docx + docmosisId: TB-SCS-LET-ENG-Appeal-Lodged-Appellant.docx struckOut: docmosisId: TB-SCS-GNO-ENG-00466.docx processAudioVideo: diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java index 54282682ef9..57b09fc9fc3 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java @@ -672,4 +672,104 @@ public NotificationSscsCaseDataWrapper buildBaseWrapperWithCaseData(SscsCaseData .build(); return caseDataWrapper; } + + + @DisplayName("lines returns expected values when given a valid UK address object.") + @Test + public void lines_returns_expected_for_UK_address() { + Address testAddress = Address.builder() + .line1("Somerset House") + .line2("Strand") + .town("London") + .county("Greater London") + .postcode("WC2R 1LA") + .build(); + + String[] addressLines = lines(testAddress); + List expectedLines = List.of("Somerset House", "Strand", "London", "Greater London", "WC2R 1LA"); + + for (int i = 0; i < addressLines.length; i++) { + assertEquals(expectedLines.get(i), addressLines[i]); + } + } + + @DisplayName("lines returns expected values when given a valid UK address object with inMainlandUK YES.") + @Test + public void lines_returns_expected_for_UK_address_with_inMainlandUK() { + Address testAddress = Address.builder() + .line1("Somerset House") + .line2("Strand") + .town("London") + .county("Greater London") + .postcode("WC2R 1LA") + .inMainlandUk(YesNo.YES) + .build(); + + String[] addressLines = lines(testAddress); + List expectedLines = List.of("Somerset House", "Strand", "London", "Greater London", "WC2R 1LA"); + + for (int i = 0; i < addressLines.length; i++) { + assertEquals(expectedLines.get(i), addressLines[i]); + } + } + + @DisplayName("lines returns expected values when given a valid international address object.") + @Test + public void lines_returns_expected_for_International_address() { + Address testAddress = Address.builder() + .line1("Catherdrale Notre-Dame de Paris") + .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") + .town("Paris") + .county("Ile-de_France") + .postcode("75004") + .country("France") + .inMainlandUk(YesNo.NO) + .build(); + + String[] addressLines = lines(testAddress); + List expectedLines = List.of("Catherdrale Notre-Dame de Paris", "6 Parvis Notre-dame - Pl. Jean-Paul II", "Paris", "75004", "France"); + + for (int i = 0; i < addressLines.length; i++) { + assertEquals(expectedLines.get(i), addressLines[i]); + } + } + + @DisplayName("lines returns expected values when international address object doesn't include postcode.") + @Test + public void lines_returns_expected_for_International_address_without_Postcode() { + Address testAddress = Address.builder() + .line1("Catherdrale Notre-Dame de Paris") + .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") + .town("Paris") + .county("Ile-de_France") + .country("France") + .inMainlandUk(YesNo.NO) + .build(); + + String[] addressLines = lines(testAddress); + List expectedLines = List.of("Catherdrale Notre-Dame de Paris", "6 Parvis Notre-dame - Pl. Jean-Paul II", "Paris", "France"); + + for (int i = 0; i < addressLines.length; i++) { + assertEquals(expectedLines.get(i), addressLines[i]); + } + } + + @DisplayName("lines filters out null address lines for UK addresses.") + @Test + public void lines_removes_null_values() { + Address testAddress = Address.builder() + .line1("Test House") + .line2(null) + .town("Test Town") + .county("Test County") + .postcode("Test Postcode") + .build(); + + String[] addressLines = lines(testAddress); + List expectedLines = List.of("Test House", "Test Town", "Test County", "Test Postcode"); + + for (int i = 0; i < addressLines.length; i++) { + assertEquals(expectedLines.get(i), addressLines[i]); + } + } } From 40b7208fc9e9775409483f401d014aa4d22a84f3 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Mon, 4 Nov 2024 19:21:15 +0000 Subject: [PATCH 11/18] lines now returns List --- .../GenericLetterPlaceholderService.java | 7 ++--- .../placeholders/PlaceholderService.java | 6 ++-- .../placeholders/PlaceholderUtility.java | 6 ++-- .../tyanotifications/service/LetterUtils.java | 6 ++-- .../service/SendNotificationService.java | 6 ++-- .../service/docmosis/PdfLetterService.java | 6 ++-- .../service/LetterUtilsTest.java | 30 +++++++++---------- 7 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java index a2608e6f16c..b564ccbd155 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java @@ -108,11 +108,10 @@ private Map getAddressPlaceHolders(Address address) { List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - String[] lines = lines(address); + List lines = lines(address); - - for (int i = 0; i < lines.length; i++) { - addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); + for (int i = 0; i < lines.size(); i++) { + addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines.get(i)))); } return addressPlaceHolders; } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java index 39d0a7aaaaa..467ac98e738 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java @@ -116,10 +116,10 @@ private void buildRecipientAddressPlaceholders(Address address, Map addressConstants = List.of(RECIPIENT_ADDRESS_LINE_1_LITERAL, RECIPIENT_ADDRESS_LINE_2_LITERAL, RECIPIENT_ADDRESS_LINE_3_LITERAL, RECIPIENT_ADDRESS_LINE_4_LITERAL, RECIPIENT_ADDRESS_LINE_5_LITERAL); - String[] lines = lines(address); + List lines = lines(address); - for (int i = 0; i < lines.length; i++) { - placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); + for (int i = 0; i < lines.size(); i++) { + placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines.get(i)))); } } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java index c590179fcd6..ea4170d0da8 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java @@ -178,10 +178,10 @@ static Map getAddressPlaceHolders(Address address) { List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - String[] lines = lines(address); + List lines = lines(address); - for (int i = 0; i < lines.length; i++) { - addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); + for (int i = 0; i < lines.size(); i++) { + addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines.get(i)))); } return addressPlaceHolders; } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java index 090f419849a..3467071df74 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java @@ -323,15 +323,15 @@ static boolean isValidOtherPartyRepresentative(String subscriptionPartyId, Strin return false; } - public static String[] lines(Address address) { + public static List lines(Address address) { if (isYes(address.getInMainlandUk()) || address.getInMainlandUk() == null) { return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getCounty(), address.getPostcode()) .filter(x -> x != null) - .toArray(String[]::new); + .toList(); } else { return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getPostcode(), address.getCountry()) .filter(x -> x != null) - .toArray(String[]::new); + .toList(); } } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java index f290a0140cb..c20f72e5636 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java @@ -239,10 +239,10 @@ protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Noti List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - String[] lines = lines(address); + List lines = lines(address); - for (int i = 0; i < lines.length; i++) { - placeholders.put(addressConstants.get(i), defaultToEmptyStringIfNull(lines[i])); + for (int i = 0; i < lines.size(); i++) { + placeholders.put(addressConstants.get(i), defaultToEmptyStringIfNull(lines.get(i))); } placeholders.put(NAME, fullNameNoTitle); diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java index 21bad163a3a..162e0931f0c 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java @@ -135,10 +135,10 @@ public byte[] generateLetter(NotificationWrapper wrapper, Notification notificat private void buildRecipientAddressPlaceholders(Address address, Map placeholders) { List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - String[] lines = lines(address); + List lines = lines(address); - for (int i = 0; i < lines.length; i++) { - placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines[i]))); + for (int i = 0; i < lines.size(); i++) { + placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines.get(i)))); } } diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java index 57b09fc9fc3..2cebd430b55 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java @@ -685,11 +685,11 @@ public void lines_returns_expected_for_UK_address() { .postcode("WC2R 1LA") .build(); - String[] addressLines = lines(testAddress); + List addressLines = lines(testAddress); List expectedLines = List.of("Somerset House", "Strand", "London", "Greater London", "WC2R 1LA"); - for (int i = 0; i < addressLines.length; i++) { - assertEquals(expectedLines.get(i), addressLines[i]); + for (int i = 0; i < addressLines.size(); i++) { + assertEquals(expectedLines.get(i), addressLines.get(i)); } } @@ -705,11 +705,11 @@ public void lines_returns_expected_for_UK_address_with_inMainlandUK() { .inMainlandUk(YesNo.YES) .build(); - String[] addressLines = lines(testAddress); + List addressLines = lines(testAddress); List expectedLines = List.of("Somerset House", "Strand", "London", "Greater London", "WC2R 1LA"); - for (int i = 0; i < addressLines.length; i++) { - assertEquals(expectedLines.get(i), addressLines[i]); + for (int i = 0; i < addressLines.size(); i++) { + assertEquals(expectedLines.get(i), addressLines.get(i)); } } @@ -726,11 +726,11 @@ public void lines_returns_expected_for_International_address() { .inMainlandUk(YesNo.NO) .build(); - String[] addressLines = lines(testAddress); + List addressLines = lines(testAddress); List expectedLines = List.of("Catherdrale Notre-Dame de Paris", "6 Parvis Notre-dame - Pl. Jean-Paul II", "Paris", "75004", "France"); - for (int i = 0; i < addressLines.length; i++) { - assertEquals(expectedLines.get(i), addressLines[i]); + for (int i = 0; i < addressLines.size(); i++) { + assertEquals(expectedLines.get(i), addressLines.get(i)); } } @@ -746,11 +746,11 @@ public void lines_returns_expected_for_International_address_without_Postcode() .inMainlandUk(YesNo.NO) .build(); - String[] addressLines = lines(testAddress); + List addressLines = lines(testAddress); List expectedLines = List.of("Catherdrale Notre-Dame de Paris", "6 Parvis Notre-dame - Pl. Jean-Paul II", "Paris", "France"); - for (int i = 0; i < addressLines.length; i++) { - assertEquals(expectedLines.get(i), addressLines[i]); + for (int i = 0; i < addressLines.size(); i++) { + assertEquals(expectedLines.get(i), addressLines.get(i)); } } @@ -765,11 +765,11 @@ public void lines_removes_null_values() { .postcode("Test Postcode") .build(); - String[] addressLines = lines(testAddress); + List addressLines = lines(testAddress); List expectedLines = List.of("Test House", "Test Town", "Test County", "Test Postcode"); - for (int i = 0; i < addressLines.length; i++) { - assertEquals(expectedLines.get(i), addressLines[i]); + for (int i = 0; i < addressLines.size(); i++) { + assertEquals(expectedLines.get(i), addressLines.get(i)); } } } From c2e62a5718953781c6e032b404136d3b01006265 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Tue, 5 Nov 2024 15:27:44 +0000 Subject: [PATCH 12/18] Update to use correct mapping constants. Refactor to allow unit testing. --- .../GenericLetterPlaceholderService.java | 2 +- .../service/SendNotificationService.java | 36 ++++----- .../service/SendNotificationServiceTest.java | 79 ++++++++++++++++++- 3 files changed, 94 insertions(+), 23 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java index b564ccbd155..5627af9040d 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java @@ -37,12 +37,12 @@ public Map populatePlaceholders(SscsCaseData caseData, FurtherEv Address address = PlaceholderUtility.getAddress(caseData, letterType, otherPartyId); String name = PlaceholderUtility.getName(caseData, letterType, otherPartyId); - placeholders.putAll(getAddressPlaceHolders(address)); if (name != null) { placeholders.put(ADDRESS_NAME, truncateAddressLine(name)); placeholders.put(NAME, name); } + placeholders.putAll(getAddressPlaceHolders(address)); String appellantName = caseData.getAppeal().getAppellant().getName().getFullNameNoTitle(); placeholders.put(APPELLANT_NAME, appellantName); diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java index c20f72e5636..7a7877d17bd 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java @@ -3,11 +3,6 @@ import static java.util.Objects.nonNull; import static org.apache.commons.lang3.StringUtils.isNotBlank; import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.*; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_1; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_2; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_3; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_4; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_POSTCODE; import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.*; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.*; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.CORRECTION_GRANTED; @@ -23,10 +18,7 @@ import java.io.IOException; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; @@ -234,16 +226,8 @@ protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Noti if (address != null) { Map placeholders = notification.getPlaceholders(); String fullNameNoTitle = getNameToUseForLetter(wrapper, subscriptionWithType); - placeholders.put(ADDRESS_NAME, fullNameNoTitle); - List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, - LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - - List lines = lines(address); - - for (int i = 0; i < lines.size(); i++) { - placeholders.put(addressConstants.get(i), defaultToEmptyStringIfNull(lines.get(i))); - } + placeholders.putAll(getAddressPlaceholders(address, fullNameNoTitle)); placeholders.put(NAME, fullNameNoTitle); if (SubscriptionType.REPRESENTATIVE.equals(subscriptionWithType.getSubscriptionType())) { @@ -272,6 +256,22 @@ protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Noti } } + public static Map getAddressPlaceholders(final Address address, String fullNameNoTitle) { + Map addressPlaceHolders = new HashMap<>(); + + addressPlaceHolders.put(ADDRESS_LINE_1, fullNameNoTitle); + + List addressConstants = List.of(ADDRESS_LINE_2, ADDRESS_LINE_3, ADDRESS_LINE_4, + ADDRESS_LINE_5, POSTCODE_LITERAL); + + List lines = lines(address); + + for (int i = 0; i < lines.size(); i++) { + addressPlaceHolders.put(addressConstants.get(i), defaultToEmptyStringIfNull(lines.get(i))); + } + return addressPlaceHolders; + } + private static boolean isValidLetterAddress(Address addressToUse) { return null != addressToUse && isNotBlank(addressToUse.getLine1()) diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java index 93f1bb293ce..bbb855bbc85 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java @@ -8,12 +8,19 @@ import static uk.gov.hmcts.reform.sscs.ccd.domain.State.VALID_APPEAL; import static uk.gov.hmcts.reform.sscs.tyanotifications.config.AppConstants.REP_SALUTATION; import static uk.gov.hmcts.reform.sscs.tyanotifications.config.NotificationEventTypeLists.EVENT_TYPES_FOR_BUNDLED_LETTER; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_1; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_2; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_3; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_4; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_5; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.POSTCODE_LITERAL; import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.*; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.*; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressToUseForLetter; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationServiceTest.verifyExpectedLogMessage; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationServiceTest.verifyNoErrorsLogged; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.SendNotificationHelper.getRepSalutation; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.SendNotificationService.getAddressPlaceholders; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.SendNotificationService.getBundledLetterDocumentUrl; import ch.qos.logback.classic.Level; @@ -21,10 +28,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.Appender; import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; +import java.util.*; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Before; @@ -497,6 +501,73 @@ public void givenNonDigitalCase_willNotSendAppealLodgedLetters() { verifyNoInteractions(notificationHandler); } + @Test + public void getAddressPlaceholders_returnsExpectedValuesUKkAddress() { + String fullNameNoTitle = "Jane Doe"; + Address testAddress = Address.builder() + .line1("Somerset House") + .line2("Strand") + .town("London") + .county("Greater London") + .postcode("WC2R 1LA") + .inMainlandUk(YesNo.YES) + .build(); + + Map placeholders = getAddressPlaceholders(testAddress, fullNameNoTitle); + + assertEquals("Jane Doe", placeholders.get(ADDRESS_LINE_1)); + assertEquals("Somerset House", placeholders.get(ADDRESS_LINE_2)); + assertEquals("Strand", placeholders.get(ADDRESS_LINE_3)); + assertEquals("London", placeholders.get(ADDRESS_LINE_4)); + assertEquals("Greater London", placeholders.get(ADDRESS_LINE_5)); + assertEquals("WC2R 1LA", placeholders.get(POSTCODE_LITERAL)); + } + + public void getAddressPlaceholders_returnsExpectedValuesInternationalAddressNoPostcode() { + String fullNameNoTitle = "Jane Doe"; + Address testAddress = Address.builder() + .line1("Catherdrale Notre-Dame de Paris") + .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") + .town("Paris") + .county("Ile-de_France") + .country("France") + .inMainlandUk(YesNo.NO) + .build(); + + Map placeholders = getAddressPlaceholders(testAddress, fullNameNoTitle); + + assertEquals("Jane Doe", placeholders.get(ADDRESS_LINE_1)); + assertEquals("Catherdrale Notre-Dame de Paris", placeholders.get(ADDRESS_LINE_2)); + assertEquals("6 Parvis Notre-dame - Pl. Jean-Paul II", placeholders.get(ADDRESS_LINE_3)); + assertEquals("Paris", placeholders.get(ADDRESS_LINE_4)); + assertEquals("Ile-de_France", placeholders.get(ADDRESS_LINE_5)); + assertEquals("France", placeholders.get(POSTCODE_LITERAL)); + } + + @Test + public void getAddressPlaceholders_returnsExpectedKeys() { + String fullNameNoTitle = "Jane Doe"; + Address testAddress = Address.builder() + .line1("Catherdrale Notre-Dame de Paris") + .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") + .town("Paris") + .county("Ile-de_France") + .postcode("75004") + .country("France") + .inMainlandUk(YesNo.NO) + .build(); + + List addressConstants = List.of(ADDRESS_LINE_1, ADDRESS_LINE_2, ADDRESS_LINE_3, ADDRESS_LINE_4, + ADDRESS_LINE_5, POSTCODE_LITERAL); + + Map actualPlaceholders = getAddressPlaceholders(testAddress, fullNameNoTitle); + for (String addressConstant : addressConstants) { + assertTrue(actualPlaceholders.containsKey(addressConstant) && actualPlaceholders.get(addressConstant) != null); + } + } + + + private void verifyNotificationIsSaved(NotificationHandler.SendNotification sender, NotificationEventType eventType, String ccdCaseId, SubscriptionType subscriptionType) { try { sender.send(); From 4bfb67171103f2777713abddb394ccd68962ec70 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Tue, 5 Nov 2024 17:24:40 +0000 Subject: [PATCH 13/18] Update LETTER_ADDRESS_POSTCODE in PlaceholderConstants --- .../placeholders/GenericLetterPlaceholderService.java | 2 +- .../service/placeholders/PlaceholderConstants.java | 3 +-- .../config/PersonalisationMappingConstants.java | 3 ++- .../tyanotifications/service/SendNotificationService.java | 6 +++++- .../service/SendNotificationServiceTest.java | 6 +++++- .../service/docmosis/PdfLetterServiceTest.java | 3 +++ 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java index 5627af9040d..b564ccbd155 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java @@ -37,12 +37,12 @@ public Map populatePlaceholders(SscsCaseData caseData, FurtherEv Address address = PlaceholderUtility.getAddress(caseData, letterType, otherPartyId); String name = PlaceholderUtility.getName(caseData, letterType, otherPartyId); + placeholders.putAll(getAddressPlaceHolders(address)); if (name != null) { placeholders.put(ADDRESS_NAME, truncateAddressLine(name)); placeholders.put(NAME, name); } - placeholders.putAll(getAddressPlaceHolders(address)); String appellantName = caseData.getAppeal().getAppellant().getName().getFullNameNoTitle(); placeholders.put(APPELLANT_NAME, appellantName); diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderConstants.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderConstants.java index 65f08416f84..d26c5918919 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderConstants.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderConstants.java @@ -41,8 +41,7 @@ public final class PlaceholderConstants { public static final String LETTER_ADDRESS_LINE_2 = "letter_address_line_2"; public static final String LETTER_ADDRESS_LINE_3 = "letter_address_line_3"; public static final String LETTER_ADDRESS_LINE_4 = "letter_address_line_4"; - public static final String LETTER_ADDRESS_POSTCODE = "letter_address_postcode"; - + public static final String LETTER_ADDRESS_POSTCODE = "letter_address_line_5"; public static final String BENEFIT_NAME_ACRONYM_LITERAL = "benefit_name_acronym"; public static final String IS_REPRESENTATIVE = "representative"; public static final String IS_OTHER_PARTY = "is_other_party"; diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/PersonalisationMappingConstants.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/PersonalisationMappingConstants.java index f7d120eeb7b..64b1fc4af8d 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/PersonalisationMappingConstants.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/config/PersonalisationMappingConstants.java @@ -79,7 +79,8 @@ public final class PersonalisationMappingConstants { public static final String LETTER_ADDRESS_LINE_2 = "letter_address_line_2"; public static final String LETTER_ADDRESS_LINE_3 = "letter_address_line_3"; public static final String LETTER_ADDRESS_LINE_4 = "letter_address_line_4"; - public static final String LETTER_ADDRESS_POSTCODE = "letter_address_postcode"; + public static final String LETTER_ADDRESS_POSTCODE = "letter_address_line_5"; + public static final String NAME = "name"; public static final String MANAGE_EMAILS_LINK_LITERAL = "manage_emails_link"; public static final String MRN_DETAILS_LITERAL = "mrn_details"; diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java index 7a7877d17bd..ee63cf75d43 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java @@ -18,7 +18,11 @@ import java.io.IOException; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java index bbb855bbc85..9df769c8dcb 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java @@ -28,7 +28,11 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.Appender; import java.time.LocalDate; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Before; diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterServiceTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterServiceTest.java index 66467a92275..f57f965ced6 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterServiceTest.java @@ -269,6 +269,9 @@ public void givenAnAddressForARepWithNoName_thenAddressToOrganisationIfExists() ArgumentCaptor> placeholderCaptor = ArgumentCaptor.forClass(Map.class); verify(docmosisPdfService).createPdfFromMap(placeholderCaptor.capture(), eq(notification.getDocmosisLetterTemplate())); + + System.out.println("Hello " + placeholderCaptor.getAllValues()); + assertEquals("My Company", placeholderCaptor.getValue().get(ADDRESS_NAME)); assertEquals("FirstLine", placeholderCaptor.getValue().get(LETTER_ADDRESS_LINE_1)); assertEquals("SecondLine", placeholderCaptor.getValue().get(LETTER_ADDRESS_LINE_2)); From 357c0321588587a048eb65c5c85dfb9635036556 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Tue, 5 Nov 2024 17:30:02 +0000 Subject: [PATCH 14/18] remove System.out.println --- .../service/docmosis/PdfLetterServiceTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterServiceTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterServiceTest.java index f57f965ced6..4523d7a4dfb 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterServiceTest.java @@ -269,9 +269,7 @@ public void givenAnAddressForARepWithNoName_thenAddressToOrganisationIfExists() ArgumentCaptor> placeholderCaptor = ArgumentCaptor.forClass(Map.class); verify(docmosisPdfService).createPdfFromMap(placeholderCaptor.capture(), eq(notification.getDocmosisLetterTemplate())); - - System.out.println("Hello " + placeholderCaptor.getAllValues()); - + assertEquals("My Company", placeholderCaptor.getValue().get(ADDRESS_NAME)); assertEquals("FirstLine", placeholderCaptor.getValue().get(LETTER_ADDRESS_LINE_1)); assertEquals("SecondLine", placeholderCaptor.getValue().get(LETTER_ADDRESS_LINE_2)); From fef1245c43676c9b63294745ac5521aa779a7693 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Wed, 6 Nov 2024 10:36:32 +0000 Subject: [PATCH 15/18] Correct formatting of Ile-de-France. --- .../sscs/tyanotifications/service/LetterUtilsTest.java | 4 ++-- .../service/SendNotificationServiceTest.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java index 2cebd430b55..413c3737235 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java @@ -720,7 +720,7 @@ public void lines_returns_expected_for_International_address() { .line1("Catherdrale Notre-Dame de Paris") .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") .town("Paris") - .county("Ile-de_France") + .county("Ile-de-France") .postcode("75004") .country("France") .inMainlandUk(YesNo.NO) @@ -741,7 +741,7 @@ public void lines_returns_expected_for_International_address_without_Postcode() .line1("Catherdrale Notre-Dame de Paris") .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") .town("Paris") - .county("Ile-de_France") + .county("Ile-de-France") .country("France") .inMainlandUk(YesNo.NO) .build(); diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java index 9df769c8dcb..e8d8b1403de 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java @@ -533,7 +533,7 @@ public void getAddressPlaceholders_returnsExpectedValuesInternationalAddressNoPo .line1("Catherdrale Notre-Dame de Paris") .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") .town("Paris") - .county("Ile-de_France") + .county("Ile-de-France") .country("France") .inMainlandUk(YesNo.NO) .build(); @@ -544,7 +544,7 @@ public void getAddressPlaceholders_returnsExpectedValuesInternationalAddressNoPo assertEquals("Catherdrale Notre-Dame de Paris", placeholders.get(ADDRESS_LINE_2)); assertEquals("6 Parvis Notre-dame - Pl. Jean-Paul II", placeholders.get(ADDRESS_LINE_3)); assertEquals("Paris", placeholders.get(ADDRESS_LINE_4)); - assertEquals("Ile-de_France", placeholders.get(ADDRESS_LINE_5)); + assertEquals("Ile-de-France", placeholders.get(ADDRESS_LINE_5)); assertEquals("France", placeholders.get(POSTCODE_LITERAL)); } @@ -555,7 +555,7 @@ public void getAddressPlaceholders_returnsExpectedKeys() { .line1("Catherdrale Notre-Dame de Paris") .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") .town("Paris") - .county("Ile-de_France") + .county("Ile-de-France") .postcode("75004") .country("France") .inMainlandUk(YesNo.NO) From 3e10e2afb76d8746ed8f9c602eff9b378a940bdd Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Wed, 6 Nov 2024 11:56:14 +0000 Subject: [PATCH 16/18] Add 10 seconds to delay to allow respons from simulateCcdCallback --- .../sya/notifications/NotificationsFunctionalTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/sscs/functional/tyanotifications/sya/notifications/NotificationsFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/sscs/functional/tyanotifications/sya/notifications/NotificationsFunctionalTest.java index a839f31e528..55f5f7d15fc 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/sscs/functional/tyanotifications/sya/notifications/NotificationsFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/sscs/functional/tyanotifications/sya/notifications/NotificationsFunctionalTest.java @@ -459,7 +459,7 @@ public void shouldSendAppointeeHearingPostponedNotification() throws Notificatio public void shouldSaveReasonableAdjustmentNotificationForAppellant() throws IOException { simulateCcdCallback(APPEAL_RECEIVED, BASE_PATH_TYAN + APPEAL_RECEIVED.getId() + "AppellantReasonableAdjustmentCallback.json"); - delayInSeconds(10); + delayInSeconds(20); SscsCaseDetails caseDetails = findCaseById(caseId); SscsCaseData caseData = caseDetails.getData(); @@ -473,7 +473,7 @@ public void shouldSaveReasonableAdjustmentNotificationForAppellant() throws IOEx public void shouldSaveReasonableAdjustmentNotificationForAppellantAndRep() throws IOException { simulateCcdCallback(APPEAL_RECEIVED, BASE_PATH_TYAN + APPEAL_RECEIVED.getId() + "AppellantRepReasonableAdjustmentCallback.json"); - delayInSeconds(10); + delayInSeconds(20); SscsCaseDetails caseDetails = findCaseById(caseId); SscsCaseData caseData = caseDetails.getData(); From 82f19a544d2077d015f2f3e42ff1034556f5c10b Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Sat, 9 Nov 2024 19:10:25 +0000 Subject: [PATCH 17/18] Refactor letter services to use getAddressPlaceholders and remove wildcard imports. --- .gitignore | 2 + cftlib_log_file_IS_UNDEFINED | 0 .../GenericLetterPlaceholderService.java | 45 ++-- .../placeholders/PlaceholderService.java | 49 ++-- .../placeholders/PlaceholderUtility.java | 32 +-- .../placeholders/SorPlaceholderService.java | 25 +- .../tyanotifications/service/LetterUtils.java | 28 +- .../service/SendNotificationService.java | 85 +++--- .../service/docmosis/PdfLetterService.java | 24 +- .../service/LetterUtilsTest.java | 249 +++++++++++++++++- .../service/SendNotificationServiceTest.java | 84 +----- 11 files changed, 438 insertions(+), 185 deletions(-) delete mode 100644 cftlib_log_file_IS_UNDEFINED diff --git a/.gitignore b/.gitignore index cbf3aaab748..842bf205926 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ definitions/**/*.xlsx# # aat env file .aat-env + +cftlib_log_file_IS_UNDEFINED \ No newline at end of file diff --git a/cftlib_log_file_IS_UNDEFINED b/cftlib_log_file_IS_UNDEFINED deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java index b564ccbd155..87a2f6ecd97 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/GenericLetterPlaceholderService.java @@ -2,10 +2,31 @@ import static org.apache.commons.lang3.StringUtils.isBlank; import static uk.gov.hmcts.reform.sscs.ccd.domain.Benefit.getBenefitByCodeOrThrowException; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.ADDRESS_NAME; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.APPEAL_REF; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.APPELLANT_NAME; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.BENEFIT_NAME_ACRONYM_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.CASE_ID_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.GENERATED_DATE_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.HMCTS2; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.HMCTS_IMG; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.INFO_REQUEST_DETAIL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.IS_OTHER_PARTY; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.IS_REPRESENTATIVE; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.JOINT; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_1; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_2; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_3; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_4; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_POSTCODE; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.NAME; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.REGIONAL_OFFICE_PHONE_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.REPRESENTATIVE_NAME; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.SSCS_URL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.SSCS_URL_LITERAL; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.defaultToEmptyStringIfNull; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.truncateAddressLine; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressPlaceholders; import java.time.LocalDateTime; import java.util.HashMap; @@ -32,12 +53,13 @@ public GenericLetterPlaceholderService(PlaceholderService placeholderService) { } public Map populatePlaceholders(SscsCaseData caseData, FurtherEvidenceLetterType letterType, String otherPartyId) { - var placeholders = new HashMap(); - Address address = PlaceholderUtility.getAddress(caseData, letterType, otherPartyId); String name = PlaceholderUtility.getName(caseData, letterType, otherPartyId); - placeholders.putAll(getAddressPlaceHolders(address)); + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); + + Map placeholders = new HashMap<>(getAddressPlaceholders(address, addressConstants, true)); if (name != null) { placeholders.put(ADDRESS_NAME, truncateAddressLine(name)); @@ -102,17 +124,4 @@ private String getAppealReference(SscsCaseData caseData) { return isBlank(caseReference) || (caseData.getCreatedInGapsFrom() != null && caseData.getCreatedInGapsFrom().equals("readyToList")) ? caseData.getCcdCaseId() : caseReference; } - - private Map getAddressPlaceHolders(Address address) { - var addressPlaceHolders = new HashMap(); - List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, - LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - - List lines = lines(address); - - for (int i = 0; i < lines.size(); i++) { - addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines.get(i)))); - } - return addressPlaceHolders; - } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java index 467ac98e738..9fb70d078e1 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderService.java @@ -1,10 +1,36 @@ package uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders; import static java.util.Objects.nonNull; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.APPELLANT_FULL_NAME_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.BENEFIT_TYPE_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.CASE_CREATED_DATE_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.CASE_ID_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.EXELA_ADDRESS_LINE1_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.EXELA_ADDRESS_LINE2_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.EXELA_ADDRESS_LINE3_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.EXELA_ADDRESS_POSTCODE_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.GENERATED_DATE_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.NINO_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.RECIPIENT_ADDRESS_LINE_1_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.RECIPIENT_ADDRESS_LINE_2_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.RECIPIENT_ADDRESS_LINE_3_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.RECIPIENT_ADDRESS_LINE_4_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.RECIPIENT_ADDRESS_LINE_5_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.REGIONAL_OFFICE_ADDRESS_LINE1_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.REGIONAL_OFFICE_ADDRESS_LINE2_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.REGIONAL_OFFICE_ADDRESS_LINE3_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.REGIONAL_OFFICE_ADDRESS_LINE4_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.REGIONAL_OFFICE_COUNTY_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.REGIONAL_OFFICE_FAX_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.REGIONAL_OFFICE_PHONE_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.REGIONAL_OFFICE_POSTCODE_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.SC_NUMBER_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.SHOULD_HIDE_NINO; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.SSCS_URL_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.WELSH_CASE_CREATED_DATE_LITERAL; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.WELSH_GENERATED_DATE_LITERAL; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.defaultToEmptyStringIfNull; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.truncateAddressLine; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressPlaceholders; import java.time.LocalDateTime; import java.util.List; @@ -77,7 +103,11 @@ public void build(SscsCaseData caseData, Map placeholders, Addre buildExcelaAddress(caseData.getIsScottishCase(), placeholders); populateRpcPlaceHolders(caseData, placeholders); - buildRecipientAddressPlaceholders(address, placeholders); + + List addressConstants = List.of(RECIPIENT_ADDRESS_LINE_1_LITERAL, RECIPIENT_ADDRESS_LINE_2_LITERAL, RECIPIENT_ADDRESS_LINE_3_LITERAL, + RECIPIENT_ADDRESS_LINE_4_LITERAL, RECIPIENT_ADDRESS_LINE_5_LITERAL); + + placeholders.putAll(getAddressPlaceholders(address, addressConstants, true)); } public void buildExcelaAddress(String isScottish, Map placeholders) { @@ -111,15 +141,4 @@ public boolean hasRegionalProcessingCenter(SscsCaseData ccdResponse) { return nonNull(ccdResponse.getRegionalProcessingCenter()) && nonNull(ccdResponse.getRegionalProcessingCenter().getName()); } - - private void buildRecipientAddressPlaceholders(Address address, Map placeholders) { - List addressConstants = List.of(RECIPIENT_ADDRESS_LINE_1_LITERAL, RECIPIENT_ADDRESS_LINE_2_LITERAL, RECIPIENT_ADDRESS_LINE_3_LITERAL, - RECIPIENT_ADDRESS_LINE_4_LITERAL, RECIPIENT_ADDRESS_LINE_5_LITERAL); - - List lines = lines(address); - - for (int i = 0; i < lines.size(); i++) { - placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines.get(i)))); - } - } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java index ea4170d0da8..13f4b5d42ee 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/PlaceholderUtility.java @@ -3,16 +3,19 @@ import static java.util.Optional.ofNullable; import static org.apache.commons.lang3.StringUtils.isNoneBlank; import static uk.gov.hmcts.reform.sscs.ccd.domain.YesNo.isYes; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import java.util.Optional; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import uk.gov.hmcts.reform.sscs.ccd.domain.*; +import uk.gov.hmcts.reform.sscs.ccd.domain.Address; +import uk.gov.hmcts.reform.sscs.ccd.domain.Appeal; +import uk.gov.hmcts.reform.sscs.ccd.domain.Appellant; +import uk.gov.hmcts.reform.sscs.ccd.domain.Appointee; +import uk.gov.hmcts.reform.sscs.ccd.domain.CcdValue; +import uk.gov.hmcts.reform.sscs.ccd.domain.Name; +import uk.gov.hmcts.reform.sscs.ccd.domain.OtherParty; +import uk.gov.hmcts.reform.sscs.ccd.domain.Representative; +import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseData; import uk.gov.hmcts.reform.sscs.evidenceshare.domain.FurtherEvidenceLetterType; @Slf4j @@ -24,11 +27,11 @@ public final class PlaceholderUtility { private PlaceholderUtility() { } - static String defaultToEmptyStringIfNull(String value) { + public static String defaultToEmptyStringIfNull(String value) { return (value == null) ? StringUtils.EMPTY : value; } - static String truncateAddressLine(String addressLine) { + public static String truncateAddressLine(String addressLine) { return addressLine != null && addressLine.length() > 45 ? addressLine.substring(0, 45) : addressLine; } @@ -172,17 +175,4 @@ && isValidName(otherPartyValue.getRep().getName())) { private static boolean isValidName(Name name) { return isNoneBlank(name.getFirstName()) && isNoneBlank(name.getLastName()); } - - static Map getAddressPlaceHolders(Address address) { - var addressPlaceHolders = new HashMap(); - List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, - LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - - List lines = lines(address); - - for (int i = 0; i < lines.size(); i++) { - addressPlaceHolders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines.get(i)))); - } - return addressPlaceHolders; - } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/SorPlaceholderService.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/SorPlaceholderService.java index d1619eaedba..1af4c1e30fc 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/SorPlaceholderService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/service/placeholders/SorPlaceholderService.java @@ -2,9 +2,24 @@ import static java.util.Objects.isNull; import static java.util.Objects.requireNonNull; -import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.*; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.ADDRESS_NAME; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.APPEAL_REF; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.APPELLANT_NAME; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.ENTITY_TYPE; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.HEARING_DATE; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.HMCTS2; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.HMCTS_IMG; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_1; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_2; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_3; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_4; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_POSTCODE; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.NAME; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.PHONE_NUMBER; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressPlaceholders; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -32,13 +47,15 @@ public SorPlaceholderService(PlaceholderService placeholderService) { public Map populatePlaceholders(SscsCaseData caseData, FurtherEvidenceLetterType letterType, String entityType, String otherPartyId) { requireNonNull(caseData, "caseData must not be null"); - - Map placeholders = new HashMap<>(); Address address = PlaceholderUtility.getAddress(caseData, letterType, otherPartyId); + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); + + Map placeholders = new HashMap<>(getAddressPlaceholders(address, addressConstants, true)); + placeholderService.build(caseData, placeholders, address, null); String name = PlaceholderUtility.getName(caseData, letterType, otherPartyId); - placeholders.putAll(PlaceholderUtility.getAddressPlaceHolders(address)); if (name != null) { placeholders.put(NAME, name); diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java index 3467071df74..a84d2863d2e 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtils.java @@ -5,6 +5,8 @@ import static org.apache.commons.collections4.CollectionUtils.isNotEmpty; import static org.apache.commons.collections4.ListUtils.emptyIfNull; import static uk.gov.hmcts.reform.sscs.ccd.domain.YesNo.isYes; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.defaultToEmptyStringIfNull; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderUtility.truncateAddressLine; import static uk.gov.hmcts.reform.sscs.model.PartyItemList.*; import static uk.gov.hmcts.reform.sscs.tyanotifications.config.NotificationEventTypeLists.EVENTS_FOR_ACTION_FURTHER_EVIDENCE; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationUtils.hasAppointee; @@ -12,7 +14,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.stream.Stream; @@ -23,7 +27,14 @@ import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPageContentStream; import org.apache.pdfbox.pdmodel.common.PDRectangle; -import uk.gov.hmcts.reform.sscs.ccd.domain.*; +import uk.gov.hmcts.reform.sscs.ccd.domain.Address; +import uk.gov.hmcts.reform.sscs.ccd.domain.CcdValue; +import uk.gov.hmcts.reform.sscs.ccd.domain.Name; +import uk.gov.hmcts.reform.sscs.ccd.domain.OtherParty; +import uk.gov.hmcts.reform.sscs.ccd.domain.ReasonableAdjustments; +import uk.gov.hmcts.reform.sscs.ccd.domain.Representative; +import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseData; +import uk.gov.hmcts.reform.sscs.ccd.domain.YesNo; import uk.gov.hmcts.reform.sscs.model.PartyItemList; import uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType; import uk.gov.hmcts.reform.sscs.tyanotifications.domain.NotificationSscsCaseDataWrapper; @@ -326,12 +337,23 @@ static boolean isValidOtherPartyRepresentative(String subscriptionPartyId, Strin public static List lines(Address address) { if (isYes(address.getInMainlandUk()) || address.getInMainlandUk() == null) { return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getCounty(), address.getPostcode()) - .filter(x -> x != null) + .filter(Objects::nonNull) .toList(); } else { return Stream.of(address.getLine1(), address.getLine2(), address.getTown(), address.getPostcode(), address.getCountry()) - .filter(x -> x != null) + .filter(Objects::nonNull) .toList(); } } + + public static Map getAddressPlaceholders(Address address, List addressConstants, boolean truncate) { + HashMap addressPlaceHolders = new HashMap<>(); + + List lines = lines(address); + + for (int i = 0; i < lines.size(); i++) { + addressPlaceHolders.put(addressConstants.get(i), truncate ? truncateAddressLine(defaultToEmptyStringIfNull(lines.get(i))) : defaultToEmptyStringIfNull(lines.get(i))); + } + return addressPlaceHolders; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java index ee63cf75d43..9e49f5f2cfc 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationService.java @@ -2,36 +2,79 @@ import static java.util.Objects.nonNull; import static org.apache.commons.lang3.StringUtils.isNotBlank; -import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.*; -import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.*; -import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.*; +import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.ADJOURNMENT_NOTICE; +import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.AUDIO_VIDEO_EVIDENCE_DIRECTION_NOTICE; +import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.CORRECTED_DECISION_NOTICE; +import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.DECISION_NOTICE; +import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.DIRECTION_NOTICE; +import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.FINAL_DECISION_NOTICE; +import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.POSTPONEMENT_REQUEST_DIRECTION_NOTICE; +import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.STATEMENT_OF_REASONS_GRANTED; +import static uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType.STATEMENT_OF_REASONS_REFUSED; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_1; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_2; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_3; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_4; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_5; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.APPEAL_RESPOND_DATE; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.APPELLANT_NAME; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.CLAIMANT_NAME; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ENTITY_TYPE; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.NAME; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.PARTY_TYPE; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.POSTCODE_LITERAL; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.REPRESENTATIVE_NAME; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.ACTION_POSTPONEMENT_REQUEST; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.ACTION_POSTPONEMENT_REQUEST_WELSH; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.ADMIN_CORRECTION_HEADER; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.CORRECTION_GRANTED; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.DECISION_ISSUED; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.DECISION_ISSUED_WELSH; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.DIRECTION_ISSUED; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.DIRECTION_ISSUED_WELSH; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.ISSUE_ADJOURNMENT_NOTICE; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.ISSUE_ADJOURNMENT_NOTICE_WELSH; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.ISSUE_FINAL_DECISION; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.ISSUE_FINAL_DECISION_WELSH; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.PERMISSION_TO_APPEAL_GRANTED; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.PERMISSION_TO_APPEAL_REFUSED; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.PROCESS_AUDIO_VIDEO; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.PROCESS_AUDIO_VIDEO_WELSH; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.REVIEW_AND_SET_ASIDE; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.SET_ASIDE_GRANTED; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.SET_ASIDE_REFUSED; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.*; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationUtils.*; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.SOR_EXTEND_TIME; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.SOR_REFUSED; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.addBlankPageAtTheEndIfOddPage; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.buildBundledLetter; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressPlaceholders; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressToUseForLetter; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getNameToUseForLetter; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.isAlternativeLetterFormatRequired; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationUtils.hasLetterTemplate; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationUtils.isOkToSendEmailNotification; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationUtils.isOkToSendSmsNotification; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationValidService.isBundledLetter; import java.io.IOException; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.sscs.ccd.callback.DocumentType; -import uk.gov.hmcts.reform.sscs.ccd.domain.*; +import uk.gov.hmcts.reform.sscs.ccd.domain.AbstractDocument; +import uk.gov.hmcts.reform.sscs.ccd.domain.Address; +import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseData; +import uk.gov.hmcts.reform.sscs.ccd.domain.State; +import uk.gov.hmcts.reform.sscs.ccd.domain.Subscription; import uk.gov.hmcts.reform.sscs.service.PdfStoreService; import uk.gov.hmcts.reform.sscs.tyanotifications.config.AppConstants; import uk.gov.hmcts.reform.sscs.tyanotifications.config.NotificationEventTypeLists; @@ -231,7 +274,10 @@ protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Noti Map placeholders = notification.getPlaceholders(); String fullNameNoTitle = getNameToUseForLetter(wrapper, subscriptionWithType); - placeholders.putAll(getAddressPlaceholders(address, fullNameNoTitle)); + placeholders.put(ADDRESS_LINE_1, fullNameNoTitle); + List addressConstants = List.of(ADDRESS_LINE_2, ADDRESS_LINE_3, ADDRESS_LINE_4, ADDRESS_LINE_5, POSTCODE_LITERAL); + + placeholders.putAll(getAddressPlaceholders(address, addressConstants, false)); placeholders.put(NAME, fullNameNoTitle); if (SubscriptionType.REPRESENTATIVE.equals(subscriptionWithType.getSubscriptionType())) { @@ -259,22 +305,6 @@ protected void sendLetterNotificationToAddress(NotificationWrapper wrapper, Noti ); } } - - public static Map getAddressPlaceholders(final Address address, String fullNameNoTitle) { - Map addressPlaceHolders = new HashMap<>(); - - addressPlaceHolders.put(ADDRESS_LINE_1, fullNameNoTitle); - - List addressConstants = List.of(ADDRESS_LINE_2, ADDRESS_LINE_3, ADDRESS_LINE_4, - ADDRESS_LINE_5, POSTCODE_LITERAL); - - List lines = lines(address); - - for (int i = 0; i < lines.size(); i++) { - addressPlaceHolders.put(addressConstants.get(i), defaultToEmptyStringIfNull(lines.get(i))); - } - return addressPlaceHolders; - } private static boolean isValidLetterAddress(Address addressToUse) { return null != addressToUse @@ -415,9 +445,4 @@ private static String getDocumentForType(AbstractDocument sscsDocument) { } return null; } - - private static String defaultToEmptyStringIfNull(String value) { - return (value == null) ? StringUtils.EMPTY : value; - } - } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java index 162e0931f0c..39609b1d3e1 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/docmosis/PdfLetterService.java @@ -5,10 +5,14 @@ import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_3; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_4; import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_POSTCODE; -import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.*; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_NAME; import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.APPEAL_RECEIVED; import static uk.gov.hmcts.reform.sscs.tyanotifications.personalisation.Personalisation.translateToWelshDate; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.*; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.addBlankPageAtTheEndIfOddPage; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.buildBundledLetter; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressPlaceholders; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressToUseForLetter; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getNameToUseForLetter; import java.io.IOException; import java.time.LocalDate; @@ -117,7 +121,11 @@ public byte[] generateLetter(NotificationWrapper wrapper, Notification notificat placeholders.put(ADDRESS_NAME, truncateAddressLine(getNameToUseForLetter(wrapper, subscriptionWithType))); Address addressToUse = getAddressToUseForLetter(wrapper, subscriptionWithType); - buildRecipientAddressPlaceholders(addressToUse, placeholders); + + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); + + placeholders.putAll(getAddressPlaceholders(addressToUse, addressConstants, true)); placeholders.put(docmosisTemplatesConfig.getHmctsImgKey(), docmosisTemplatesConfig.getHmctsImgVal()); placeholders.put(docmosisTemplatesConfig.getHmctsWelshImgKey(), docmosisTemplatesConfig.getHmctsWelshImgVal()); @@ -132,16 +140,6 @@ public byte[] generateLetter(NotificationWrapper wrapper, Notification notificat return new byte[0]; } - private void buildRecipientAddressPlaceholders(Address address, Map placeholders) { - List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, - LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); - List lines = lines(address); - - for (int i = 0; i < lines.size(); i++) { - placeholders.put(addressConstants.get(i), truncateAddressLine(defaultToEmptyStringIfNull(lines.get(i)))); - } - } - private static String defaultToEmptyStringIfNull(String value) { return (value == null) ? StringUtils.EMPTY : value; } diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java index 413c3737235..2a85f01a262 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java @@ -3,13 +3,38 @@ import static java.util.Objects.requireNonNull; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_1; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_2; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_3; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_LINE_4; +import static uk.gov.hmcts.reform.sscs.evidenceshare.service.placeholders.PlaceholderConstants.LETTER_ADDRESS_POSTCODE; import static uk.gov.hmcts.reform.sscs.model.PartyItemList.DWP; import static uk.gov.hmcts.reform.sscs.model.PartyItemList.HMCTS; import static uk.gov.hmcts.reform.sscs.tyanotifications.config.AppConstants.REP_SALUTATION; -import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.*; -import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.*; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.*; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_1; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_2; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_3; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_4; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_5; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.POSTCODE_LITERAL; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.APPELLANT; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.APPOINTEE; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.JOINT_PARTY; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.OTHER_PARTY; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.REPRESENTATIVE; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.APPEAL_RECEIVED; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.LIBERTY_TO_APPLY_REQUEST; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.SYA_APPEAL_CREATED; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.addBlankPageAtTheEndIfOddPage; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.buildBundledLetter; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressPlaceholders; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressToUseForLetter; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getNameToUseForLetter; +import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.lines; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationServiceTest.APPELLANT_WITH_ADDRESS; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.SendNotificationServiceTest.APPELLANT_WITH_ADDRESS_AND_APPOINTEE; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.SendNotificationServiceTest.REP_WITH_ADDRESS; @@ -18,6 +43,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.stream.Stream; @@ -32,7 +58,23 @@ import org.junit.Test; import org.junit.jupiter.api.DisplayName; import org.junit.runner.RunWith; -import uk.gov.hmcts.reform.sscs.ccd.domain.*; +import uk.gov.hmcts.reform.sscs.ccd.domain.Address; +import uk.gov.hmcts.reform.sscs.ccd.domain.Appeal; +import uk.gov.hmcts.reform.sscs.ccd.domain.Appellant; +import uk.gov.hmcts.reform.sscs.ccd.domain.Appointee; +import uk.gov.hmcts.reform.sscs.ccd.domain.CcdValue; +import uk.gov.hmcts.reform.sscs.ccd.domain.DynamicList; +import uk.gov.hmcts.reform.sscs.ccd.domain.DynamicListItem; +import uk.gov.hmcts.reform.sscs.ccd.domain.Entity; +import uk.gov.hmcts.reform.sscs.ccd.domain.JointParty; +import uk.gov.hmcts.reform.sscs.ccd.domain.Name; +import uk.gov.hmcts.reform.sscs.ccd.domain.OtherParty; +import uk.gov.hmcts.reform.sscs.ccd.domain.Party; +import uk.gov.hmcts.reform.sscs.ccd.domain.ReasonableAdjustmentDetails; +import uk.gov.hmcts.reform.sscs.ccd.domain.Representative; +import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseData; +import uk.gov.hmcts.reform.sscs.ccd.domain.Subscription; +import uk.gov.hmcts.reform.sscs.ccd.domain.YesNo; import uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType; import uk.gov.hmcts.reform.sscs.tyanotifications.domain.NotificationSscsCaseDataWrapper; import uk.gov.hmcts.reform.sscs.tyanotifications.domain.SubscriptionWithType; @@ -693,6 +735,23 @@ public void lines_returns_expected_for_UK_address() { } } + @DisplayName("lines returns expected values when given a shorter UK address object.") + @Test + public void lines_returns_expected_for_short_UK_address() { + Address testAddress = Address.builder() + .line1("Elba") + .town("Duns") + .postcode("TD11 3RY") + .build(); + + List addressLines = lines(testAddress); + List expectedLines = List.of("Elba", "Duns", "TD11 3RY"); + + for (int i = 0; i < addressLines.size(); i++) { + assertEquals(expectedLines.get(i), addressLines.get(i)); + } + } + @DisplayName("lines returns expected values when given a valid UK address object with inMainlandUK YES.") @Test public void lines_returns_expected_for_UK_address_with_inMainlandUK() { @@ -772,4 +831,184 @@ public void lines_removes_null_values() { assertEquals(expectedLines.get(i), addressLines.get(i)); } } + + @DisplayName("getAddressPlaceholders returns expected values for a UK address.") + @Test + public void getAddressPlaceholders_returnsExpectedValuesUkAddress() { + Address testAddress = Address.builder() + .line1("Somerset House") + .line2("Strand") + .town("London") + .county("Greater London") + .postcode("WC2R 1LA") + .inMainlandUk(YesNo.YES) + .build(); + + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); + Map placeholders = getAddressPlaceholders(testAddress, addressConstants, true); + + assertEquals("Somerset House", placeholders.get(LETTER_ADDRESS_LINE_1)); + assertEquals("Strand", placeholders.get(LETTER_ADDRESS_LINE_2)); + assertEquals("London", placeholders.get(LETTER_ADDRESS_LINE_3)); + assertEquals("Greater London", placeholders.get(LETTER_ADDRESS_LINE_4)); + assertEquals("WC2R 1LA", placeholders.get(LETTER_ADDRESS_POSTCODE)); + } + + @DisplayName("getAddressPlaceholders returns expected values for a UK address.") + @Test + public void getAddressPlaceholders_returnsExpectedValuesShortUkAddress() { + Address testAddress = Address.builder() + .line1("Elba") + .town("Duns") + .postcode("TD11 3RY") + .build(); + + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); + Map placeholders = getAddressPlaceholders(testAddress, addressConstants, true); + + assertEquals("Elba", placeholders.get(LETTER_ADDRESS_LINE_1)); + assertEquals("Duns", placeholders.get(LETTER_ADDRESS_LINE_2)); + assertEquals("TD11 3RY", placeholders.get(LETTER_ADDRESS_LINE_3)); + } + + @DisplayName("getAddressPlaceholders returns expected values when using sendLetterNotificationToAddress address placeholders.") + @Test + public void getAddressPlaceholders_returnsExpectedValuesWhenUsingSendLetterNotificationToAddressPlaceholders() { + String fullNameNoTitle = "Jane Doe"; + Address testAddress = Address.builder() + .line1("Somerset House") + .line2("Strand") + .town("London") + .county("Greater London") + .postcode("WC2R 1LA") + .inMainlandUk(YesNo.YES) + .build(); + + List addressConstants = List.of(ADDRESS_LINE_2, ADDRESS_LINE_3, ADDRESS_LINE_4, ADDRESS_LINE_5, POSTCODE_LITERAL); + + Map placeholders = getAddressPlaceholders(testAddress, addressConstants, true); + placeholders.put(ADDRESS_LINE_1, fullNameNoTitle); + + assertEquals("Jane Doe", placeholders.get(ADDRESS_LINE_1)); + assertEquals("Somerset House", placeholders.get(ADDRESS_LINE_2)); + assertEquals("Strand", placeholders.get(ADDRESS_LINE_3)); + assertEquals("London", placeholders.get(ADDRESS_LINE_4)); + assertEquals("Greater London", placeholders.get(ADDRESS_LINE_5)); + assertEquals("WC2R 1LA", placeholders.get(POSTCODE_LITERAL)); + } + + @Test + public void getAddressPlaceholders_returnsExpectedValuesInternationalAddress() { + Address testAddress = Address.builder() + .line1("Catherdrale Notre-Dame de Paris") + .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") + .town("Paris") + .county("Ile-de-France") + .country("France") + .inMainlandUk(YesNo.NO) + .build(); + + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); + Map placeholders = getAddressPlaceholders(testAddress, addressConstants, true); + + assertEquals("Catherdrale Notre-Dame de Paris", placeholders.get(LETTER_ADDRESS_LINE_1)); + assertEquals("6 Parvis Notre-dame - Pl. Jean-Paul II", placeholders.get(LETTER_ADDRESS_LINE_2)); + assertEquals("Paris", placeholders.get(LETTER_ADDRESS_LINE_3)); + assertEquals("France", placeholders.get(LETTER_ADDRESS_LINE_4)); + } + + @Test + public void getAddressPlaceholders_returnsExpectedValuesInternationalAddressNoPostcode() { + Address testAddress = Address.builder() + .line1("Catherdrale Notre-Dame de Paris") + .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") + .town("Paris") + .county("Ile-de-France") + .postcode("75004") + .country("France") + .inMainlandUk(YesNo.NO) + .build(); + + List addressConstants = List.of(LETTER_ADDRESS_LINE_1, LETTER_ADDRESS_LINE_2, LETTER_ADDRESS_LINE_3, + LETTER_ADDRESS_LINE_4, LETTER_ADDRESS_POSTCODE); + Map placeholders = getAddressPlaceholders(testAddress, addressConstants, true); + + assertEquals("Catherdrale Notre-Dame de Paris", placeholders.get(LETTER_ADDRESS_LINE_1)); + assertEquals("6 Parvis Notre-dame - Pl. Jean-Paul II", placeholders.get(LETTER_ADDRESS_LINE_2)); + assertEquals("Paris", placeholders.get(LETTER_ADDRESS_LINE_3)); + assertEquals("75004", placeholders.get(LETTER_ADDRESS_LINE_4)); + assertEquals("France", placeholders.get(LETTER_ADDRESS_POSTCODE)); + + } + + @Test + public void getAddressPlaceholders_returnsExpectedKeys() { + String fullNameNoTitle = "Jane Doe"; + Address testAddress = Address.builder() + .line1("Catherdrale Notre-Dame de Paris") + .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") + .town("Paris") + .county("Ile-de-France") + .postcode("75004") + .country("France") + .inMainlandUk(YesNo.NO) + .build(); + + List addressConstants = List.of(ADDRESS_LINE_2, ADDRESS_LINE_3, ADDRESS_LINE_4, + ADDRESS_LINE_5, POSTCODE_LITERAL); + Map actualPlaceholders = getAddressPlaceholders(testAddress, addressConstants, true); + + actualPlaceholders.put(ADDRESS_LINE_1, fullNameNoTitle); + + for (String addressConstant : addressConstants) { + assertTrue(actualPlaceholders.containsKey(addressConstant) && actualPlaceholders.get(addressConstant) != null); + } + } + + @DisplayName("getAddressPlaceholders truncates address lines over 45 characters when truncate is true.") + @Test + public void getAddressPlaceholders_truncatesLongAddressLinesWhenTruncateTrue() { + Address testAddress = Address.builder() + .line1("This is a very long test address, it should be truncated to a shorter string when getAddressPlaceholders truncate argument is true") + .line2("Test Street") + .town("Test Town") + .county("Test County") + .postcode("TT1 1TT") + .build(); + + List addressConstants = List.of(ADDRESS_LINE_2, ADDRESS_LINE_3, ADDRESS_LINE_4, + ADDRESS_LINE_5, POSTCODE_LITERAL); + + Map placeholders = getAddressPlaceholders(testAddress, addressConstants, true); + assertEquals("This is a very long test address, it should b", placeholders.get(ADDRESS_LINE_2)); + assertEquals("Test Street", placeholders.get(ADDRESS_LINE_3)); + assertEquals("Test Town", placeholders.get(ADDRESS_LINE_4)); + assertEquals("Test County", placeholders.get(ADDRESS_LINE_5)); + assertEquals("TT1 1TT", placeholders.get(POSTCODE_LITERAL)); + } + + @DisplayName("getAddressPlaceholders keeps address lines long when truncate is false.") + @Test + public void getAddressPlaceholders_keepsLongAddressLinesWhenTruncateFalse() { + Address testAddress = Address.builder() + .line1("This is a very long test address, it should be long string when getAddressPlaceholders truncate argument is false") + .line2("Test Street") + .town("Test Town") + .county("Test County") + .postcode("TT1 1TT") + .build(); + + List addressConstants = List.of(ADDRESS_LINE_2, ADDRESS_LINE_3, ADDRESS_LINE_4, + ADDRESS_LINE_5, POSTCODE_LITERAL); + + Map placeholders = getAddressPlaceholders(testAddress, addressConstants, false); + assertEquals("This is a very long test address, it should be long string when getAddressPlaceholders truncate argument is false", placeholders.get(ADDRESS_LINE_2)); + assertEquals("Test Street", placeholders.get(ADDRESS_LINE_3)); + assertEquals("Test Town", placeholders.get(ADDRESS_LINE_4)); + assertEquals("Test County", placeholders.get(ADDRESS_LINE_5)); + assertEquals("TT1 1TT", placeholders.get(POSTCODE_LITERAL)); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java index e8d8b1403de..f71c35c17b3 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/SendNotificationServiceTest.java @@ -8,19 +8,18 @@ import static uk.gov.hmcts.reform.sscs.ccd.domain.State.VALID_APPEAL; import static uk.gov.hmcts.reform.sscs.tyanotifications.config.AppConstants.REP_SALUTATION; import static uk.gov.hmcts.reform.sscs.tyanotifications.config.NotificationEventTypeLists.EVENT_TYPES_FOR_BUNDLED_LETTER; -import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_1; -import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_2; -import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_3; -import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_4; -import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.ADDRESS_LINE_5; -import static uk.gov.hmcts.reform.sscs.tyanotifications.config.PersonalisationMappingConstants.POSTCODE_LITERAL; -import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.*; -import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.*; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.APPELLANT; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.APPOINTEE; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.JOINT_PARTY; +import static uk.gov.hmcts.reform.sscs.tyanotifications.config.SubscriptionType.REPRESENTATIVE; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.APPEAL_RECEIVED; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.CASE_UPDATED; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.ISSUE_FINAL_DECISION; +import static uk.gov.hmcts.reform.sscs.tyanotifications.domain.notify.NotificationEventType.STRUCK_OUT; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.LetterUtils.getAddressToUseForLetter; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationServiceTest.verifyExpectedLogMessage; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.NotificationServiceTest.verifyNoErrorsLogged; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.SendNotificationHelper.getRepSalutation; -import static uk.gov.hmcts.reform.sscs.tyanotifications.service.SendNotificationService.getAddressPlaceholders; import static uk.gov.hmcts.reform.sscs.tyanotifications.service.SendNotificationService.getBundledLetterDocumentUrl; import ch.qos.logback.classic.Level; @@ -32,7 +31,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; -import java.util.Map; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Before; @@ -505,72 +503,6 @@ public void givenNonDigitalCase_willNotSendAppealLodgedLetters() { verifyNoInteractions(notificationHandler); } - @Test - public void getAddressPlaceholders_returnsExpectedValuesUKkAddress() { - String fullNameNoTitle = "Jane Doe"; - Address testAddress = Address.builder() - .line1("Somerset House") - .line2("Strand") - .town("London") - .county("Greater London") - .postcode("WC2R 1LA") - .inMainlandUk(YesNo.YES) - .build(); - - Map placeholders = getAddressPlaceholders(testAddress, fullNameNoTitle); - - assertEquals("Jane Doe", placeholders.get(ADDRESS_LINE_1)); - assertEquals("Somerset House", placeholders.get(ADDRESS_LINE_2)); - assertEquals("Strand", placeholders.get(ADDRESS_LINE_3)); - assertEquals("London", placeholders.get(ADDRESS_LINE_4)); - assertEquals("Greater London", placeholders.get(ADDRESS_LINE_5)); - assertEquals("WC2R 1LA", placeholders.get(POSTCODE_LITERAL)); - } - - public void getAddressPlaceholders_returnsExpectedValuesInternationalAddressNoPostcode() { - String fullNameNoTitle = "Jane Doe"; - Address testAddress = Address.builder() - .line1("Catherdrale Notre-Dame de Paris") - .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") - .town("Paris") - .county("Ile-de-France") - .country("France") - .inMainlandUk(YesNo.NO) - .build(); - - Map placeholders = getAddressPlaceholders(testAddress, fullNameNoTitle); - - assertEquals("Jane Doe", placeholders.get(ADDRESS_LINE_1)); - assertEquals("Catherdrale Notre-Dame de Paris", placeholders.get(ADDRESS_LINE_2)); - assertEquals("6 Parvis Notre-dame - Pl. Jean-Paul II", placeholders.get(ADDRESS_LINE_3)); - assertEquals("Paris", placeholders.get(ADDRESS_LINE_4)); - assertEquals("Ile-de-France", placeholders.get(ADDRESS_LINE_5)); - assertEquals("France", placeholders.get(POSTCODE_LITERAL)); - } - - @Test - public void getAddressPlaceholders_returnsExpectedKeys() { - String fullNameNoTitle = "Jane Doe"; - Address testAddress = Address.builder() - .line1("Catherdrale Notre-Dame de Paris") - .line2("6 Parvis Notre-dame - Pl. Jean-Paul II") - .town("Paris") - .county("Ile-de-France") - .postcode("75004") - .country("France") - .inMainlandUk(YesNo.NO) - .build(); - - List addressConstants = List.of(ADDRESS_LINE_1, ADDRESS_LINE_2, ADDRESS_LINE_3, ADDRESS_LINE_4, - ADDRESS_LINE_5, POSTCODE_LITERAL); - - Map actualPlaceholders = getAddressPlaceholders(testAddress, fullNameNoTitle); - for (String addressConstant : addressConstants) { - assertTrue(actualPlaceholders.containsKey(addressConstant) && actualPlaceholders.get(addressConstant) != null); - } - } - - private void verifyNotificationIsSaved(NotificationHandler.SendNotification sender, NotificationEventType eventType, String ccdCaseId, SubscriptionType subscriptionType) { try { From 2c3fb4be03943fa93acce80a503853a5b5093792 Mon Sep 17 00:00:00 2001 From: Joshua Gray Date: Sat, 9 Nov 2024 19:12:15 +0000 Subject: [PATCH 18/18] Refactor letter services to use getAddressPlaceholders and remove wildcard imports. --- .../reform/sscs/tyanotifications/service/LetterUtilsTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java index 2a85f01a262..a8b35c14f59 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/tyanotifications/service/LetterUtilsTest.java @@ -944,6 +944,7 @@ public void getAddressPlaceholders_returnsExpectedValuesInternationalAddressNoPo } + @DisplayName("getAddressPlaceholders returns the expected keys.") @Test public void getAddressPlaceholders_returnsExpectedKeys() { String fullNameNoTitle = "Jane Doe";