diff --git a/src/integrationTest/resources/mappings/exception/auto-case-incomplete-response.json b/src/integrationTest/resources/mappings/exception/auto-case-incomplete-response.json index 8b22d59ca..bdaf16222 100644 --- a/src/integrationTest/resources/mappings/exception/auto-case-incomplete-response.json +++ b/src/integrationTest/resources/mappings/exception/auto-case-incomplete-response.json @@ -47,7 +47,7 @@ "hasRepresentative": "No", "organisation": null, "name": null, - "address": null, + "address": {}, "contact": null }, "signer": null, diff --git a/src/integrationTest/resources/mappings/exception/auto-valid-appeal-response-attendance-allowance.json b/src/integrationTest/resources/mappings/exception/auto-valid-appeal-response-attendance-allowance.json index 871e09ed6..7912195c6 100644 --- a/src/integrationTest/resources/mappings/exception/auto-valid-appeal-response-attendance-allowance.json +++ b/src/integrationTest/resources/mappings/exception/auto-valid-appeal-response-attendance-allowance.json @@ -138,7 +138,7 @@ "phoneNumber": "0300 123 1142", "faxNumber": "0126 434 7983", "email": "SSCS_Bradford@justice.gov.uk", - "hearingRoute": "gaps", + "hearingRoute": "gaps", "epimsId": "698118" }, "processingVenue": "Basildon CC", @@ -158,7 +158,7 @@ }, "warnings": [], "supplementary_data": { - "$set" : { + "$set": { "HMCTSServiceId": "BBA3" } } diff --git a/src/integrationTest/resources/mappings/exception/auto-valid-appeal-response.json b/src/integrationTest/resources/mappings/exception/auto-valid-appeal-response.json index 1dabaa7c4..ce2a9775c 100644 --- a/src/integrationTest/resources/mappings/exception/auto-valid-appeal-response.json +++ b/src/integrationTest/resources/mappings/exception/auto-valid-appeal-response.json @@ -138,7 +138,7 @@ "phoneNumber": "0300 123 1142", "faxNumber": "0126 434 7983", "email": "SSCS_Bradford@justice.gov.uk", - "hearingRoute": "gaps", + "hearingRoute": "gaps", "epimsId": "698118" }, "processingVenue": "Basildon CC", @@ -158,7 +158,7 @@ }, "warnings": [], "supplementary_data": { - "$set" : { + "$set": { "HMCTSServiceId": "BBA3" } } diff --git a/src/integrationTest/resources/mappings/exception/auto-valid-appeal-with-appointee-response.json b/src/integrationTest/resources/mappings/exception/auto-valid-appeal-with-appointee-response.json index 84654a63a..4646957b7 100644 --- a/src/integrationTest/resources/mappings/exception/auto-valid-appeal-with-appointee-response.json +++ b/src/integrationTest/resources/mappings/exception/auto-valid-appeal-with-appointee-response.json @@ -158,7 +158,6 @@ } } ], - "linkedCasesBoolean": "No", "caseCreated": "2018-01-11", "region": "BRADFORD", @@ -173,7 +172,7 @@ "postcode": "BD3 7BH", "city": "BRADFORD", "email": "SSCS_Bradford@justice.gov.uk", - "hearingRoute": "gaps", + "hearingRoute": "gaps", "epimsId": "698118" }, "caseManagementLocation": { @@ -187,7 +186,7 @@ }, "warnings": [], "supplementary_data": { - "$set" : { + "$set": { "HMCTSServiceId": "BBA3" } } diff --git a/src/integrationTest/resources/mappings/exception/case-creation-request.json b/src/integrationTest/resources/mappings/exception/case-creation-request.json index 2a6efeabe..d8a9d2d9b 100644 --- a/src/integrationTest/resources/mappings/exception/case-creation-request.json +++ b/src/integrationTest/resources/mappings/exception/case-creation-request.json @@ -34,26 +34,28 @@ "dob": "1976-11-11", "nino": "BB000000B" }, - "isAppointee" : "No", + "isAppointee": "No", "appointee": null, - "isAddressSameAsAppointee" : null + "isAddressSameAsAppointee": null }, "benefitType": { "code": "ESA", "description": "Employment and Support Allowance" }, "hearingOptions": { - "wantsToAttend" : "Yes", - "wantsSupport" : "No", + "wantsToAttend": "Yes", + "wantsSupport": "No", "languageInterpreter": "No", - "arrangements" : [], - "scheduleHearing" : "Yes", - "excludeDates" : [{ - "value" : { - "start" : "2030-12-01", - "end" : null + "arrangements": [], + "scheduleHearing": "Yes", + "excludeDates": [ + { + "value": { + "start": "2030-12-01", + "end": null } - }] + } + ] }, "hearingSubtype": { "wantsHearingTypeTelephone": "Yes", @@ -72,20 +74,22 @@ }, "signer": null, "hearingType": "oral", - "receivedVia" : "Paper" + "receivedVia": "Paper" }, - "sscsDocument" : [ { - "value" : { - "documentType" : "appellantEvidence", - "documentFileName" : "11111.pdf", - "documentDateAdded" : "2018-10-10", - "documentLink" : { - "document_url" : "http://www.bbc.com", - "document_binary_url" : "http://www.bbc.com/binary", - "document_filename" : "myfile.jpg" + "sscsDocument": [ + { + "value": { + "documentType": "appellantEvidence", + "documentFileName": "11111.pdf", + "documentDateAdded": "2018-10-10", + "documentLink": { + "document_url": "http://www.bbc.com", + "document_binary_url": "http://www.bbc.com/binary", + "document_filename": "myfile.jpg" + } } } - } ], + ], "subscriptions": { "appellantSubscription": { "wantSmsNotifications": "No", @@ -95,27 +99,27 @@ "subscribeSms": "No", "reason": null }, - "supporterSubscription" : null, - "representativeSubscription" : null, - "appointeeSubscription" : null + "supporterSubscription": null, + "representativeSubscription": null, + "appointeeSubscription": null }, - "region" : "BIRMINGHAM", - "regionalProcessingCenter" : { - "faxNumber" : "0126 434 7983", - "address4" : "PO Box 14620", - "phoneNumber" : "0300 123 1142", - "name" : "BIRMINGHAM", - "address1" : "HM Courts & Tribunals Service", - "address2" : "Social Security & Child Support Appeals", - "address3" : "Administrative Support Centre", - "postcode" : "B16 6FR", - "city" : "BIRMINGHAM" + "region": "BIRMINGHAM", + "regionalProcessingCenter": { + "faxNumber": "0126 434 7983", + "address4": "PO Box 14620", + "phoneNumber": "0300 123 1142", + "name": "BIRMINGHAM", + "address1": "HM Courts & Tribunals Service", + "address2": "Social Security & Child Support Appeals", + "address3": "Administrative Support Centre", + "postcode": "B16 6FR", + "city": "BIRMINGHAM" }, - "evidencePresent" : "Yes", - "bulkScanCaseReference" : "1234567890", - "caseCreated" : "2018-11-21" + "evidencePresent": "Yes", + "bulkScanCaseReference": "1234567890", + "caseCreated": "2018-11-21" }, - "security_classification" : "PUBLIC", - "event_token" : "test_event_token", - "ignore_warning" : false + "security_classification": "PUBLIC", + "event_token": "test_event_token", + "ignore_warning": false } diff --git a/src/integrationTest/resources/mappings/exception/case-non-compliant-creation-request-old.json b/src/integrationTest/resources/mappings/exception/case-non-compliant-creation-request-old.json index 5a63f866f..07b5b3a33 100644 --- a/src/integrationTest/resources/mappings/exception/case-non-compliant-creation-request-old.json +++ b/src/integrationTest/resources/mappings/exception/case-non-compliant-creation-request-old.json @@ -34,9 +34,9 @@ "dob": "1976-11-11", "nino": "BB000000B" }, - "isAppointee" : "No", + "isAppointee": "No", "appointee": null, - "isAddressSameAsAppointee" : null + "isAddressSameAsAppointee": null }, "benefitType": { "code": "ESA", @@ -44,17 +44,19 @@ }, "hearingSubtype": {}, "hearingOptions": { - "wantsToAttend" : "Yes", - "wantsSupport" : "No", + "wantsToAttend": "Yes", + "wantsSupport": "No", "languageInterpreter": "No", - "arrangements" : [], - "scheduleHearing" : "Yes", - "excludeDates" : [{ - "value" : { - "start" : "2030-12-01", - "end" : null + "arrangements": [], + "scheduleHearing": "Yes", + "excludeDates": [ + { + "value": { + "start": "2030-12-01", + "end": null + } } - }] + ] }, "appealReasons": null, "rep": { @@ -66,20 +68,22 @@ }, "signer": null, "hearingType": "oral", - "receivedVia" : "Paper" + "receivedVia": "Paper" }, - "sscsDocument" : [ { - "value" : { - "documentType" : "appellantEvidence", - "documentFileName" : "11111.pdf", - "documentDateAdded" : "2018-10-10", - "documentLink" : { - "document_url" : "http://www.bbc.com", - "document_binary_url" : "http://www.bbc.com/binary", - "document_filename" : "myfile.jpg" + "sscsDocument": [ + { + "value": { + "documentType": "appellantEvidence", + "documentFileName": "11111.pdf", + "documentDateAdded": "2018-10-10", + "documentLink": { + "document_url": "http://www.bbc.com", + "document_binary_url": "http://www.bbc.com/binary", + "document_filename": "myfile.jpg" + } } } - } ], + ], "subscriptions": { "appellantSubscription": { "wantSmsNotifications": "No", @@ -89,28 +93,28 @@ "subscribeSms": "No", "reason": null }, - "supporterSubscription" : null, - "representativeSubscription" : null, - "appointeeSubscription" : null + "supporterSubscription": null, + "representativeSubscription": null, + "appointeeSubscription": null }, - "region" : "BRADFORD", - "regionalProcessingCenter" : { - "name" : "BRADFORD", + "region": "BRADFORD", + "regionalProcessingCenter": { + "name": "BRADFORD", "address1": "HM Courts & Tribunals Service", "address2": "Social Security & Child Support Appeals", "address3": "Phoenix House", "address4": "Rushton Avenue", "city": "BRADFORD", "postcode": "BD3 7BH", - "phoneNumber" : "0300 123 1142", - "faxNumber" : "0126 434 7983", - "email" : "SSCS_Bradford@justice.gov.uk" + "phoneNumber": "0300 123 1142", + "faxNumber": "0126 434 7983", + "email": "SSCS_Bradford@justice.gov.uk" }, - "evidencePresent" : "Yes", - "bulkScanCaseReference" : "1234567890", - "caseCreated" : "2018-01-11" + "evidencePresent": "Yes", + "bulkScanCaseReference": "1234567890", + "caseCreated": "2018-01-11" }, - "security_classification" : "PUBLIC", - "event_token" : "test_event_token", - "ignore_warning" : false + "security_classification": "PUBLIC", + "event_token": "test_event_token", + "ignore_warning": false } diff --git a/src/integrationTest/resources/mappings/exception/case-non-compliant-response.json b/src/integrationTest/resources/mappings/exception/case-non-compliant-response.json index 2c07cbbd2..849302abb 100644 --- a/src/integrationTest/resources/mappings/exception/case-non-compliant-response.json +++ b/src/integrationTest/resources/mappings/exception/case-non-compliant-response.json @@ -49,10 +49,10 @@ "dob": "1976-11-11", "nino": "BB000000B" }, - "isAppointee" : "No", + "isAppointee": "No", "confidentialityRequired": null, "appointee": null, - "isAddressSameAsAppointee" : null, + "isAddressSameAsAppointee": null, "role": null }, "benefitType": { @@ -67,18 +67,20 @@ "wantsHearingTypeFaceToFace": "No" }, "hearingOptions": { - "wantsToAttend" : "Yes", - "wantsSupport" : "No", + "wantsToAttend": "Yes", + "wantsSupport": "No", "languageInterpreter": "No", "languages": null, - "arrangements" : [], - "scheduleHearing" : "Yes", - "excludeDates" : [{ - "value" : { - "start" : "2030-12-01", - "end" : null + "arrangements": [], + "scheduleHearing": "Yes", + "excludeDates": [ + { + "value": { + "start": "2030-12-01", + "end": null + } } - }] + ] }, "appealReasons": null, "rep": { @@ -92,20 +94,22 @@ }, "signer": null, "hearingType": "oral", - "receivedVia" : "Paper" + "receivedVia": "Paper" }, - "sscsDocument" : [ { - "value" : { - "documentType" : "appellantEvidence", - "documentFileName" : "11111.pdf", - "documentDateAdded" : "2018-10-10", - "documentLink" : { - "document_url" : "http://www.bbc.com", - "document_binary_url" : "http://www.bbc.com/binary", - "document_filename" : "myfile.jpg" + "sscsDocument": [ + { + "value": { + "documentType": "appellantEvidence", + "documentFileName": "11111.pdf", + "documentDateAdded": "2018-10-10", + "documentLink": { + "document_url": "http://www.bbc.com", + "document_binary_url": "http://www.bbc.com/binary", + "document_filename": "myfile.jpg" + } } } - } ], + ], "subscriptions": { "appellantSubscription": { "wantSmsNotifications": "No", @@ -117,30 +121,30 @@ "lastLoggedIntoMya": null, "tya": "TYA_RANDOM_NUMBER" }, - "supporterSubscription" : null, - "representativeSubscription" : null, - "appointeeSubscription" : null, + "supporterSubscription": null, + "representativeSubscription": null, + "appointeeSubscription": null, "jointPartySubscription": null }, - "region" : "BRADFORD", - "regionalProcessingCenter" : { - "name" : "BRADFORD", + "region": "BRADFORD", + "regionalProcessingCenter": { + "name": "BRADFORD", "address1": "HM Courts & Tribunals Service", "address2": "Social Security & Child Support Appeals", "address3": "Phoenix House", "address4": "Rushton Avenue", "city": "BRADFORD", "postcode": "BD3 7BH", - "phoneNumber" : "0300 123 1142", - "faxNumber" : "0126 434 7983", - "email" : "SSCS_Bradford@justice.gov.uk", - "hearingRoute": "gaps", + "phoneNumber": "0300 123 1142", + "faxNumber": "0126 434 7983", + "email": "SSCS_Bradford@justice.gov.uk", + "hearingRoute": "gaps", "epimsId": "698118" }, "processingVenue": "Basildon CC", "interlocReferralReason": "over13MonthsAndGroundsMissing", - "evidencePresent" : "Yes", - "bulkScanCaseReference" : "1234567890", + "evidencePresent": "Yes", + "bulkScanCaseReference": "1234567890", "benefitCode": "051", "caseCode": "051DD", "caseCreated": "2018-01-11", @@ -155,7 +159,7 @@ }, "warnings": [], "supplementary_data": { - "$set" : { + "$set": { "HMCTSServiceId": "BBA3" } } diff --git a/src/integrationTest/resources/mappings/exception/sscs5-valid-appeal-response.json b/src/integrationTest/resources/mappings/exception/sscs5-valid-appeal-response.json index e228f4b6d..20ad40bde 100644 --- a/src/integrationTest/resources/mappings/exception/sscs5-valid-appeal-response.json +++ b/src/integrationTest/resources/mappings/exception/sscs5-valid-appeal-response.json @@ -138,7 +138,7 @@ "phoneNumber": "0300 123 1142", "faxNumber": "0126 434 7983", "email": "SSCS_Bradford@justice.gov.uk", - "hearingRoute": "gaps", + "hearingRoute": "gaps", "epimsId": "698118" }, "caseManagementLocation": { @@ -162,7 +162,7 @@ }, "warnings": [], "supplementary_data": { - "$set" : { + "$set": { "HMCTSServiceId": "BBA3" } } diff --git a/src/integrationTest/resources/mappings/exception/valid-appeal-request-old.json b/src/integrationTest/resources/mappings/exception/valid-appeal-request-old.json index 6b60163a8..e61523de0 100644 --- a/src/integrationTest/resources/mappings/exception/valid-appeal-request-old.json +++ b/src/integrationTest/resources/mappings/exception/valid-appeal-request-old.json @@ -35,7 +35,7 @@ "nino": "BB000000B" }, "appointee": null, - "isAddressSameAsAppointee" : null + "isAddressSameAsAppointee": null }, "benefitType": { "code": "ESA", @@ -43,17 +43,19 @@ }, "hearingSubtype": {}, "hearingOptions": { - "wantsToAttend" : "Yes", - "wantsSupport" : "No", + "wantsToAttend": "Yes", + "wantsSupport": "No", "languageInterpreter": "No", - "arrangements" : [], - "scheduleHearing" : "Yes", - "excludeDates" : [{ - "value" : { - "start" : "2030-12-01", - "end" : null + "arrangements": [], + "scheduleHearing": "Yes", + "excludeDates": [ + { + "value": { + "start": "2030-12-01", + "end": null } - }] + } + ] }, "appealReasons": null, "rep": { @@ -65,20 +67,22 @@ }, "signer": null, "hearingType": "oral", - "receivedVia" : "Paper" + "receivedVia": "Paper" }, - "sscsDocument" : [ { - "value" : { - "documentType" : "appellantEvidence", - "documentFileName" : "11111.pdf", - "documentDateAdded" : "2018-10-10", - "documentLink" : { - "document_url" : "http://www.bbc.com", - "document_binary_url" : "http://www.bbc.com/binary", - "document_filename" : "myfile.jpg" + "sscsDocument": [ + { + "value": { + "documentType": "appellantEvidence", + "documentFileName": "11111.pdf", + "documentDateAdded": "2018-10-10", + "documentLink": { + "document_url": "http://www.bbc.com", + "document_binary_url": "http://www.bbc.com/binary", + "document_filename": "myfile.jpg" + } } } - } ], + ], "subscriptions": { "appellantSubscription": { "wantSmsNotifications": "No", @@ -88,9 +92,9 @@ "subscribeSms": "No", "reason": null }, - "supporterSubscription" : null, - "representativeSubscription" : null, - "appointeeSubscription" : null + "supporterSubscription": null, + "representativeSubscription": null, + "appointeeSubscription": null }, "region": "BRADFORD", "regionalProcessingCenter": { @@ -105,11 +109,11 @@ "faxNumber": "0126 434 7983", "email": "SSCS_Bradford@justice.gov.uk" }, - "evidencePresent" : "Yes", - "bulkScanCaseReference" : "1234567890", - "caseCreated" : "2018-01-11" + "evidencePresent": "Yes", + "bulkScanCaseReference": "1234567890", + "caseCreated": "2018-01-11" }, - "security_classification" : "PUBLIC", - "event_token" : "test_event_token", - "ignore_warning" : false + "security_classification": "PUBLIC", + "event_token": "test_event_token", + "ignore_warning": false } diff --git a/src/integrationTest/resources/mappings/exception/valid-appeal-response.json b/src/integrationTest/resources/mappings/exception/valid-appeal-response.json index 26665f4bb..2241810a8 100644 --- a/src/integrationTest/resources/mappings/exception/valid-appeal-response.json +++ b/src/integrationTest/resources/mappings/exception/valid-appeal-response.json @@ -138,7 +138,7 @@ "phoneNumber": "0300 123 1142", "faxNumber": "0126 434 7983", "email": "SSCS_Bradford@justice.gov.uk", - "hearingRoute": "gaps", + "hearingRoute": "gaps", "epimsId": "698118" }, "processingVenue": "Basildon CC", @@ -158,7 +158,7 @@ }, "warnings": [], "supplementary_data": { - "$set" : { + "$set": { "HMCTSServiceId": "BBA3" } } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/bulkscancore/handlers/CcdCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/sscs/bulkscancore/handlers/CcdCallbackHandler.java index ea7e2e973..f512e8e44 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/bulkscancore/handlers/CcdCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/bulkscancore/handlers/CcdCallbackHandler.java @@ -166,13 +166,17 @@ public PreSubmitCallbackResponse handleValidationAndUpdate(Callbac ); boolean ignoreMrnValidation = false; + boolean validateIbcRoleField = false; if (callback.getEvent() != null && (EventType.DIRECTION_ISSUED.equals(callback.getEvent()) || EventType.DIRECTION_ISSUED_WELSH.equals(callback.getEvent())) && callback.getCaseDetails().getCaseData().getDirectionTypeDl() != null) { ignoreMrnValidation = StringUtils.equals(DirectionType.APPEAL_TO_PROCEED.toString(), callback.getCaseDetails().getCaseData().getDirectionTypeDl().getValue().getCode()); } - CaseResponse caseValidationResponse = caseValidator.validateValidationRecord(appealData, ignoreMrnValidation); + if (callback.getEvent() != null && EventType.VALID_APPEAL.equals(callback.getEvent()) && FormType.SSCS8.equals(formType)) { + validateIbcRoleField = true; + } + CaseResponse caseValidationResponse = caseValidator.validateValidationRecord(appealData, ignoreMrnValidation, validateIbcRoleField); PreSubmitCallbackResponse validationErrorResponse = convertWarningsToErrors(callback.getCaseDetails().getCaseData(), caseValidationResponse); diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/bulkscancore/validators/CaseValidator.java b/src/main/java/uk/gov/hmcts/reform/sscs/bulkscancore/validators/CaseValidator.java index 58002cbc0..f52825644 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/bulkscancore/validators/CaseValidator.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/bulkscancore/validators/CaseValidator.java @@ -9,7 +9,7 @@ * If case validation is not required then return original case data in the transformation. */ public interface CaseValidator { - CaseResponse validateValidationRecord(Map caseData, boolean ignoreMrnValidation); + CaseResponse validateValidationRecord(Map caseData, boolean ignoreMrnValidation, boolean validateIbcRoleField); CaseResponse validateExceptionRecord(CaseResponse transformResponse, ExceptionRecord exceptionRecord, Map caseData, boolean combineWarnings); } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/constants/SscsConstants.java b/src/main/java/uk/gov/hmcts/reform/sscs/constants/SscsConstants.java index c8ec89e93..ff881ef17 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/constants/SscsConstants.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/constants/SscsConstants.java @@ -38,6 +38,7 @@ private SscsConstants() { public static final String TELL_TRIBUNAL_ABOUT_DATES = "tell_tribunal_about_dates"; public static final String MRN_DATE = "mrn_date"; public static final String ISSUING_OFFICE = "office"; + public static final String IBCA_ISSUING_OFFICE = "IBCA"; public static final String YES_LITERAL = "Yes"; public static final String NO_LITERAL = "No"; public static final String TITLE = "_title"; @@ -47,12 +48,21 @@ private SscsConstants() { public static final String ADDRESS_LINE2 = "_address_line2"; public static final String ADDRESS_LINE3 = "_address_line3"; public static final String ADDRESS_LINE4 = "_address_line4"; + public static final String ADDRESS_COUNTRY = "_Country"; + public static final String ADDRESS_PORT_OF_ENTRY = "_port_of_entry"; public static final String ADDRESS_POSTCODE = "_postcode"; public static final String PHONE = "_phone"; public static final String MOBILE = "_mobile"; public static final String EMAIL = "_email"; public static final String NINO = "_nino"; + public static final String IBCA_REFERENCE = "_ibca_reference"; public static final String DOB = "_dob"; + public static final String IBC_ROLE_FOR_SELF = "person1_for_self"; + public static final String IBC_ROLE_FOR_U18 = "person1_for_person_under_18"; + public static final String IBC_ROLE_FOR_LACKING_CAPACITY = "person1_on_behalf_of_a_person_who_lacks_capacity"; + public static final String IBC_ROLE_FOR_POA = "person1_as_poa"; + public static final String IBC_ROLE_FOR_DECEASED = "person1_as_rep_of_deceased"; + public static final String IBC_ROLE = "ibcRole"; public static final String IS_EMPTY = "is empty"; public static final String IS_MISSING = "is missing"; public static final String ARE_EMPTY = "are empty. At least one must be populated"; @@ -78,5 +88,6 @@ private SscsConstants() { public static final String OTHER_PARTY_DETAILS = "other_party_details"; public static final String FORM_TYPE = "form_type"; + public static final String INFECTED_BLOOD_COMPENSATION = "infectedBloodCompensation"; } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/constants/WarningMessage.java b/src/main/java/uk/gov/hmcts/reform/sscs/constants/WarningMessage.java index 7bd288309..fd01c5408 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/constants/WarningMessage.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/constants/WarningMessage.java @@ -41,6 +41,9 @@ public enum WarningMessage { APPOINTEE_POSTCODE(ADDRESS_POSTCODE, "Appointee postcode"), REPRESENTATIVE_POSTCODE(ADDRESS_POSTCODE, "Representative postcode"), OTHER_PARTY_POSTCODE(ADDRESS_POSTCODE, "Other party postcode"), + APPELLANT_ADDRESS_COUNTRY(ADDRESS_COUNTRY, "Appellant address country"), + APPELLANT_ADDRESS_PORT_OF_ENTRY(ADDRESS_PORT_OF_ENTRY, "Appellant address port of entry"), + APPELLANT_IBCA_REFERENCE(IBCA_REFERENCE, "Appellant ibca reference"), BENEFIT_TYPE_DESCRIPTION(SscsConstants.BENEFIT_TYPE_DESCRIPTION, "Benefit type description"), BENEFIT_TYPE_OTHER(SscsConstants.BENEFIT_TYPE_OTHER, "Benefit type description"), MRN_DATE(SscsConstants.MRN_DATE, "Mrn date"), diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/transformers/SscsCaseTransformer.java b/src/main/java/uk/gov/hmcts/reform/sscs/transformers/SscsCaseTransformer.java index 9d4ca4edd..e641b3982 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/transformers/SscsCaseTransformer.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/transformers/SscsCaseTransformer.java @@ -131,7 +131,7 @@ public CaseResponse transformExceptionRecord(ExceptionRecord exceptionRecord, bo formTypeUpdated = true; } - if (formType == null || notAValidFormType(formType)) { + if (formType == null || notAValidFormType(formType)) { formType = exceptionRecord.getFormType(); if (formType != null && notAValidFormType(formType)) { @@ -182,13 +182,14 @@ private Map transformData(String caseId, boolean ignoreWarnings, boolean formTypeUpdated, String orgFormType) { - Appeal appeal = buildAppealFromData(scannedData.getOcrCaseData(), caseId, formType, errors, ignoreWarnings); + boolean isSscs8 = FormType.SSCS8.toString().equalsIgnoreCase(formType); + Appeal appeal = buildAppealFromData(scannedData.getOcrCaseData(), caseId, formType, errors, ignoreWarnings, isSscs8); List sscsDocuments = buildDocumentsFromData(scannedData.getRecords(), formTypeUpdated, orgFormType, formType); Subscriptions subscriptions = populateSubscriptions(appeal, scannedData.getOcrCaseData()); Map transformed = new HashMap<>(); - List> otherParties = buildOtherParty(scannedData.getOcrCaseData()); + List> otherParties = buildOtherParty(scannedData.getOcrCaseData(), isSscs8); sscsDataHelper.addSscsDataToMap(transformed, appeal, sscsDocuments, subscriptions, FormType.getById(formType), getField(scannedData.getOcrCaseData(), PERSON_1_CHILD_MAINTENANCE_NUMBER), otherParties); @@ -253,7 +254,7 @@ && isNotBlank(email)) { .wantSmsNotifications(convertBooleanToYesNoString(wantsSms)).tya(generateAppealNumber()).build(); } - private Appeal buildAppealFromData(Map pairs, String caseId, String formType, Set errors, boolean ignoreWarnings) { + private Appeal buildAppealFromData(Map pairs, String caseId, String formType, Set errors, boolean ignoreWarnings, boolean isSscs8) { Appellant appellant = null; if (pairs != null && pairs.size() != 0) { @@ -262,15 +263,15 @@ private Appeal buildAppealFromData(Map pairs, String caseId, Str if (hasPerson(pairs, PERSON1_VALUE)) { appointee = Appointee.builder() .name(buildPersonName(pairs, PERSON1_VALUE)) - .address(buildPersonAddress(pairs, PERSON1_VALUE)) + .address(buildPersonAddress(pairs, PERSON1_VALUE, isSscs8)) .contact(buildPersonContact(pairs, PERSON1_VALUE)) .identity(buildPersonIdentity(pairs, PERSON1_VALUE)) .build(); } - appellant = buildAppellant(pairs, PERSON2_VALUE, appointee, buildPersonContact(pairs, PERSON2_VALUE), formType, ignoreWarnings); + appellant = buildAppellant(pairs, PERSON2_VALUE, appointee, buildPersonContact(pairs, PERSON2_VALUE), formType, ignoreWarnings, isSscs8); } else if (hasPerson(pairs, PERSON1_VALUE)) { - appellant = buildAppellant(pairs, PERSON1_VALUE, null, buildPersonContact(pairs, PERSON1_VALUE), formType, ignoreWarnings); + appellant = buildAppellant(pairs, PERSON1_VALUE, null, buildPersonContact(pairs, PERSON1_VALUE), formType, ignoreWarnings, isSscs8); } String hearingType = findHearingType(pairs); @@ -286,16 +287,19 @@ private Appeal buildAppealFromData(Map pairs, String caseId, Str benefitType = BenefitType.builder() .code(CHILD_SUPPORT.getShortName()) .description(CHILD_SUPPORT.getDescription()).build(); + } else if (FormType.SSCS8.toString().equalsIgnoreCase(formType)) { + benefitType = BenefitType.builder() + .code(Benefit.INFECTED_BLOOD_COMPENSATION.getShortName()) + .description(Benefit.INFECTED_BLOOD_COMPENSATION.getDescription()).build(); } else { benefitType = getBenefitType(caseId, pairs, FormType.getById(formType)); } - return Appeal.builder() .benefitType(benefitType) .appellant(appellant) .appealReasons(appealReasons) - .rep(buildRepresentative(pairs)) + .rep(buildRepresentative(pairs, isSscs8)) .mrnDetails(buildMrnDetails(pairs, benefitType)) .hearingType(hearingType) .hearingOptions(buildHearingOptions(pairs, hearingType)) @@ -481,16 +485,17 @@ private String getCodeFromField(String caseId, Map pairs, String } private Appellant buildAppellant(Map pairs, String personType, Appointee appointee, - Contact contact, String formType, boolean ignoreWarnings) { + Contact contact, String formType, boolean ignoreWarnings, boolean isSscs8) { return Appellant.builder() .name(buildPersonName(pairs, personType)) .isAppointee(convertBooleanToYesNoString(appointee != null)) - .address(buildPersonAddress(pairs, personType)) + .address(buildPersonAddress(pairs, personType, isSscs8)) .identity(buildPersonIdentity(pairs, personType)) .contact(contact) .confidentialityRequired(getConfidentialityRequired(pairs, errors)) .appointee(appointee) .role(buildAppellantRole(pairs, formType, ignoreWarnings)) + .ibcRole(buildIbcRole(pairs, personType, isSscs8)) .build(); } @@ -500,6 +505,33 @@ private YesNo getConfidentialityRequired(Map pairs, Set ? convertBooleanToYesNo(getBoolean(pairs, errors, KEEP_HOME_ADDRESS_CONFIDENTIAL)) : null; } + private String buildIbcRole(Map pairs, String personType, boolean isSscs8) { + String value = null; + if (isSscs8 && personType.equalsIgnoreCase("person1")) { + Map ibcRoles = Map.of( + IBC_ROLE_FOR_SELF, extractBooleanValue(pairs, warnings, IBC_ROLE_FOR_SELF) ? 1 : 0, + IBC_ROLE_FOR_U18, extractBooleanValue(pairs, warnings, IBC_ROLE_FOR_U18) ? 1 : 0, + IBC_ROLE_FOR_LACKING_CAPACITY, extractBooleanValue(pairs, warnings, IBC_ROLE_FOR_LACKING_CAPACITY) ? 1 : 0, + IBC_ROLE_FOR_POA, extractBooleanValue(pairs, warnings, IBC_ROLE_FOR_POA) ? 1 : 0, + IBC_ROLE_FOR_DECEASED, extractBooleanValue(pairs, warnings, IBC_ROLE_FOR_DECEASED) ? 1 : 0 + ); + Map valueMapping = Map.of( + IBC_ROLE_FOR_SELF, "myself", + IBC_ROLE_FOR_U18, "parent", + IBC_ROLE_FOR_LACKING_CAPACITY, "guardian", + IBC_ROLE_FOR_POA, "powerOfAttorney", + IBC_ROLE_FOR_DECEASED, "deceasedRepresentative" + ); + + value = ibcRoles.entrySet().stream() + .filter(entry -> entry.getValue() == 1) + .map(entry -> valueMapping.get(entry.getKey())) + .findFirst() + .orElse(null); + } + return value; + } + private Role buildAppellantRole(Map pairs, String formType, boolean ignoreWarnings) { if (FormType.SSCS2.toString().equalsIgnoreCase(formType)) { List validProvidedBooleanValues = @@ -566,14 +598,14 @@ private boolean validateValues(List validValues, String otherPartyDetail return true; } - private Representative buildRepresentative(Map pairs) { + private Representative buildRepresentative(Map pairs, boolean isSscs8) { boolean doesRepExist = hasPerson(pairs, REPRESENTATIVE_VALUE); if (doesRepExist) { return Representative.builder() .hasRepresentative(YES_LITERAL) .name(buildPersonName(pairs, REPRESENTATIVE_VALUE)) - .address(buildPersonAddress(pairs, REPRESENTATIVE_VALUE)) + .address(buildPersonAddress(pairs, REPRESENTATIVE_VALUE, isSscs8)) .organisation(getField(pairs, "representative_company")) .contact(buildPersonContact(pairs, REPRESENTATIVE_VALUE)) .build(); @@ -582,7 +614,7 @@ private Representative buildRepresentative(Map pairs) { } } - private List> buildOtherParty(Map pairs) { + private List> buildOtherParty(Map pairs, boolean isSscs8) { if (pairs != null && pairs.size() != 0) { boolean doesOtherPartyExist = hasPerson(pairs, OTHER_PARTY_VALUE); @@ -590,18 +622,18 @@ private List> buildOtherParty(Map pairs) { if (doesOtherPartyExist) { if (isOtherPartyAddressValid(pairs)) { return Collections.singletonList(CcdValue.builder().value( - OtherParty.builder() - .id(OTHER_PARTY_ID_ONE) - .name(buildPersonName(pairs, OTHER_PARTY_VALUE)) - .address(buildPersonAddress(pairs, OTHER_PARTY_VALUE)) - .build()) + OtherParty.builder() + .id(OTHER_PARTY_ID_ONE) + .name(buildPersonName(pairs, OTHER_PARTY_VALUE)) + .address(buildPersonAddress(pairs, OTHER_PARTY_VALUE, isSscs8)) + .build()) .build()); } return Collections.singletonList(CcdValue.builder().value( - OtherParty.builder() - .id(OTHER_PARTY_ID_ONE) - .name(buildPersonName(pairs, OTHER_PARTY_VALUE)).build()) + OtherParty.builder() + .id(OTHER_PARTY_ID_ONE) + .name(buildPersonName(pairs, OTHER_PARTY_VALUE)).build()) .build()); } } @@ -622,7 +654,7 @@ private MrnDetails buildMrnDetails(Map pairs, BenefitType benefi String office = getDwpIssuingOffice(pairs, benefitType); return MrnDetails.builder() - .mrnDate(generateDateForCcd(pairs, errors, "mrn_date")) + .mrnDate(generateDateForCcd(pairs, errors, MRN_DATE)) .mrnLateReason(getField(pairs, "appeal_late_reason")) .dwpIssuingOffice(office) .build(); @@ -632,6 +664,9 @@ private String getDwpIssuingOffice(Map pairs, BenefitType benefi String dwpIssuingOffice = getField(pairs, "office"); if (benefitType != null && benefitType.getCode() != null) { + if (benefitType.getCode().equalsIgnoreCase(Benefit.INFECTED_BLOOD_COMPENSATION.getShortName())) { + return IBCA_ISSUING_OFFICE; + } if (Benefit.getBenefitOptionalByCode(benefitType.getCode()) .filter(benefit -> isBenefitWithAutoFilledOffice(benefit, dwpIssuingOffice)).isPresent()) { return dwpAddressLookupService.getDefaultDwpMappingByBenefitType(benefitType.getCode()) @@ -674,12 +709,12 @@ private boolean isBenefitWithAutoFilledOffice(Benefit benefit, String office) { } private Name buildPersonName(Map pairs, String personType) { - String title = transformTitle(getField(pairs, personType + "_title")); + String title = transformTitle(getField(pairs, personType + TITLE)); return Name.builder() .title(title) - .firstName(getField(pairs, personType + "_first_name")) - .lastName(getField(pairs, personType + "_last_name")) + .firstName(getField(pairs, personType + FIRST_NAME)) + .lastName(getField(pairs, personType + LAST_NAME)) .build(); } @@ -692,7 +727,18 @@ private String transformTitle(String title) { return title; } - private Address buildPersonAddress(Map pairs, String personType) { + private Address buildPersonAddress(Map pairs, String personType, boolean isSscs8) { + if (findBooleanExists(getField(pairs, personType + ADDRESS_PORT_OF_ENTRY))) { + return Address.builder() + .line1(getField(pairs, personType + ADDRESS_LINE1)) + .line2(getField(pairs, personType + ADDRESS_LINE2)) + .town(getField(pairs, personType + ADDRESS_LINE3)) + .country(getField(pairs, personType + ADDRESS_COUNTRY)) + .portOfEntry(getField(pairs, personType + ADDRESS_PORT_OF_ENTRY)) + .postcode(getField(pairs, personType + ADDRESS_POSTCODE)) + .inMainlandUk(isSscs8 ? YesNo.NO : null) + .build(); + } if (findBooleanExists(getField(pairs, personType + ADDRESS_LINE4))) { return Address.builder() .line1(getField(pairs, personType + ADDRESS_LINE1)) @@ -700,33 +746,33 @@ private Address buildPersonAddress(Map pairs, String personType) .town(getField(pairs, personType + ADDRESS_LINE3)) .county(getField(pairs, personType + ADDRESS_LINE4)) .postcode(getField(pairs, personType + ADDRESS_POSTCODE)) + .inMainlandUk(isSscs8 ? YesNo.YES : null) .build(); } - boolean line3IsBlank = false; - if (findBooleanExists(getField(pairs, personType + ADDRESS_LINE2)) - && !findBooleanExists(getField(pairs, personType + ADDRESS_LINE3))) { - line3IsBlank = true; - } + boolean line3IsBlank = findBooleanExists(getField(pairs, personType + ADDRESS_LINE2)) + && !findBooleanExists(getField(pairs, personType + ADDRESS_LINE3)); return Address.builder() .line1(getField(pairs, personType + ADDRESS_LINE1)) .town(getField(pairs, personType + ADDRESS_LINE2)) .county(line3IsBlank ? "." : getField(pairs, personType + ADDRESS_LINE3)) .postcode(getField(pairs, personType + ADDRESS_POSTCODE)) + .inMainlandUk(isSscs8 ? YesNo.YES : null) .build(); } private Identity buildPersonIdentity(Map pairs, String personType) { return Identity.builder() - .dob(generateDateForCcd(pairs, errors, personType + "_dob")) - .nino(normaliseNino(getField(pairs, personType + "_nino"))) + .dob(generateDateForCcd(pairs, errors, personType + DOB)) + .nino(normaliseNino(getField(pairs, personType + NINO))) + .ibcaReference(getField(pairs, personType + IBCA_REFERENCE)) .build(); } private Contact buildPersonContact(Map pairs, String personType) { return Contact.builder() - .phone(getField(pairs, personType + "_phone")) - .mobile(getField(pairs, personType + "_mobile")) - .email(getField(pairs, personType + "_email")) + .phone(getField(pairs, personType + PHONE)) + .mobile(getField(pairs, personType + MOBILE)) + .email(getField(pairs, personType + EMAIL)) .build(); } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/util/SscsOcrDataUtil.java b/src/main/java/uk/gov/hmcts/reform/sscs/util/SscsOcrDataUtil.java index 183018e9c..cf386b622 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/util/SscsOcrDataUtil.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/util/SscsOcrDataUtil.java @@ -21,10 +21,10 @@ private SscsOcrDataUtil() { public static Boolean hasPerson(Map pairs, String person) { - return findBooleanExists(getField(pairs,person + "_title"), getField(pairs,person + "_first_name"), - getField(pairs,person + "_last_name"), getField(pairs,person + "_address_line1"), getField(pairs,person + "_address_line2"), - getField(pairs,person + "_address_line3"), getField(pairs,person + "_address_line4"), getField(pairs,person + "_postcode"), - getField(pairs,person + "_dob"), getField(pairs,person + "_nino"), getField(pairs,person + "_company"), getField(pairs,person + "_phone")); + return findBooleanExists(getField(pairs, person + "_title"), getField(pairs, person + "_first_name"), + getField(pairs, person + "_last_name"), getField(pairs, person + "_address_line1"), getField(pairs, person + "_address_line2"), + getField(pairs, person + "_address_line3"), getField(pairs, person + "_address_line4"), getField(pairs, person + "_postcode"), + getField(pairs, person + "_dob"), getField(pairs, person + "_nino"), getField(pairs, person + "_company"), getField(pairs, person + "_phone")); } public static boolean findBooleanExists(String... values) { @@ -38,8 +38,8 @@ public static boolean findBooleanExists(String... values) { public static Boolean hasAddress(Map pairs, String person) { - return findBooleanExists(getField(pairs,person + "_address_line1"), getField(pairs,person + "_address_line2"), - getField(pairs,person + "_address_line3"), getField(pairs,person + "_address_line4"), getField(pairs,person + "_postcode")); + return findBooleanExists(getField(pairs, person + "_address_line1"), getField(pairs, person + "_address_line2"), + getField(pairs, person + "_address_line3"), getField(pairs, person + "_address_line4"), getField(pairs, person + "_postcode")); } public static String getField(Map pairs, String field) { @@ -110,6 +110,18 @@ public static boolean extractBooleanValue(Map pairs, Set return false; } + public static boolean extractBooleanValueWarning(Map pairs, List errors, String value) { + if (pairs.get(value) != null) { + Boolean booleanValue = BooleanUtils.toBooleanObject(pairs.get(value).toString()); + if (booleanValue != null) { + return booleanValue; + } else { + errors.add(value + " has an invalid value. Should be Yes/No or True/False"); + } + } + return false; + } + public static boolean getBoolean(Map pairs, Set errors, String value) { return checkBooleanValue(pairs, errors, value) && BooleanUtils.toBoolean(pairs.get(value).toString()); @@ -131,11 +143,12 @@ public static String generateDateForCcd(Map pairs, Set e } public static String getDateForCcd(String ocrField, Set errors, String errorMessage) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/uuuu").withResolverStyle(ResolverStyle.STRICT); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("[d/M/uuuu][ddMMuuuu]") + .withResolverStyle(ResolverStyle.STRICT); if (!StringUtils.isEmpty(ocrField)) { try { - return LocalDate.parse(ocrField, formatter).toString(); + return LocalDate.parse(ocrField, formatter).format(DateTimeFormatter.ofPattern("uuuu-MM-dd")); } catch (DateTimeParseException ex) { errors.add(errorMessage); } diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/validators/SscsCaseValidator.java b/src/main/java/uk/gov/hmcts/reform/sscs/validators/SscsCaseValidator.java index 76c10fcca..6e5684db6 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/validators/SscsCaseValidator.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/validators/SscsCaseValidator.java @@ -107,7 +107,7 @@ public CaseResponse validateExceptionRecord(CaseResponse transformResponse, Exce ScannedData ocrCaseData = sscsJsonExtractor.extractJson(exceptionRecord); boolean ignoreWarningsValue = exceptionRecord.getIgnoreWarnings() != null ? exceptionRecord.getIgnoreWarnings() : false; - validateAppeal(ocrCaseData.getOcrCaseData(), caseData, false, ignoreWarningsValue, true); + validateAppeal(ocrCaseData.getOcrCaseData(), caseData, false, false, ignoreWarningsValue, true); if (combineWarnings) { warnings = combineWarnings(); @@ -122,14 +122,14 @@ public CaseResponse validateExceptionRecord(CaseResponse transformResponse, Exce } @Override - public CaseResponse validateValidationRecord(Map caseData, boolean ignoreMrnValidation) { + public CaseResponse validateValidationRecord(Map caseData, boolean ignoreMrnValidation, boolean validateIbcRoleField) { warnings = new ArrayList<>(); errors = new ArrayList<>(); callbackType = VALIDATION_CALLBACK; Map ocrCaseData = new HashMap<>(); - validateAppeal(ocrCaseData, caseData, ignoreMrnValidation, false, false); + validateAppeal(ocrCaseData, caseData, ignoreMrnValidation, validateIbcRoleField, false, false); return CaseResponse.builder() .errors(errors) @@ -139,15 +139,13 @@ public CaseResponse validateValidationRecord(Map caseData, boole } private List validateAppeal(Map ocrCaseData, Map caseData, - boolean ignoreMrnValidation, boolean ignoreWarnings, boolean ignorePartyRoleValidation) { + boolean ignoreMrnValidation, boolean validateIbcRoleField, boolean ignoreWarnings, boolean ignorePartyRoleValidation) { FormType formType = (FormType) caseData.get("formType"); Appeal appeal = (Appeal) caseData.get("appeal"); String appellantPersonType = getPerson1OrPerson2(appeal.getAppellant()); - final String benefitTypeCode = Optional.of(appeal) - .map(Appeal::getBenefitType) - .map(BenefitType::getCode) - .orElse(null); + + final boolean isSscs8 = FormType.SSCS8.equals(formType); checkAppellant( appeal, @@ -155,15 +153,13 @@ private List validateAppeal(Map ocrCaseData, Map sscsDocuments) { }); } - private void checkAppellant(Appeal appeal, Map ocrCaseData, Map caseData, - String personType, FormType formType, boolean ignorePartyRoleValidation, - boolean ignoreWarnings, String benefitTypeCode) { + String personType, FormType formType, boolean validateIbcRoleField, + boolean ignorePartyRoleValidation, boolean ignoreWarnings, boolean isSscs8) { Appellant appellant = appeal.getAppellant(); @@ -239,20 +234,27 @@ private void checkAppellant(Appeal appeal, Map ocrCaseData, Map< warnings.add(getMessageByCallbackType(callbackType, personType, getWarningMessageName(personType, appellant) + ADDRESS_POSTCODE, IS_EMPTY)); warnings.add( - getMessageByCallbackType(callbackType, personType, getWarningMessageName(personType, appellant) + NINO, + getMessageByCallbackType(callbackType, personType, getWarningMessageName(personType, appellant) + (isSscs8 ? IBCA_REFERENCE : NINO), IS_EMPTY)); } else { - checkAppointee(appellant, ocrCaseData, caseData, benefitTypeCode); + checkAppointee(appellant, ocrCaseData, caseData, isSscs8); + + checkPersonName(appellant.getName(), personType, appellant, isSscs8); - checkPersonName(appellant.getName(), personType, appellant); + checkPersonAddressAndDob(appellant.getAddress(), appellant.getIdentity(), personType, ocrCaseData, caseData, + appellant, isSscs8); - if (!INFECTED_BLOOD_COMPENSATION.equals(benefitTypeCode)) { - checkPersonAddressAndDob(appellant.getAddress(), appellant.getIdentity(), personType, ocrCaseData, caseData, - appellant, benefitTypeCode); + if (isSscs8) { + checkAppellantIbcaReference(appellant, personType); + } else { checkAppellantNino(appellant, personType); } + if (isSscs8) { + checkIbcRole(personType, ocrCaseData, appellant, validateIbcRoleField); + } + checkMobileNumber(appellant.getContact(), personType); checkHearingSubtypeDetails(appeal.getHearingSubtype()); @@ -304,23 +306,23 @@ private void checkHearingSubtypeDetails(HearingSubtype hearingSubtype) { } } - private void checkAppointee(Appellant appellant, Map ocrCaseData, Map caseData, String benefitTypeCode) { + private void checkAppointee(Appellant appellant, Map ocrCaseData, Map caseData, boolean isSscs8) { if (appellant != null && !isAppointeeDetailsEmpty(appellant.getAppointee())) { - checkPersonName(appellant.getAppointee().getName(), PERSON1_VALUE, appellant); + checkPersonName(appellant.getAppointee().getName(), PERSON1_VALUE, appellant, isSscs8); checkPersonAddressAndDob(appellant.getAppointee().getAddress(), appellant.getAppointee().getIdentity(), - PERSON1_VALUE, ocrCaseData, caseData, appellant, benefitTypeCode); + PERSON1_VALUE, ocrCaseData, caseData, appellant, isSscs8); checkMobileNumber(appellant.getAppointee().getContact(), PERSON1_VALUE); } } - private void checkRepresentative(Appeal appeal, Map ocrCaseData, Map caseData, String benefitTypeCode) { + private void checkRepresentative(Appeal appeal, Map ocrCaseData, Map caseData, boolean isSscs8) { if (appeal.getRep() == null || StringUtils.isBlank(appeal.getRep().getHasRepresentative())) { errors.add(HAS_REPRESENTATIVE_FIELD_MISSING); } if (appeal.getRep() != null && StringUtils.equals(appeal.getRep().getHasRepresentative(), YES_LITERAL)) { final Contact repsContact = appeal.getRep().getContact(); checkPersonAddressAndDob(appeal.getRep().getAddress(), null, REPRESENTATIVE_VALUE, ocrCaseData, caseData, - appeal.getAppellant(), benefitTypeCode); + appeal.getAppellant(), isSscs8); Name name = appeal.getRep().getName(); @@ -370,7 +372,7 @@ private void checkOtherPartyDataValid(Name name, Address address) { IS_INVALID)); } - boolean hasNoName = ! doesFirstNameExist(name) && !doesLastNameExist(name); + boolean hasNoName = !doesFirstNameExist(name) && !doesLastNameExist(name); if (!hasNoName) { otherPartyNameValidation(name); @@ -440,7 +442,7 @@ private void checkMrnDetails(Appeal appeal, Map ocrCaseData, boo log.info("DwpHandling handling office is not valid"); warnings.add(getMessageByCallbackType(callbackType, "", ISSUING_OFFICE, IS_INVALID)); } - } else if (dwpIssuingOffice == null && !FormType.SSCS2.equals(formType) && !FormType.SSCS5.equals(formType)) { + } else if (dwpIssuingOffice == null && !FormType.SSCS2.equals(formType) && !FormType.SSCS5.equals(formType) && !FormType.SSCS8.equals(formType)) { warnings.add(getMessageByCallbackType(callbackType, "", ISSUING_OFFICE, IS_EMPTY)); } } @@ -455,16 +457,17 @@ private String getDwpIssuingOffice(Appeal appeal, Map ocrCaseDat } } - private void checkPersonName(Name name, String personType, Appellant appellant) { - - if (!doesTitleExist(name)) { - warnings.add( - getMessageByCallbackType(callbackType, personType, getWarningMessageName(personType, appellant) + TITLE, - IS_EMPTY)); - } else if (name != null && !isTitleValid(name.getTitle())) { - warnings.add( - getMessageByCallbackType(callbackType, personType, getWarningMessageName(personType, appellant) + TITLE, - IS_INVALID)); + private void checkPersonName(Name name, String personType, Appellant appellant, boolean isSscs8) { + if (!isSscs8) { + if (!doesTitleExist(name)) { + warnings.add( + getMessageByCallbackType(callbackType, personType, getWarningMessageName(personType, appellant) + TITLE, + IS_EMPTY)); + } else if (name != null && !isTitleValid(name.getTitle())) { + warnings.add( + getMessageByCallbackType(callbackType, personType, getWarningMessageName(personType, appellant) + TITLE, + IS_INVALID)); + } } if (!doesFirstNameExist(name)) { @@ -477,12 +480,49 @@ private void checkPersonName(Name name, String personType, Appellant appellant) } } + private void checkIbcRole(String personType, Map ocrCaseData, Appellant appellant, boolean validateIbcRoleField) { + if (!validateIbcRoleField && personType.equalsIgnoreCase("person1")) { + Map ibcRoles = Map.of( + IBC_ROLE_FOR_SELF, extractBooleanValueWarning(ocrCaseData, warnings, IBC_ROLE_FOR_SELF) ? 1 : 0, + IBC_ROLE_FOR_U18, extractBooleanValueWarning(ocrCaseData, warnings, IBC_ROLE_FOR_U18) ? 1 : 0, + IBC_ROLE_FOR_LACKING_CAPACITY, extractBooleanValueWarning(ocrCaseData, warnings, IBC_ROLE_FOR_LACKING_CAPACITY) ? 1 : 0, + IBC_ROLE_FOR_POA, extractBooleanValueWarning(ocrCaseData, warnings, IBC_ROLE_FOR_POA) ? 1 : 0, + IBC_ROLE_FOR_DECEASED, extractBooleanValueWarning(ocrCaseData, warnings, IBC_ROLE_FOR_DECEASED) ? 1 : 0 + ); + + long trueCount = ibcRoles.values().stream().filter(value -> value == 1).count(); + + if (trueCount > 1) { + ArrayList chosenRoles = new ArrayList<>(); + ibcRoles.forEach((role, value) -> { + if (value == 1) { + chosenRoles.add(role); + } + }); + errors.add(String.join(", ", chosenRoles) + " cannot all be True"); + } else if (trueCount == 0) { + ibcRoles.keySet().forEach(role -> { + errors.add(role + ": one role must be True"); + }); + } + } + + if (validateIbcRoleField && appellant.getIbcRole() == null) { + errors.add(IBC_ROLE + " " + IS_EMPTY); + } + } + private void checkPersonAddressAndDob(Address address, Identity identity, String personType, Map ocrCaseData, Map caseData, - Appellant appellant, String benefitTypeCode) { + Appellant appellant, boolean isSscs8) { boolean isAddressLine4Present = findBooleanExists(getField(ocrCaseData, personType + "_address_line4")); + // Remove this part if/when the mainland UK question is added to sscs8 form + if (isSscs8 && address != null && address.getInMainlandUk() == null) { + address.setInMainlandUk(doesAddressPortOfEntryExist(address) ? YesNo.NO : YesNo.YES); + } + if (!doesAddressLine1Exist(address)) { warnings.add(getMessageByCallbackType(callbackType, personType, getWarningMessageName(personType, appellant) + ADDRESS_LINE1, IS_EMPTY)); @@ -501,26 +541,30 @@ private void checkPersonAddressAndDob(Address address, Identity identity, String getWarningMessageName(personType, appellant) + townLine, HAS_INVALID_ADDRESS)); } - String countyLine = (isAddressLine4Present) ? ADDRESS_LINE4 : "_ADDRESS_LINE3_COUNTY"; - if (!doesAddressCountyExist(address)) { - warnings.add(getMessageByCallbackType(callbackType, personType, - getWarningMessageName(personType, appellant) + countyLine, IS_EMPTY)); - } else if (!address.getCounty().matches(COUNTY_REGEX)) { - warnings.add(getMessageByCallbackType(callbackType, personType, - getWarningMessageName(personType, appellant) + countyLine, HAS_INVALID_ADDRESS)); + // Removed from IBC as it's an optional field for non mainland UK addresses + if (!isSscs8 || isInMainlandUk(address)) { + // Once form has been updated to account for this, this can be re-enabled + String countyLine = (isAddressLine4Present) ? ADDRESS_LINE4 : "_ADDRESS_LINE3_COUNTY"; + if (!doesAddressCountyExist(address)) { + warnings.add(getMessageByCallbackType(callbackType, personType, + getWarningMessageName(personType, appellant) + countyLine, IS_EMPTY)); + } else if (!address.getCounty().matches(COUNTY_REGEX)) { + warnings.add(getMessageByCallbackType(callbackType, personType, + getWarningMessageName(personType, appellant) + countyLine, HAS_INVALID_ADDRESS)); + } } if (isAddressPostcodeValid(address, personType, appellant) && address != null) { if (personType.equals(getPerson1OrPerson2(appellant))) { - boolean isIbc = INFECTED_BLOOD_COMPENSATION.equals(benefitTypeCode); - var postCodeOrPort = YesNo.NO.equals(address.getInMainlandUk()) ? address.getPortOfEntry() : address.getPostcode(); + boolean isPort = YesNo.NO.equals(address.getInMainlandUk()); + String postCodeOrPort = isPort ? address.getPortOfEntry() : address.getPostcode(); - RegionalProcessingCenter rpc = regionalProcessingCenterService.getByPostcode(postCodeOrPort, isIbc); + RegionalProcessingCenter rpc = regionalProcessingCenterService.getByPostcode(postCodeOrPort, isSscs8); if (rpc != null) { caseData.put("region", rpc.getName()); caseData.put("regionalProcessingCenter", rpc); - } else { + } else if (!isPort) { warnings.add(getMessageByCallbackType(callbackType, personType, getWarningMessageName(personType, appellant) + ADDRESS_POSTCODE, "is not a postcode that maps to a regional processing center")); @@ -568,6 +612,10 @@ private Boolean doesAddressLine1Exist(Address address) { return false; } + private boolean isInMainlandUk(Address address) { + return address == null || address.getInMainlandUk() == null || YesNo.YES.equals(address.getInMainlandUk()); + } + private Boolean doesAddressPostcodeExist(Address address) { if (address != null) { return StringUtils.isNotEmpty(address.getPostcode()); @@ -589,6 +637,13 @@ private Boolean doesAddressCountyExist(Address address) { return false; } + private Boolean doesAddressPortOfEntryExist(Address address) { + if (address != null) { + return StringUtils.isNotEmpty(address.getPortOfEntry()); + } + return false; + } + private Boolean isAddressPostcodeValid(Address address, String personType, Appellant appellant) { if (address != null && YesNo.NO.equals(address.getInMainlandUk())) { return true; @@ -623,6 +678,20 @@ private void checkAppellantNino(Appellant appellant, String personType) { } } + private void checkAppellantIbcaReference(Appellant appellant, String personType) { + if (appellant != null && appellant.getIdentity() != null && appellant.getIdentity().getIbcaReference() != null) { + if (!String.join("", appellant.getIdentity().getIbcaReference().split(" ")).matches( + "^[A-z]\\d{2}[A-z]\\d{2}$")) { + warnings.add(getMessageByCallbackType(callbackType, personType, + getWarningMessageName(personType, appellant) + IBCA_REFERENCE, IS_INVALID)); + } + } else { + warnings.add( + getMessageByCallbackType(callbackType, personType, getWarningMessageName(personType, appellant) + IBCA_REFERENCE, + IS_EMPTY)); + } + } + private void checkDateValidDate(String dateField, String fieldName, String personType, Boolean isInFutureCheck) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); @@ -720,7 +789,13 @@ private void isBenefitTypeValid(Appeal appeal, FormType formType) { .build()); } } else { - if (formType == null || (!formType.equals(FormType.SSCS1U) && !formType.equals(FormType.SSCS5))) { + if (FormType.SSCS8.equals(formType)) { + appeal.setBenefitType(BenefitType.builder() + .description(Benefit.INFECTED_BLOOD_COMPENSATION.getDescription()) + .code(Benefit.INFECTED_BLOOD_COMPENSATION.getShortName()) + .build()); + } + if (formType == null || (!formType.equals(FormType.SSCS1U) && !formType.equals(FormType.SSCS5) && !formType.equals(FormType.SSCS8))) { warnings.add(getMessageByCallbackType(callbackType, "", BENEFIT_TYPE_DESCRIPTION, IS_EMPTY)); } } @@ -801,4 +876,9 @@ private String getWarningMessageName(String personType, Appellant appellant) { return "APPOINTEE"; } } + + private boolean isIbcOrSscs8(FormType formType, String benefitTypeCode) { + return Benefit.INFECTED_BLOOD_COMPENSATION.getShortName().equals(benefitTypeCode) + || FormType.SSCS8.equals(formType); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/TestDataConstants.java b/src/test/java/uk/gov/hmcts/reform/sscs/TestDataConstants.java index a1e19950d..085a1ff6d 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/TestDataConstants.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/TestDataConstants.java @@ -19,11 +19,19 @@ private TestDataConstants() { public static final String APPELLANT_ADDRESS_LINE3 = "Brentwood"; public static final String APPELLANT_ADDRESS_LINE4 = "Essex"; public static final String APPELLANT_POSTCODE = "CM13 1BA"; + public static final String APPELLANT_ADDRESS_COUNTRY = "Iceland"; + public static final String APPELLANT_PORT_OF_ENTRY = "some-port-of-entry"; public static final String APPELLANT_PHONE = "01234505050"; public static final String APPELLANT_MOBILE = "07929292929"; public static final String APPELLANT_EMAIL = "appellant@example.com"; public static final String APPELLANT_DATE_OF_BIRTH = "12/08/1987"; public static final String APPELLANT_NINO = "JT072319B"; + public static final String APPELLANT_IBCA_REFERENCE = "A12A12"; + public static final String APPELLANT_IBC_ROLE_FOR_SELF = "myself"; + public static final String APPELLANT_IBC_ROLE_FOR_U18 = "parent"; + public static final String APPELLANT_IBC_ROLE_FOR_LACKING_CAPACITY = "guardian"; + public static final String APPELLANT_IBC_ROLE_FOR_POA = "powerOfAttorney"; + public static final String APPELLANT_IBC_ROLE_FOR_DECEASED = "deceasedRepresentative"; public static final String APPOINTEE_TITLE = "Mrs"; public static final String APPOINTEE_FIRST_NAME = "Wendy"; public static final String APPOINTEE_LAST_NAME = "Baker"; @@ -77,4 +85,5 @@ private TestDataConstants() { public static final String EPIMMS_ID = "1"; public static final String REGION_ID = "100"; public static final String VENUE_POSTCODE = "CF24 0AB"; + public static final String SSCS8_FORM_TYPE = "sscs8"; } diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/bulkscancore/handlers/CcdCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/bulkscancore/handlers/CcdCallbackHandlerTest.java index 0bf01da3c..f4aea6698 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/bulkscancore/handlers/CcdCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/bulkscancore/handlers/CcdCallbackHandlerTest.java @@ -304,7 +304,7 @@ public void should_return_no_warnings_or_errors_or_data_when_validation_endpoint .build(); CaseResponse caseValidationResponse = CaseResponse.builder().build(); - when(caseValidator.validateValidationRecord(any(), anyBoolean())).thenReturn(caseValidationResponse); + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())).thenReturn(caseValidationResponse); when(appealPostcodeHelper.resolvePostCodeOrPort(appeal.getAppellant())).thenReturn("CV35 2TD"); when(caseManagementLocationService.retrieveCaseManagementLocation(PROCESSING_VENUE, rpc)).thenReturn( @@ -356,7 +356,7 @@ public void should_return_no_warnings_or_errors_or_data_when_validation_endpoint .build(); CaseResponse caseValidationResponse = CaseResponse.builder().build(); - when(caseValidator.validateValidationRecord(any(), anyBoolean())).thenReturn(caseValidationResponse); + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())).thenReturn(caseValidationResponse); PreSubmitCallbackResponse ccdCallbackResponse = invokeValidationCallbackHandler(caseDetails.getCaseData()); @@ -403,7 +403,7 @@ public void should_return_warnings_or_error_on_data_when_direction_issued_and_mr caseDetails.getCaseData().setDirectionTypeDl(appealToProccedDynamicList); CaseResponse caseValidationResponse = CaseResponse.builder().build(); - when(caseValidator.validateValidationRecord(any(), eq(true))).thenReturn(caseValidationResponse); + when(caseValidator.validateValidationRecord(any(), eq(true), anyBoolean())).thenReturn(caseValidationResponse); PreSubmitCallbackResponse ccdCallbackResponse = invokeValidationCallbackHandler(caseDetails.getCaseData(), EventType.DIRECTION_ISSUED); @@ -450,7 +450,7 @@ public void should_return_warnings_or_error_on_data_when_direction_issued_welsh_ caseDetails.getCaseData().setDirectionTypeDl(appealToProccedDynamicList); CaseResponse caseValidationResponse = CaseResponse.builder().build(); - when(caseValidator.validateValidationRecord(any(), eq(true))).thenReturn(caseValidationResponse); + when(caseValidator.validateValidationRecord(any(), eq(true), anyBoolean())).thenReturn(caseValidationResponse); PreSubmitCallbackResponse ccdCallbackResponse = invokeValidationCallbackHandler(caseDetails.getCaseData(), EventType.DIRECTION_ISSUED_WELSH); @@ -495,7 +495,7 @@ public void should_return_warnings_on_data_when_other_event_and_mrn_date_is_empt .build(); CaseResponse caseValidationResponse = CaseResponse.builder().warnings(Lists.list("Mrn date is empty")).build(); - when(caseValidator.validateValidationRecord(any(), eq(false))).thenReturn(caseValidationResponse); + when(caseValidator.validateValidationRecord(any(), eq(false), anyBoolean())).thenReturn(caseValidationResponse); PreSubmitCallbackResponse ccdCallbackResponse = invokeValidationCallbackHandler(caseDetails.getCaseData()); @@ -531,7 +531,7 @@ public void should_return_exc_data_and_errors_in_callback_when_validation_endpoi .caseId("123") .build(); - when(caseValidator.validateValidationRecord(any(), anyBoolean())) + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())) .thenReturn(CaseResponse.builder() .errors(ImmutableList.of("NI Number is invalid")) .build()); @@ -554,7 +554,7 @@ public void should_return_exc_data_and_errors_in_callback_when_validation_endpoi .caseId("123") .build(); - when(caseValidator.validateValidationRecord(any(), anyBoolean())) + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())) .thenReturn(CaseResponse.builder() .warnings(ImmutableList.of("Postcode is invalid")) .build()); @@ -578,7 +578,7 @@ public void should_return_error_for_invalid_benefitType(@Nullable String benefit .caseId("123") .build(); - when(caseValidator.validateValidationRecord(any(), anyBoolean())) + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())) .thenReturn(CaseResponse.builder() .errors(ImmutableList.of("Benefit type is invalid")) .build()); @@ -599,7 +599,7 @@ public void givenBlankBenefitTypeSscs1_shouldReturnUnknownCmc() { .caseId("123") .build(); - when(caseValidator.validateValidationRecord(any(), anyBoolean())) + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())) .thenReturn(CaseResponse.builder() .errors(ImmutableList.of("Benefit type is invalid")) .build()); @@ -619,7 +619,7 @@ public void givenBlankBenefitTypeSscs2_shouldReturnUnknownCmc() { .caseId("123") .build(); - when(caseValidator.validateValidationRecord(any(), anyBoolean())) + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())) .thenReturn(CaseResponse.builder() .errors(ImmutableList.of("Benefit type is invalid")) .build()); @@ -639,7 +639,7 @@ public void givenBlankBenefitTypeSscs5_shouldReturnUnknownCmc() { .caseId("123") .build(); - when(caseValidator.validateValidationRecord(any(), anyBoolean())) + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())) .thenReturn(CaseResponse.builder() .errors(ImmutableList.of("Benefit type is invalid")) .build()); @@ -650,6 +650,52 @@ public void givenBlankBenefitTypeSscs5_shouldReturnUnknownCmc() { assertEquals("SSCS5 Unknown", ccdCallbackResponse.getData().getCaseAccessManagementFields().getCaseManagementCategory().getValue().getLabel()); } + + @Test + public void should_pass_validateIbcRoleField_true_for_valid_appeal_event_sscs8_form() { + SscsCaseDetails caseDetails = SscsCaseDetails + .builder() + .caseData(SscsCaseData.builder().formType(FormType.SSCS8).build()) + .build(); + + CaseResponse caseValidationResponse = CaseResponse.builder().build(); + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())).thenReturn(caseValidationResponse); + + invokeValidationCallbackHandler(caseDetails.getCaseData()); + + verify(caseValidator).validateValidationRecord(any(), anyBoolean(), eq(true)); + } + + @Test + public void should_pass_validateIbcRoleField_false_for_non_valid_appeal_event_sscs8_form() { + SscsCaseDetails caseDetails = SscsCaseDetails + .builder() + .caseData(SscsCaseData.builder().formType(FormType.SSCS8).build()) + .build(); + + CaseResponse caseValidationResponse = CaseResponse.builder().build(); + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())).thenReturn(caseValidationResponse); + + invokeValidationCallbackHandler(caseDetails.getCaseData(), EventType.DIRECTION_ISSUED); + + verify(caseValidator).validateValidationRecord(any(), anyBoolean(), eq(false)); + } + + @Test + public void should_pass_validateIbcRoleField_false_for_valid_appeal_event_non_sscs8_form() { + SscsCaseDetails caseDetails = SscsCaseDetails + .builder() + .caseData(SscsCaseData.builder().formType(FormType.SSCS2).build()) + .build(); + + CaseResponse caseValidationResponse = CaseResponse.builder().build(); + when(caseValidator.validateValidationRecord(any(), anyBoolean(), anyBoolean())).thenReturn(caseValidationResponse); + + invokeValidationCallbackHandler(caseDetails.getCaseData()); + + verify(caseValidator).validateValidationRecord(any(), anyBoolean(), eq(false)); + } + private void assertLogContains(final String logMessage) { assertThat(listAppender.list.stream().map(ILoggingEvent::getFormattedMessage)).contains(logMessage); } diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/transformers/SscsCaseTransformerTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/transformers/SscsCaseTransformerTest.java index 5df13d7c6..e91a00443 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/transformers/SscsCaseTransformerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/transformers/SscsCaseTransformerTest.java @@ -92,7 +92,7 @@ public class SscsCaseTransformerTest { private final List ocrList = new ArrayList<>(); - private final Map pairs = new HashMap<>(); + private Map pairs; private ExceptionRecord exceptionRecord; @@ -106,7 +106,7 @@ public class SscsCaseTransformerTest { @Before public void setup() { openMocks(this); - + pairs = new HashMap<>(); DwpAddressLookupService dwpAddressLookupService = new DwpAddressLookupService(); formTypeValidator2 = new FormTypeValidator(sscsJsonExtractor); @@ -484,6 +484,7 @@ public void canHandleAddressWithoutAddressLine4(String personType) { .town("town") .county("county") .postcode(APPELLANT_POSTCODE) + .build(); for (String person : Arrays.asList("person1", personType)) { pairs.put(person + "_address_line1", expectedAddress.getLine1()); @@ -508,6 +509,7 @@ public void givenAddressLine3IsBlankAndAddressLine4IsNotPresent_thenAddressLine3 .town("town") .county(".") .postcode(APPELLANT_POSTCODE) + .build(); for (String person : Arrays.asList("person1", personType)) { pairs.remove(person + "_address_line4"); @@ -532,6 +534,7 @@ public void givenAddressLine3IsNullAndAddressLine4IsNotPresent_thenAddressLine3P .town("town") .county(".") .postcode(APPELLANT_POSTCODE) + .build(); for (String person : Arrays.asList("person1", personType)) { pairs.remove(person + "_address_line4"); @@ -556,6 +559,7 @@ public void givenAddressLine2And3AreNullAndAddressLine4IsNotPresent_thenAddressL .town(null) .county(null) .postcode(APPELLANT_POSTCODE) + .build(); for (String person : Arrays.asList("person1", personType)) { pairs.remove(person + "_address_line4"); @@ -581,6 +585,7 @@ public void givenAddressLine3IsBlankAndAddressLine4IsPresent_thenAddressLine3Not .town(null) .county("county") .postcode(APPELLANT_POSTCODE) + .build(); for (String person : Arrays.asList("person1", personType)) { pairs.put(person + "_address_line1", expectedAddress.getLine1()); @@ -713,6 +718,101 @@ public void givenKeyValuePairsWithPerson1AndPipBenefitType_thenBuildAnAppealWith assertTrue(result.getErrors().isEmpty()); } + @Test + public void givenSscs8IbcInUk_thenBuildAnAppealWithIbcRoleAndIbcaReference() { + pairs.put("person1_title", APPELLANT_TITLE); + pairs.put("person1_first_name", APPELLANT_FIRST_NAME); + pairs.put("person1_last_name", APPELLANT_LAST_NAME); + pairs.put("person1_address_line1", APPELLANT_ADDRESS_LINE1); + pairs.put("person1_address_line2", APPELLANT_ADDRESS_LINE2); + pairs.put("person1_address_line3", APPELLANT_ADDRESS_LINE3); + pairs.put("person1_address_line4", APPELLANT_ADDRESS_LINE4); + pairs.put("person1_Country", APPELLANT_ADDRESS_COUNTRY); + pairs.put("person1_postcode", APPELLANT_POSTCODE); + pairs.put("person1_phone", APPELLANT_PHONE); + pairs.put("person1_mobile", APPELLANT_MOBILE); + pairs.put("person1_dob", APPELLANT_DATE_OF_BIRTH); + pairs.put("person1_email", APPELLANT_EMAIL); + pairs.put(APPEAL_GROUNDS, APPEAL_REASON); + pairs.put("person1_ibca_reference", APPELLANT_IBCA_REFERENCE); + pairs.put(IBC_ROLE_FOR_SELF, true); + pairs.put("form_type", SSCS8_FORM_TYPE); + + CaseResponse result = transformer.transformExceptionRecord(exceptionRecord, false); + + assertEquals(SSCS8, result.getTransformedCase().get("formType")); + Appeal transformedAppeal = (Appeal) result.getTransformedCase().get("appeal"); + assertNotNull(transformedAppeal); + assertEquals(APPELLANT_IBC_ROLE_FOR_SELF, transformedAppeal.getAppellant().getIbcRole()); + assertEquals(APPELLANT_IBCA_REFERENCE, transformedAppeal.getAppellant().getIdentity().getIbcaReference()); + Address address = transformedAppeal.getAppellant().getAddress(); + assertNotNull(address); + Address expectedAddress = Address.builder().line1(APPELLANT_ADDRESS_LINE1).line2(APPELLANT_ADDRESS_LINE2).town(APPELLANT_ADDRESS_LINE3).county(APPELLANT_ADDRESS_LINE4).postcode(APPELLANT_POSTCODE).inMainlandUk(YesNo.YES).build(); + assertEquals(expectedAddress, address); + assertTrue(result.getErrors().isEmpty()); + } + + @Test + public void givenPortOfEntry_thenBuildAnAppealWithAddressWithCountryPortOfEntryWithoutCounty() { + pairs.put("person1_address_line1", APPELLANT_ADDRESS_LINE1); + pairs.put("person1_address_line2", APPELLANT_ADDRESS_LINE2); + pairs.put("person1_address_line3", APPELLANT_ADDRESS_LINE3); + pairs.put("person1_address_line4", APPELLANT_ADDRESS_LINE4); + pairs.put("person1_Country", APPELLANT_ADDRESS_COUNTRY); + pairs.put("person1_port_of_entry", APPELLANT_PORT_OF_ENTRY); + pairs.put("person1_postcode", APPELLANT_POSTCODE); + pairs.put("person1_ibca_reference", APPELLANT_IBCA_REFERENCE); + pairs.put(IBC_ROLE_FOR_SELF, true); + pairs.put("form_type", SSCS8_FORM_TYPE); + + CaseResponse result = transformer.transformExceptionRecord(exceptionRecord, false); + + assertEquals(SSCS8, result.getTransformedCase().get("formType")); + Appeal transformedAppeal = (Appeal) result.getTransformedCase().get("appeal"); + assertNotNull(transformedAppeal); + assertEquals(APPELLANT_IBC_ROLE_FOR_SELF, transformedAppeal.getAppellant().getIbcRole()); + assertEquals(APPELLANT_IBCA_REFERENCE, transformedAppeal.getAppellant().getIdentity().getIbcaReference()); + Address address = transformedAppeal.getAppellant().getAddress(); + assertNotNull(address); + Address expectedAddress = Address.builder().line1(APPELLANT_ADDRESS_LINE1).line2(APPELLANT_ADDRESS_LINE2).town(APPELLANT_ADDRESS_LINE3).country(APPELLANT_ADDRESS_COUNTRY).postcode(APPELLANT_POSTCODE).portOfEntry(APPELLANT_PORT_OF_ENTRY).inMainlandUk(YesNo.NO).build(); + assertEquals(expectedAddress, address); + assertTrue(result.getErrors().isEmpty()); + } + + @Test + @Parameters({ + IBC_ROLE_FOR_SELF + "," + APPELLANT_IBC_ROLE_FOR_SELF, + IBC_ROLE_FOR_U18 + "," + APPELLANT_IBC_ROLE_FOR_U18, + IBC_ROLE_FOR_DECEASED + "," + APPELLANT_IBC_ROLE_FOR_DECEASED, + IBC_ROLE_FOR_POA + "," + APPELLANT_IBC_ROLE_FOR_POA, + IBC_ROLE_FOR_LACKING_CAPACITY + "," + APPELLANT_IBC_ROLE_FOR_LACKING_CAPACITY + }) + public void givenChosenIbcRole_thenBuildAnAppealWithIbcRoleSet(String ibcRoleBoolean, String ibcRoleValue) { + pairs.put("person1_address_line1", APPELLANT_ADDRESS_LINE1); + pairs.put("person1_address_line2", APPELLANT_ADDRESS_LINE2); + pairs.put("person1_address_line3", APPELLANT_ADDRESS_LINE3); + pairs.put("person1_address_line4", APPELLANT_ADDRESS_LINE4); + pairs.put("person1_Country", APPELLANT_ADDRESS_COUNTRY); + pairs.put("person1_port_of_entry", APPELLANT_PORT_OF_ENTRY); + pairs.put("person1_postcode", APPELLANT_POSTCODE); + pairs.put("person1_ibca_reference", APPELLANT_IBCA_REFERENCE); + pairs.put(ibcRoleBoolean, true); + pairs.put("form_type", SSCS8_FORM_TYPE); + + CaseResponse result = transformer.transformExceptionRecord(exceptionRecord, false); + + assertEquals(SSCS8, result.getTransformedCase().get("formType")); + Appeal transformedAppeal = (Appeal) result.getTransformedCase().get("appeal"); + assertNotNull(transformedAppeal); + assertEquals(ibcRoleValue, transformedAppeal.getAppellant().getIbcRole()); + assertEquals(APPELLANT_IBCA_REFERENCE, transformedAppeal.getAppellant().getIdentity().getIbcaReference()); + Address address = transformedAppeal.getAppellant().getAddress(); + assertNotNull(address); + Address expectedAddress = Address.builder().line1(APPELLANT_ADDRESS_LINE1).line2(APPELLANT_ADDRESS_LINE2).town(APPELLANT_ADDRESS_LINE3).country(APPELLANT_ADDRESS_COUNTRY).postcode(APPELLANT_POSTCODE).portOfEntry(APPELLANT_PORT_OF_ENTRY).inMainlandUk(YesNo.NO).build(); + assertEquals(expectedAddress, address); + assertTrue(result.getErrors().isEmpty()); + } + @Test public void givenKeyValuePairsWithEsaBenefitType_thenBuildAnAppealWithAppellant() { @@ -2677,8 +2777,6 @@ public void givenNullFormAndWithSscs5FormTypeInput_thenDocumentUpdated() { checkFormTypeAndDocumentUpdated(null, "sscs5", "sscs5"); } - - private Appeal buildTestAppealData() { Name appellantName = Name.builder().title(APPELLANT_TITLE).firstName(APPELLANT_FIRST_NAME).lastName(APPELLANT_LAST_NAME).build(); Address appellantAddress = Address.builder().line1(APPELLANT_ADDRESS_LINE1).line2(APPELLANT_ADDRESS_LINE2).town(APPELLANT_ADDRESS_LINE3).county(APPELLANT_ADDRESS_LINE4).postcode(APPELLANT_POSTCODE).build(); diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/validators/SscsCaseValidatorTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/validators/SscsCaseValidatorTest.java index 1b666ab92..df2420e23 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/validators/SscsCaseValidatorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/validators/SscsCaseValidatorTest.java @@ -8,6 +8,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; import static uk.gov.hmcts.reform.sscs.TestDataConstants.CHILD_MAINTENANCE_NUMBER; import static uk.gov.hmcts.reform.sscs.TestDataConstants.OTHER_PARTY_ADDRESS_LINE1; @@ -427,13 +428,41 @@ public void givenAnAppellantIsEmpty_thenAddAWarning() { "benefit_type_description is empty"); } + @Test + public void givenAnAppellantIsEmptySscs8_thenAddAWarningForIbcaReference() { + Map ocrCaseDataEmptyOffice = new HashMap<>(); + ocrCaseDataEmptyOffice.put("person1_address_line4", "county"); + ocrCaseDataEmptyOffice.put("person2_address_line4", "county"); + ocrCaseDataEmptyOffice.put("representative_address_line4", "county"); + given(scannedData.getOcrCaseData()).willReturn(ocrCaseDataEmptyOffice); + Map pairs = new HashMap<>(); + BenefitType benefitType = BenefitType.builder().code(INFECTED_BLOOD_COMPENSATION.getShortName()).build(); + pairs.put("appeal", Appeal.builder().hearingType(HEARING_TYPE_ORAL).benefitType(benefitType).build()); + pairs.put("bulkScanCaseReference", 123); + pairs.put("formType", FormType.SSCS8); + + CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, pairs, false); + + assertThat(response.getWarnings()) + .containsOnly( + "person1_title is empty", + "person1_first_name is empty", + "person1_last_name is empty", + "person1_address_line1 is empty", + "person1_address_line3 is empty", + "person1_address_line4 is empty", + "person1_postcode is empty", + "person1_ibca_reference is empty", + "mrn_date is empty"); + } + @Test public void givenAnAppellantWithNoName_thenAddWarnings() { Map pairs = new HashMap<>(); pairs.put("appeal", Appeal.builder().appellant(Appellant.builder().address( - Address.builder().line1("123 The Road").town("Harlow").county("Essex").postcode(VALID_POSTCODE).build()) - .identity(Identity.builder().nino("BB000000B").build()).build()) + Address.builder().line1("123 The Road").town("Harlow").county("Essex").postcode(VALID_POSTCODE).build()) + .identity(Identity.builder().nino("BB000000B").build()).build()) .benefitType(BenefitType.builder().code(PIP.name()).build()) .mrnDetails(defaultMrnDetails) .hearingType(HEARING_TYPE_ORAL).build()); @@ -485,10 +514,10 @@ public void givenAnAppellantWithNoNameAndEmptyAppointeeDetails_thenAddWarnings() .build(); pairs.put("appeal", Appeal.builder().appellant(Appellant.builder() - .appointee(appointee) - .address( - Address.builder().line1("123 The Road").town("Harlow").county("Essex").postcode(VALID_POSTCODE).build()) - .identity(Identity.builder().nino("BB000000B").build()).build()) + .appointee(appointee) + .address( + Address.builder().line1("123 The Road").town("Harlow").county("Essex").postcode(VALID_POSTCODE).build()) + .identity(Identity.builder().nino("BB000000B").build()).build()) .benefitType(BenefitType.builder().code(PIP.name()).build()) .mrnDetails(defaultMrnDetails) .hearingType(HEARING_TYPE_ORAL).build()); @@ -508,8 +537,8 @@ public void givenAnAppellantWithNoAddress_thenAddWarnings() { Map pairs = new HashMap<>(); pairs.put("appeal", Appeal.builder().appellant(Appellant.builder().name( - Name.builder().firstName("Harry").lastName("Kane").build()) - .identity(Identity.builder().nino("BB000000B").build()).build()) + Name.builder().firstName("Harry").lastName("Kane").build()) + .identity(Identity.builder().nino("BB000000B").build()).build()) .benefitType(BenefitType.builder().code(PIP.name()).build()) .mrnDetails(defaultMrnDetails) .hearingType(HEARING_TYPE_ORAL) @@ -527,6 +556,53 @@ public void givenAnAppellantWithNoAddress_thenAddWarnings() { "person1_postcode is empty"); } + @Test + public void givenIbcCaseAppellantWithNoAddress_thenAddWarnings() { + Map pairs = new HashMap<>(); + pairs.put("appeal", Appeal.builder().appellant(Appellant.builder().name( + Name.builder().firstName("Harry").lastName("Kane").build()) + .identity(Identity.builder().ibcaReference("A12A21").build()) + .ibcRole("some-role").build()) + .benefitType(BenefitType.builder().code(INFECTED_BLOOD_COMPENSATION.getShortName()).build()) + .mrnDetails(defaultMrnDetails) + .hearingType(HEARING_TYPE_ORAL) + .hearingSubtype(HearingSubtype.builder().wantsHearingTypeFaceToFace("Yes").build()).build()); + pairs.put("bulkScanCaseReference", 123); + pairs.put("formType", FormType.SSCS8); + + CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, pairs, false); + + assertThat(response.getWarnings()) + .containsOnly( + "person1_address_line1 is empty", + "person1_address_line3 is empty", + "person1_address_line4 is empty", + "person1_postcode is empty"); + } + + @Test + public void givenIbcCaseAppellantWithPortOfEntry_thenNoWarningsForCountyPostcode() { + Map pairs = new HashMap<>(); + pairs.put("appeal", Appeal.builder().appellant(Appellant.builder().name( + Name.builder().firstName("Harry").lastName("Kane").build()) + .identity(Identity.builder().ibcaReference("A12A21").build()) + .ibcRole("some-role").address(Address.builder().portOfEntry("GBSTGTY00") + .build()).build()) + .benefitType(BenefitType.builder().code(INFECTED_BLOOD_COMPENSATION.getShortName()).build()) + .mrnDetails(defaultMrnDetails) + .hearingType(HEARING_TYPE_ORAL) + .hearingSubtype(HearingSubtype.builder().wantsHearingTypeFaceToFace("Yes").build()).build()); + pairs.put("bulkScanCaseReference", 123); + pairs.put("formType", FormType.SSCS8); + + CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, pairs, false); + + assertThat(response.getWarnings()) + .containsOnly( + "person1_address_line1 is empty", + "person1_address_line3 is empty"); + } + @Test public void givenAnAppellantDoesNotContainATitle_thenAddAWarning() { Appellant appellant = buildAppellant(false); @@ -785,12 +861,14 @@ public void givenAnAppellantDoesNotContainAPostcodeButNotInUk_thenLetItGoElsa() appellant.getAddress().setPostcode(null); appellant.getAddress().setInMainlandUk(YesNo.NO); appellant.getAddress().setPortOfEntry(PORT_OF_NORWICH_A_FINE_CITY); + appellant.getIdentity().setIbcaReference("A12A12"); + appellant.setIbcRole("some-role"); - var data = buildMinimumAppealDataWithBenefitType(INFECTED_BLOOD_COMPENSATION.getShortName(), appellant, true, FormType.SSCS5); + var data = buildMinimumAppealDataWithBenefitType(INFECTED_BLOOD_COMPENSATION.getShortName(), appellant, true, FormType.SSCS8); CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, data, false); assertEquals(0, response.getWarnings().size()); - verifyNoInteractions(regionalProcessingCenterService); + verify(regionalProcessingCenterService).getByPostcode(PORT_OF_NORWICH_A_FINE_CITY, true); } @Test @@ -860,6 +938,132 @@ public void givenAnAppellantDoesContainANino_thenDoNotAddAWarning() { assertEquals(0, response.getErrors().size()); } + @Test + public void givenSscs8DoesNotContainIbcaReference_thenAddAWarning() { + Appellant appellant = buildAppellant(false); + appellant.getIdentity().setIbcaReference(null); + appellant.setIbcRole("some-role"); + + CaseResponse response = validator + .validateExceptionRecord(transformResponse, exceptionRecord, buildMinimumAppealData(appellant, true, FormType.SSCS8), + false); + + assertEquals("person1_ibca_reference is empty", response.getWarnings().get(0)); + } + + @Test + public void givenSscs8DoesNotContainValidIbcaReference_thenAddAWarning() { + Appellant appellant = buildAppellant(false); + appellant.getIdentity().setIbcaReference("NOT VALID"); + appellant.setIbcRole("some-role"); + + CaseResponse response = validator + .validateExceptionRecord(transformResponse, exceptionRecord, buildMinimumAppealData(appellant, true, FormType.SSCS8), + false); + + assertEquals("person1_ibca_reference is invalid", response.getWarnings().get(0)); + } + + @Test + public void givenSscs8HasNoAppellantIbcRole_thenAddAnError() { + Appellant appellant = buildAppellant(false); + appellant.getIdentity().setIbcaReference("A12A12"); + + CaseResponse response = validator + .validateExceptionRecord(transformResponse, exceptionRecord, buildMinimumAppealData(appellant, true, FormType.SSCS8), + false); + + assertTrue(response.getErrors().contains("person1_as_rep_of_deceased: one role must be True")); + assertTrue(response.getErrors().contains("person1_on_behalf_of_a_person_who_lacks_capacity: one role must be True")); + assertTrue(response.getErrors().contains("person1_as_poa: one role must be True")); + assertTrue(response.getErrors().contains("person1_for_self: one role must be True")); + assertTrue(response.getErrors().contains("person1_for_person_under_18: one role must be True")); + } + + @Test + public void givenSscs8HasOneAppellantIbcRole_thenDoNotError() { + Appellant appellant = buildAppellant(false); + appellant.getIdentity().setIbcaReference("A12A12"); + ocrCaseData.put(IBC_ROLE_FOR_SELF, true); + + CaseResponse response = validator + .validateExceptionRecord(transformResponse, exceptionRecord, buildMinimumAppealData(appellant, true, FormType.SSCS8), + false); + + assertEquals(0, response.getErrors().size()); + } + + @Test + public void givenSscs8HasAllAppellantIbcRoles_thenAddErrors() { + ocrCaseData.put(IBC_ROLE_FOR_SELF, true); + ocrCaseData.put(IBC_ROLE_FOR_U18, true); + ocrCaseData.put(IBC_ROLE_FOR_DECEASED, true); + ocrCaseData.put(IBC_ROLE_FOR_POA, true); + ocrCaseData.put(IBC_ROLE_FOR_LACKING_CAPACITY, true); + Appellant appellant = buildAppellant(false); + appellant.getIdentity().setIbcaReference("A12A12"); + appellant.setIbcRole(null); + + CaseResponse response = validator + .validateExceptionRecord(transformResponse, exceptionRecord, buildMinimumAppealData(appellant, true, FormType.SSCS8), + false); + assertEquals(1, response.getErrors().size()); + String error = response.getErrors().get(0).replace(" cannot all be True", ""); + List errors = Arrays.asList(error.split(", ")); + assertTrue(errors.contains(IBC_ROLE_FOR_SELF)); + assertTrue(errors.contains(IBC_ROLE_FOR_U18)); + assertTrue(errors.contains(IBC_ROLE_FOR_LACKING_CAPACITY)); + assertTrue(errors.contains(IBC_ROLE_FOR_POA)); + assertTrue(errors.contains(IBC_ROLE_FOR_DECEASED)); + } + + @Test + public void givenSscs8HasMultipleAppellantIbcRoles_thenAddErrors() { + ocrCaseData.put(IBC_ROLE_FOR_SELF, true); + ocrCaseData.put(IBC_ROLE_FOR_U18, true); + ocrCaseData.put(IBC_ROLE_FOR_POA, true); + Appellant appellant = buildAppellant(false); + appellant.getIdentity().setIbcaReference("A12A12"); + appellant.setIbcRole(null); + + CaseResponse response = validator + .validateExceptionRecord(transformResponse, exceptionRecord, buildMinimumAppealData(appellant, true, FormType.SSCS8), + false); + + assertEquals(1, response.getErrors().size()); + String error = response.getErrors().get(0).replace(" cannot all be True", ""); + List errors = Arrays.asList(error.split(", ")); + assertTrue(errors.contains(IBC_ROLE_FOR_SELF)); + assertTrue(errors.contains(IBC_ROLE_FOR_U18)); + assertTrue(errors.contains(IBC_ROLE_FOR_POA)); + } + + @Test + public void givenSscs8HasIbcRoleFieldTrueAndSet_thenDoNotError() { + Appellant appellant = buildAppellant(false); + appellant.getIdentity().setIbcaReference("A12A12"); + appellant.setIbcRole("myself"); + + CaseResponse response = validator + .validateValidationRecord(buildMinimumAppealData(appellant, true, FormType.SSCS8), + false, true); + + assertEquals(0, response.getErrors().size()); + } + + @Test + public void givenSscs8HasIbcRoleFieldTrueAndNotSet_thenError() { + Appellant appellant = buildAppellant(false); + appellant.getIdentity().setIbcaReference("A12A12"); + appellant.setIbcRole(null); + + CaseResponse response = validator + .validateValidationRecord(buildMinimumAppealData(appellant, true, FormType.SSCS8), + false, true); + + assertEquals(Collections.singletonList("ibcRole is empty"), response.getErrors()); + } + @Test public void givenAnAppointeeExistsAndAnAppellantDoesNotContainANino_thenAddAWarningAboutPerson2() { Appellant appellant = buildAppellant(true); @@ -1254,14 +1458,15 @@ public void givenAnAppealContainsAnValidPostcodeFormatButFound_thenNoErrorOrWarn @Test public void givenAnIbcAppealContainsAnValidPostcodeFormatButFound_thenNoErrorOrWarnings() { + ocrCaseData.put(IBC_ROLE_FOR_SELF, true); given(postcodeValidator.isValidPostcodeFormat(anyString())).willReturn(true); given(postcodeValidator.isValid(anyString())).willReturn(true); - given(regionalProcessingCenterService.getByPostcode(anyString(), eq(true))).willReturn(RegionalProcessingCenter.builder().address1("Address 1").name("Liverpool").build()); - CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, buildMinimumAppealDataWithBenefitType(INFECTED_BLOOD_COMPENSATION.getShortName(), buildAppellantWithPostcode("W1 1LA"), true, FormType.SSCS1PE), false); + CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, buildMinimumAppealDataWithBenefitType(INFECTED_BLOOD_COMPENSATION.getShortName(), buildAppellantWithPostcode("W1 1LA"), true, FormType.SSCS8), false); assertThat(response.getWarnings().size()).isEqualTo(0); assertThat(response.getErrors().size()).isEqualTo(0); + ocrCaseData.remove(IBC_ROLE_FOR_SELF); } @Test @@ -1568,7 +1773,7 @@ public void givenAllMandatoryFieldsAndValidDocumentDoNotAddAnError() { pairs.put("sscsDocument", buildDocument("myfile.pdf")); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals(0, response.getErrors().size()); } @@ -1579,7 +1784,7 @@ public void givenAllMandatoryFieldsAndDocumentNameIsNullAddAnError() { pairs.put("sscsDocument", buildDocument(null)); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals( "There is a file attached to the case that does not have a filename, add a filename, e.g. filename.pdf", @@ -1592,7 +1797,7 @@ public void givenAllMandatoryFieldsAndDocumentNameNoExtensionAddAnError() { pairs.put("sscsDocument", buildDocument("Waiver")); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals( "There is a file attached to the case called Waiver, filenames must have extension, e.g. filename.pdf", @@ -1605,7 +1810,7 @@ public void givenAValidationCallbackTypeWithIncompleteDetails_thenAddAWarningWit Appellant appellant = buildAppellant(false); appellant.getAddress().setPostcode(null); - CaseResponse response = validator.validateValidationRecord(buildMinimumAppealData(appellant, false, FormType.SSCS1PE), false); + CaseResponse response = validator.validateValidationRecord(buildMinimumAppealData(appellant, false, FormType.SSCS1PE), false, false); assertEquals("Appellant postcode is empty", response.getWarnings().get(0)); verifyNoInteractions(regionalProcessingCenterService); @@ -1618,7 +1823,7 @@ public void givenAValidationCallbackEventIsAppealToProceedAndMrnDateIsEmpty_then buildMinimumAppealDataWithMrn(MrnDetails.builder().dwpIssuingOffice("Sheffield DRT").build(), buildAppellant(false), false, FormType.SSCS1PE); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals(0, response.getWarnings().size()); assertEquals(0, response.getErrors().size()); @@ -1631,7 +1836,7 @@ public void givenAValidationCallbackEventIsOtherAndMrnDateIsEmpty_thenNoWarningO buildMinimumAppealDataWithMrn(MrnDetails.builder().dwpIssuingOffice("Sheffield DRT").build(), buildAppellant(false), false, FormType.SSCS1PE); - CaseResponse response = validator.validateValidationRecord(pairs, false); + CaseResponse response = validator.validateValidationRecord(pairs, false, false); assertEquals("Mrn date is empty", response.getWarnings().get(0)); } @@ -1676,7 +1881,7 @@ public void givenAnAppealWithAnInvalidHearingPhoneNumberForSscsCase_thenAddWarni HearingSubtype.builder().wantsHearingTypeTelephone("Yes").hearingTelephoneNumber("01222").build(), buildAppellant(false), false, FormType.SSCS1PE); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals( "Telephone hearing selected but the number used is invalid. Please check either the telephone or hearing telephone number fields", @@ -1703,7 +1908,7 @@ public void givenAnAppealWithAHearingTypeTelephoneSelectedButNoTelephoneEnteredF HearingSubtype.builder().wantsHearingTypeTelephone("Yes").hearingTelephoneNumber(null).build(), buildAppellant(false), false, FormType.SSCS1PE); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals("Hearing telephone number has not been provided but data indicates hearing telephone is required", response.getWarnings().get(0)); @@ -1729,7 +1934,7 @@ public void givenAnAppealWithAHearingTypeVideoSelectedButNoVideoEmailEnteredForS HearingSubtype.builder().wantsHearingTypeVideo("Yes").hearingVideoEmail(null).build(), buildAppellant(false), false, FormType.SSCS1PE); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals("Hearing video email address has not been provided but data indicates hearing video is required", response.getWarnings().get(0)); @@ -1740,7 +1945,7 @@ public void givenAnAppealWithAHearingTypeVideoSelectedButNoVideoEmailEnteredForS public void givenAnAppealWithAnHearingTypePaperAndEmptyHearingSubTypeForSscsCase_thenNoWarning() { Map pairs = buildMinimumAppealDataWithHearingType(HEARING_TYPE_PAPER, buildAppellant(false), false, FormType.SSCS1PE); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals(0, response.getWarnings().size()); } @@ -1753,7 +1958,7 @@ public void givenAnAppealWithAnEmptyHearingSubTypeAndFormTypeIsSscs1peuForSscsCa pairs.put("childMaintenanceNumber", "123456"); } pairs.put("formType", formType); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals(1, response.getWarnings().size()); assertEquals("Hearing option telephone, video and face to face are empty. At least one must be populated", response.getWarnings().get(0)); @@ -1763,7 +1968,7 @@ public void givenAnAppealWithAnEmptyHearingSubTypeAndFormTypeIsSscs1peuForSscsCa public void givenAnAppealWithAnEmptyHearingSubTypeForSscsCase_thenNoWarning() { Map pairs = buildMinimumAppealDataWithHearingSubtype(HearingSubtype.builder().build(), buildAppellant(false), false, FormType.SSCS1PE); pairs.put("formType", FormType.SSCS1); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals(0, response.getWarnings().size()); } @@ -1772,7 +1977,7 @@ public void givenAnAppealWithAnEmptyHearingSubTypeAndFormTypIsNullForSscsCase_th Map pairs = buildMinimumAppealDataWithHearingSubtype(HearingSubtype.builder().build(), buildAppellant(false), false, FormType.SSCS1PE); pairs.put("formType", null); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals(0, response.getWarnings().size()); } @@ -1781,7 +1986,7 @@ public void givenAnAppealWithAnHearingSubTypeVideoForSscsCase_thenNoWarning() { Map pairs = buildMinimumAppealDataWithHearingSubtype( HearingSubtype.builder().wantsHearingTypeVideo("Yes").hearingVideoEmail("m@m.com").build(), buildAppellant(false), false, FormType.SSCS1PE); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals(0, response.getWarnings().size()); } @@ -1790,7 +1995,7 @@ public void givenAnAppealWithAnHearingSubTypeFaceForSscsCase_thenNoWarning() { Map pairs = buildMinimumAppealDataWithHearingSubtype(HearingSubtype.builder().wantsHearingTypeFaceToFace("Yes").build(), buildAppellant(false), false, FormType.SSCS1PE); - CaseResponse response = validator.validateValidationRecord(pairs, true); + CaseResponse response = validator.validateValidationRecord(pairs, true, false); assertEquals(0, response.getWarnings().size()); } @@ -1812,7 +2017,7 @@ public void givenSscs2FormWithoutChildMaintenance_thenAddAWarning() { public void givenSscs2FormWithChildMaintenance_thenAppellantShouldReturnValue() { CaseResponse response = validator.validateExceptionRecord(transformResponse, - exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER,OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, buildOtherPartyName()), false); + exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER, OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, buildOtherPartyName()), false); assertEquals(0, response.getWarnings().size()); assertEquals(CHILD_MAINTENANCE_NUMBER, response.getTransformedCase().get("childMaintenanceNumber")); @@ -1829,7 +2034,7 @@ public void givenSscs2FormWithoutOtherPartyAddressEntryAndIgnoreWarningsFalse_th CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, - buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER,line1, line2,line3, postcode, buildOtherPartyName()), + buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER, line1, line2, line3, postcode, buildOtherPartyName()), false); assertFalse(response.getWarnings().isEmpty()); @@ -1841,7 +2046,7 @@ public void givenSscs2FormWithoutOtherPartyAddressEntryAndIgnoreWarningsFalse_th public void givenOtherParty_WithFirstNameLastNamePopulated_WithNoAddress_noWarnings() { CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, - buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER,"", "","", "", buildOtherPartyName()), + buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER, "", "", "", "", buildOtherPartyName()), false); assertTrue(response.getWarnings().isEmpty()); } @@ -1850,7 +2055,7 @@ public void givenOtherParty_WithFirstNameLastNamePopulated_WithNoAddress_noWarni public void givenOtherParty_WithNoName_WithNoAddress_noWarnings() { CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, - buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER,"", "","", "", Name.builder().build()), + buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER, "", "", "", "", Name.builder().build()), false); assertTrue(response.getWarnings().isEmpty()); } @@ -1859,7 +2064,7 @@ public void givenOtherParty_WithNoName_WithNoAddress_noWarnings() { public void givenOtherParty_NoName_WithAddressPresent_WarningSeen() { CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, - buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER,"line1", "","line3", "W1", Name.builder().build()), + buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER, "line1", "", "line3", "W1", Name.builder().build()), false); assertFalse(response.getWarnings().isEmpty()); } @@ -1870,7 +2075,7 @@ public void givenOtherParty_WithFirstNameOrLastNameMissing_WarningSeen(boolean i Name name = Name.builder().firstName(isFirstnameBlank ? "" : "fn").lastName(!isFirstnameBlank ? "" : "ln").build(); CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, - buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER,"line1", "line2","line3", "W1", name), + buildCaseWithChildMaintenanceWithOtherPartyNameAddress(CHILD_MAINTENANCE_NUMBER, "line1", "line2", "line3", "W1", name), false); assertFalse(response.getWarnings().isEmpty()); assertEquals(1, response.getWarnings().size()); @@ -1882,7 +2087,7 @@ public void givenSscs2FormWithOtherPartyAddressEntry_thenValueIsSet() { CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecord, buildCaseWithChildMaintenanceWithOtherPartyNameAddress( - CHILD_MAINTENANCE_NUMBER,OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, buildOtherPartyName()), + CHILD_MAINTENANCE_NUMBER, OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, buildOtherPartyName()), false); assertTrue(response.getWarnings().isEmpty()); @@ -1896,7 +2101,7 @@ public void givenSscs2FormWithOtherPartyLastNameMissingAndIgnoreWarningsFalse_th otherPartyName.setLastName(null); CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress( - CHILD_MAINTENANCE_NUMBER,OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), + CHILD_MAINTENANCE_NUMBER, OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), false); assertEquals(1, response.getWarnings().size()); @@ -1909,7 +2114,7 @@ public void givenSscs2FormWithOtherPartyFirstNameMissingAndIgnoreWarningsFalse_t otherPartyName.setFirstName(null); CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress( - CHILD_MAINTENANCE_NUMBER,OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), + CHILD_MAINTENANCE_NUMBER, OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), false); assertEquals(1, response.getWarnings().size()); @@ -1922,7 +2127,7 @@ public void givenSscs2FormWithOtherPartyTitleInvalidAndIgnoreWarningsFalse_thenO otherPartyName.setTitle("Random"); CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress( - CHILD_MAINTENANCE_NUMBER,OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), + CHILD_MAINTENANCE_NUMBER, OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), false); assertEquals(1, response.getWarnings().size()); @@ -1940,7 +2145,7 @@ public void givenSscs2FormWithOtherPartyLastNameMissingAndIgnoreWarningsTrue_the CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress( - CHILD_MAINTENANCE_NUMBER,OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,null, OTHER_PARTY_POSTCODE, otherPartyName), + CHILD_MAINTENANCE_NUMBER, OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, null, OTHER_PARTY_POSTCODE, otherPartyName), false); assertEquals(0, response.getWarnings().size()); @@ -1956,7 +2161,7 @@ public void givenSscs2FormWithChildMaintenanceNumberMissingAndIgnoreWarningsTrue CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress(null, - OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,null, OTHER_PARTY_POSTCODE, + OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, null, OTHER_PARTY_POSTCODE, buildOtherPartyName()), false); assertEquals(0, response.getWarnings().size()); @@ -1972,7 +2177,7 @@ public void givenSscs2FormWithChildMaintenanceNumberMissingAndIgnoreWarningsFals CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress(null, - OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,null, OTHER_PARTY_POSTCODE, + OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, null, OTHER_PARTY_POSTCODE, buildOtherPartyName()), false); assertEquals(1, response.getWarnings().size()); @@ -1991,7 +2196,7 @@ public void givenSscs2FormWithOtherPartyFirstNameMissingAndIgnoreWarningsTrue_th CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress( - CHILD_MAINTENANCE_NUMBER,OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), + CHILD_MAINTENANCE_NUMBER, OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), false); assertEquals(0, response.getWarnings().size()); @@ -2010,7 +2215,7 @@ public void givenSscs2FormWithOtherPartyTitleInvalidAndIgnoreWarningsTrue_thenNo CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress( - CHILD_MAINTENANCE_NUMBER,OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), + CHILD_MAINTENANCE_NUMBER, OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), false); assertEquals(0, response.getWarnings().size()); @@ -2031,7 +2236,7 @@ public void givenSscs2FormWithValidOtherPartyAndIgnoreWarningsTrue_thenNoWarning CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress( - CHILD_MAINTENANCE_NUMBER,OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2,OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), + CHILD_MAINTENANCE_NUMBER, OTHER_PARTY_ADDRESS_LINE1, OTHER_PARTY_ADDRESS_LINE2, OTHER_PARTY_ADDRESS_LINE3, OTHER_PARTY_POSTCODE, otherPartyName), false); assertEquals(0, response.getWarnings().size()); @@ -2051,7 +2256,7 @@ public void givenSscs2FormWithOtherPartyAddressFieldMissingAndIgnoreWarningsTrue CaseResponse response = validator.validateExceptionRecord(transformResponse, exceptionRecordSscs2, buildCaseWithChildMaintenanceWithOtherPartyNameAddress( - CHILD_MAINTENANCE_NUMBER,line1, line2, line3, postcode, buildOtherPartyName()), + CHILD_MAINTENANCE_NUMBER, line1, line2, line3, postcode, buildOtherPartyName()), false); assertEquals(0, response.getWarnings().size()); @@ -2205,9 +2410,10 @@ private Appellant buildAppellantWithMobileNumberAndPostcode(Boolean withAppointe .name(Name.builder().title("Mr").firstName("Bob").lastName("Smith").build()) .address( Address.builder().line1("101 My Road").town("Brentwood").county("Essex").postcode(postcode).build()) - .identity(Identity.builder().nino("BB000000B").build()) + .identity(Identity.builder().nino("BB000000B").ibcaReference("A12A12").build()) .contact(Contact.builder().mobile(mobileNumber).build()) .appointee(appointee) + .ibcRole("myself") .role(Role.builder().name("Paying parent").build()).build(); } @@ -2224,15 +2430,15 @@ private Map buildCaseWithChildMaintenanceWithOtherPartyNameAddre FormType.SSCS2); datamap.put("childMaintenanceNumber", childMaintenanceNumber); datamap.put("otherParties", Collections.singletonList(CcdValue.builder().value( - OtherParty.builder() - .name(otherPartyName) - .address(Address.builder() - .line1(line1) - .town(line2) - .county((line3 != null && !line3.equals("")) ? "." : line3) - .postcode(postcode) + OtherParty.builder() + .name(otherPartyName) + .address(Address.builder() + .line1(line1) + .town(line2) + .county((line3 != null && !line3.equals("")) ? "." : line3) + .postcode(postcode) + .build()) .build()) - .build()) .build())); return datamap; }