From 15f4f54439ca49380e090004f6e13bcb0f76117f Mon Sep 17 00:00:00 2001 From: Nilay Date: Thu, 12 Dec 2024 15:50:36 +0000 Subject: [PATCH] SSCSCI-1356 fixing draft appeals for IBC (#4177) * SSCSCI-1356 fixing draft appeals for IBC * SSCSCI-1356 pointing to PR * sonar fixes * checkstyle fix * sya flag on * Update values.preview.template.yaml --- .../model/draft/SessionAppellantIbcRole.java | 8 + .../draft/SessionAppellantIbcaReference.java | 8 + .../model/draft/SessionContactDetails.java | 2 + .../reform/sscs/model/draft/SessionDraft.java | 18 + .../sscs/model/draft/SessionInMainlandUk.java | 8 + .../draft/SessionRepresentativeDetails.java | 1 + .../ConvertSscsCaseDataIntoSessionDraft.java | 61 ++- .../controller/AbstractSyaControllerTest.java | 7 + .../sscs/model/draft/SessionDraftTest.java | 211 +++++++++ ...nvertSscsCaseDataIntoSessionDraftTest.java | 412 ++++++++++++++---- .../util/SerializeJsonMessageManager.java | 4 + .../session-sample-ibc-international.json | 57 +++ .../session-sample-ibc-rep-international.json | 73 ++++ .../drafts/session-sample-ibc-rep.json | 73 ++++ .../resources/drafts/session-sample-ibc.json | 56 +++ 15 files changed, 899 insertions(+), 100 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionAppellantIbcRole.java create mode 100644 src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionAppellantIbcaReference.java create mode 100644 src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionInMainlandUk.java create mode 100644 src/test/resources/drafts/session-sample-ibc-international.json create mode 100644 src/test/resources/drafts/session-sample-ibc-rep-international.json create mode 100644 src/test/resources/drafts/session-sample-ibc-rep.json create mode 100644 src/test/resources/drafts/session-sample-ibc.json diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionAppellantIbcRole.java b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionAppellantIbcRole.java new file mode 100644 index 00000000000..0e7a8713dc2 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionAppellantIbcRole.java @@ -0,0 +1,8 @@ +package uk.gov.hmcts.reform.sscs.model.draft; + +import lombok.Value; + +@Value +public class SessionAppellantIbcRole { + String ibcRole; +} diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionAppellantIbcaReference.java b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionAppellantIbcaReference.java new file mode 100644 index 00000000000..556704a4117 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionAppellantIbcaReference.java @@ -0,0 +1,8 @@ +package uk.gov.hmcts.reform.sscs.model.draft; + +import lombok.Value; + +@Value +public class SessionAppellantIbcaReference { + String ibcaReference; +} diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionContactDetails.java b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionContactDetails.java index 5a380f88ca9..7bf4819c014 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionContactDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionContactDetails.java @@ -10,7 +10,9 @@ public class SessionContactDetails { private String addressLine2; private String townCity; private String county; + private String country; private String postCode; + private String portOfEntry; private String phoneNumber; private String emailAddress; private String postcodeLookup; diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionDraft.java b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionDraft.java index cb2fe43dcc8..48f8619d57b 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionDraft.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionDraft.java @@ -66,9 +66,21 @@ public class SessionDraft { @JsonProperty("AppellantNINO") SessionAppellantNino appellantNino; + @JsonProperty("AppellantIBCAReference") + SessionAppellantIbcaReference appellantIbcaReference; + + @JsonProperty("AppellantRole") + SessionAppellantIbcRole appellantIbcRole; + + @JsonProperty("AppellantInMainlandUk") + SessionInMainlandUk appellantInMainlandUk; + @JsonProperty("AppellantContactDetails") SessionContactDetails appellantContactDetails; + @JsonProperty("AppellantInternationalContactDetails") + SessionContactDetails appellantInternationalContactDetails; + @JsonProperty("SameAddress") SessionSameAddress sameAddress; @@ -87,6 +99,12 @@ public class SessionDraft { @JsonProperty("Representative") SessionRepresentative representative; + @JsonProperty("RepresentativeInMainlandUk") + SessionInMainlandUk representativeInMainlandUk; + + @JsonProperty("RepresentativeInternationalDetails") + SessionRepresentativeDetails representativeInternationalDetails; + @JsonProperty("RepresentativeDetails") SessionRepresentativeDetails representativeDetails; diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionInMainlandUk.java b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionInMainlandUk.java new file mode 100644 index 00000000000..39b93699d00 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionInMainlandUk.java @@ -0,0 +1,8 @@ +package uk.gov.hmcts.reform.sscs.model.draft; + +import lombok.Value; + +@Value +public class SessionInMainlandUk { + String inMainlandUk; +} diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionRepresentativeDetails.java b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionRepresentativeDetails.java index 7965ab82ab6..eef936fe248 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionRepresentativeDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/model/draft/SessionRepresentativeDetails.java @@ -11,6 +11,7 @@ public class SessionRepresentativeDetails { private String addressLine2; private String townCity; private String county; + private String country; private String postCode; private String phoneNumber; private String emailAddress; diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/service/converter/ConvertSscsCaseDataIntoSessionDraft.java b/src/main/java/uk/gov/hmcts/reform/sscs/service/converter/ConvertSscsCaseDataIntoSessionDraft.java index 60e5b49b992..8525e68c16e 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/service/converter/ConvertSscsCaseDataIntoSessionDraft.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/service/converter/ConvertSscsCaseDataIntoSessionDraft.java @@ -45,19 +45,25 @@ public SessionDraft convert(SscsCaseData caseData) { .dwpIssuingOfficeEsa(buildDwpIssuingOfficeEsa(appeal)) .appointeeName(buildName(getAppointeeName(appeal))) .appointeeDob(buildDob(getAppointeeIdentity(appeal))) - .appointeeContactDetails(buildContactDetails(getAppointeeAddress(appeal), getAppointeeContact(appeal))) + .appointeeContactDetails(buildContactDetails(getAppointeeAddress(appeal), getAppointeeContact(appeal), YesNo.NO)) .appointee(buildAppointee(appeal)) .appellantName(buildName(getAppellantName(appeal))) .appellantDob(buildDob(getAppellantIdentity(appeal))) .appellantNino(buildAppellantNino(appeal)) - .appellantContactDetails(buildContactDetails(getAppellantAddress(appeal), getAppellantContact(appeal))) + .appellantIbcaReference(getAppellantIbcaReference(appeal)) + .appellantIbcRole(getAppellantIbcRole(appeal)) + .appellantInMainlandUk(getAppellantInMainlandUk(appeal)) + .appellantContactDetails(buildContactDetails(getAppellantAddress(appeal), getAppellantContact(appeal), YesNo.NO)) + .appellantInternationalContactDetails(buildContactDetails(getAppellantAddress(appeal), getAppellantContact(appeal), YesNo.YES)) .sameAddress(buildSameAddress(appeal)) .textReminders(buildTextReminders(caseData.getSubscriptions())) .sendToNumber(buildSendToNumber(caseData)) .enterMobile(buildEnterMobile(caseData)) .smsConfirmation(buildSmsConfirmation(caseData)) .representative(buildRepresentative(appeal)) - .representativeDetails(buildRepresentativeDetails(appeal)) + .representativeInMainlandUk(getRepresentativeInMainlandUk(appeal)) + .representativeDetails(buildRepresentativeDetails(appeal, YesNo.NO)) + .representativeInternationalDetails(buildRepresentativeDetails(appeal, YesNo.YES)) .reasonForAppealing(buildReasonForAppealing(appeal)) .otherReasonForAppealing(buildOtherReasonForAppealing(appeal)) .evidenceProvide(buildEvidenceProvide(caseData.getEvidencePresent())) @@ -287,7 +293,15 @@ private SessionRepresentative buildRepresentative(Appeal appeal) { return new SessionRepresentative(StringUtils.lowerCase(appeal.getRep().getHasRepresentative())); } - private SessionRepresentativeDetails buildRepresentativeDetails(Appeal appeal) { + private SessionInMainlandUk getRepresentativeInMainlandUk(Appeal appeal) { + if (!hasRep(appeal) || appeal.getRep().getAddress() == null || appeal.getRep().getAddress().getInMainlandUk() == null) { + return null; + } + + return new SessionInMainlandUk(appeal.getRep().getAddress().getInMainlandUk().getValue().toLowerCase()); + } + + private SessionRepresentativeDetails buildRepresentativeDetails(Appeal appeal, YesNo international) { SessionRepresentative sessionRepresentative = buildRepresentative(appeal); if (!hasRep(appeal) || sessionRepresentative == null @@ -307,12 +321,16 @@ private SessionRepresentativeDetails buildRepresentativeDetails(Appeal appeal) { boolean hasAddress = appeal.getRep().getAddress() != null; boolean hasContact = appeal.getRep().getContact() != null; + if (hasAddress && international.equals(appeal.getRep().getAddress().getInMainlandUk())) { + return null; + } return new SessionRepresentativeDetails( repName, hasAddress ? appeal.getRep().getAddress().getLine1() : null, hasAddress ? appeal.getRep().getAddress().getLine2() : null, hasAddress ? appeal.getRep().getAddress().getTown() : null, hasAddress ? appeal.getRep().getAddress().getCounty() : null, + hasAddress ? appeal.getRep().getAddress().getCountry() : null, hasAddress ? appeal.getRep().getAddress().getPostcode() : null, hasContact ? appeal.getRep().getContact().getMobile() : null, hasContact ? appeal.getRep().getContact().getEmail() : null, @@ -512,6 +530,35 @@ private SessionAppellantNino buildAppellantNino(Appeal appeal) { return new SessionAppellantNino(appeal.getAppellant().getIdentity().getNino()); } + private SessionAppellantIbcaReference getAppellantIbcaReference(Appeal appeal) { + if (appeal.getAppellant() == null + || appeal.getAppellant().getIdentity() == null + || appeal.getAppellant().getIdentity().getIbcaReference() == null) { + return null; + } + + return new SessionAppellantIbcaReference(appeal.getAppellant().getIdentity().getIbcaReference()); + } + + private SessionAppellantIbcRole getAppellantIbcRole(Appeal appeal) { + if (appeal.getAppellant() == null + || appeal.getAppellant().getIbcRole() == null) { + return null; + } + + return new SessionAppellantIbcRole(appeal.getAppellant().getIbcRole()); + } + + private SessionInMainlandUk getAppellantInMainlandUk(Appeal appeal) { + if (appeal.getAppellant() == null + || appeal.getAppellant().getAddress() == null + || appeal.getAppellant().getAddress().getInMainlandUk() == null) { + return null; + } + + return new SessionInMainlandUk(appeal.getAppellant().getAddress().getInMainlandUk().getValue().toLowerCase()); + } + private Address getAppellantAddress(Appeal appeal) { if (appeal.getAppellant() == null) { return null; @@ -544,8 +591,8 @@ private Contact getAppointeeContact(Appeal appeal) { return appeal.getAppellant().getAppointee().getContact(); } - private SessionContactDetails buildContactDetails(Address address, Contact contact) { - if (address == null || address.getLine1() == null) { + private SessionContactDetails buildContactDetails(Address address, Contact contact, YesNo international) { + if (address == null || address.getLine1() == null || international.equals(address.getInMainlandUk())) { return null; } return new SessionContactDetails( @@ -553,7 +600,9 @@ private SessionContactDetails buildContactDetails(Address address, Contact conta address.getLine2(), address.getTown(), address.getCounty(), + address.getCountry(), address.getPostcode(), + address.getPortOfEntry(), contact.getMobile(), contact.getEmail(), StringUtils.isEmpty(address.getPostcodeLookup()) ? null : address.getPostcodeLookup(), diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/controller/AbstractSyaControllerTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/controller/AbstractSyaControllerTest.java index bcb465a9c94..7ea4aca1c70 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/controller/AbstractSyaControllerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/controller/AbstractSyaControllerTest.java @@ -387,7 +387,9 @@ public void givenGetDraftIsCalled_shouldReturn200AndTheDraft() throws Exception "line2", "town-city", "county", + null, "AP1 4NT", + null, "07000000000", "appellant@test.com", null, @@ -478,7 +480,9 @@ public void givenGetDraftWithRepIsCalled_shouldReturn200AndTheDraft() throws Exc "line2", "town-city", "county", + null, "AP1 4NT", + null, "07000000000", "appellant@test.com", null, @@ -500,6 +504,7 @@ public void givenGetDraftWithRepIsCalled_shouldReturn200AndTheDraft() throws Exc "rep-line2", "rep-town-city", "rep-county", + null, "RE7 7ES", "07222222222", "representative@test.com", @@ -576,7 +581,9 @@ public void givenGetDraftWithAppointeeIsCalled_shouldReturn200AndTheDraft() thro "tee-line2", "tee-town-city", "tee-county", + null, "AP1 33T", + null, "07111111111", "appointee@test.com", null, diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/model/draft/SessionDraftTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/model/draft/SessionDraftTest.java index a929d756f63..dff6451366b 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/model/draft/SessionDraftTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/model/draft/SessionDraftTest.java @@ -3,6 +3,10 @@ import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson; import static uk.gov.hmcts.reform.sscs.util.SerializeJsonMessageManager.SESSION_SAMPLE; import static uk.gov.hmcts.reform.sscs.util.SerializeJsonMessageManager.SESSION_SAMPLE_ESA; +import static uk.gov.hmcts.reform.sscs.util.SerializeJsonMessageManager.SESSION_SAMPLE_IBC; +import static uk.gov.hmcts.reform.sscs.util.SerializeJsonMessageManager.SESSION_SAMPLE_IBC_INTERNATIONAL; +import static uk.gov.hmcts.reform.sscs.util.SerializeJsonMessageManager.SESSION_SAMPLE_IBC_REP; +import static uk.gov.hmcts.reform.sscs.util.SerializeJsonMessageManager.SESSION_SAMPLE_IBC_REP_INTERNATIONAL; import static uk.gov.hmcts.reform.sscs.util.SerializeJsonMessageManager.SESSION_SAMPLE_WITH_APPOINTEE; import static uk.gov.hmcts.reform.sscs.util.SerializeJsonMessageManager.SESSION_SAMPLE_WITH_APPOINTEE_AT_SAME_ADDRESS; import static uk.gov.hmcts.reform.sscs.util.SerializeJsonMessageManager.SESSION_SAMPLE_WITH_DATES_CANT_ATTEND; @@ -15,6 +19,7 @@ import org.junit.Test; public class SessionDraftTest { + @Test public void shouldSerializeSessionDraftAsExpected() { SessionDraft sessionDraft = SessionDraft.builder() @@ -36,7 +41,9 @@ public void shouldSerializeSessionDraftAsExpected() { null, "Appellant-town", "Appellant-county", + null, "TS1 1ST", + null, "07911123456", "appellant@gmail.com", null, @@ -98,7 +105,9 @@ public void shouldSerializeSessionDraftWithNoMrnAsExpected() { null, "Appellant-town", "Appellant-county", + null, "TS1 1ST", + null, "07911123456", "appellant@gmail.com", null, @@ -159,7 +168,9 @@ public void shouldSerializeSessionDraftWithRepAsExpected() { null, "Appellant-town", "Appellant-county", + null, "TS1 1ST", + null, "07911123456", "appellant@gmail.com", null, @@ -181,6 +192,7 @@ public void shouldSerializeSessionDraftWithRepAsExpected() { "rep-line2", "rep-town-city", "rep-county", + null, "RE7 7ES", "07222222222", "representative@gmail.com", @@ -216,7 +228,9 @@ public void shouldSerializeSessionDraftWithAppointeeAsExpected() { "", "Appointee-town", "Appointee-county", + null, "TS2 2ST", + null, "07111111111", "appointee@test.com", null, @@ -233,7 +247,9 @@ public void shouldSerializeSessionDraftWithAppointeeAsExpected() { null, "Appellant-town", "Appellant-county", + null, "TS1 1ST", + null, "07911123456", "appellant@gmail.com", null, @@ -285,7 +301,9 @@ public void shouldSerializeSessionDraftWithAppointeeAtSameAddressAsExpected() { "", "Appointee-town", "Appointee-county", + null, "TS2 2ST", + null, "07111111111", "appointee@test.com", null, @@ -341,7 +359,9 @@ public void shouldSerializeSessionEsaDraftAsExpected() { null, "Appellant-town", "Appellant-county", + null, "TS1 1ST", + null, "07911123456", "appellant@gmail.com", null, @@ -392,7 +412,9 @@ public void shouldSerializeSessionDraftWithDatesCantAttendAsExpected() { null, "Appellant-town", "Appellant-county", + null, "TS1 1ST", + null, "07911123456", "appellant@gmail.com", null, @@ -441,4 +463,193 @@ public void shouldSerializeSessionDraftWithDatesCantAttendAsExpected() { .isEqualTo(sessionDraft); } + @Test + public void shouldSerializeIbcSessionDraftAsExpected() { + SessionDraft sessionDraft = SessionDraft.builder() + .benefitType(new SessionBenefitType("Infected Blood Compensation")) + .postcode(new SessionPostcodeChecker("n29ed")) + .createAccount(new SessionCreateAccount("yes")) + .haveAMrn(new SessionHaveAMrn("yes")) + .mrnDate(new SessionMrnDate(new SessionDate("10", "10", "1990"))) + .mrnOverThirteenMonthsLate(new SessionMrnOverThirteenMonthsLate("aassas dasdsa dasdasda das")) + .appellantName(new SessionName("Mrs.", "Ap", "Pellant")) + .appellantDob(new SessionDob(new SessionDate("31", "12", "1998"))) + .appellantIbcaReference(new SessionAppellantIbcaReference("12341234")) + .appellantInMainlandUk(new SessionInMainlandUk("yes")) + .appellantIbcRole(new SessionAppellantIbcRole("myself")) + .appellantContactDetails( + new SessionContactDetails( + "1 Appellant Close", + null, + "Appellant-town", + "Appellant-county", + null, + "TS1 1ST", + null, + "07911123456", + "appellant@gmail.com", + null, + null, + null + ) + ) + .representative(new SessionRepresentative("no")) + .build(); + + assertThatJson(SESSION_SAMPLE_IBC.getSerializedMessage()) + .isEqualTo(sessionDraft); + } + + @Test + public void shouldSerializeIbcInternationalSessionDraftAsExpected() { + SessionDraft sessionDraft = SessionDraft.builder() + .benefitType(new SessionBenefitType("Infected Blood Compensation")) + .postcode(new SessionPostcodeChecker("n29ed")) + .createAccount(new SessionCreateAccount("yes")) + .haveAMrn(new SessionHaveAMrn("yes")) + .mrnDate(new SessionMrnDate(new SessionDate("10", "10", "1990"))) + .mrnOverThirteenMonthsLate(new SessionMrnOverThirteenMonthsLate("aassas dasdsa dasdasda das")) + .appellantName(new SessionName("Mrs.", "Ap", "Pellant")) + .appellantDob(new SessionDob(new SessionDate("31", "12", "1998"))) + .appellantIbcaReference(new SessionAppellantIbcaReference("12341234")) + .appellantInMainlandUk(new SessionInMainlandUk("no")) + .appellantIbcRole(new SessionAppellantIbcRole("myself")) + .appellantInternationalContactDetails( + new SessionContactDetails( + "1 Appellant Close", + null, + "Appellant-town", + null, + "Iceland", + "TS1 1ST", + "some-port-code", + "07911123456", + "appellant@gmail.com", + null, + null, + null + ) + ) + .representative(new SessionRepresentative("no")) + .build(); + + assertThatJson(SESSION_SAMPLE_IBC_INTERNATIONAL.getSerializedMessage()) + .isEqualTo(sessionDraft); + } + + @Test + public void shouldSerializeIbcRepSessionDraftAsExpected() { + SessionDraft sessionDraft = SessionDraft.builder() + .benefitType(new SessionBenefitType("Infected Blood Compensation")) + .postcode(new SessionPostcodeChecker("n29ed")) + .createAccount(new SessionCreateAccount("yes")) + .haveAMrn(new SessionHaveAMrn("yes")) + .mrnDate(new SessionMrnDate(new SessionDate("10", "10", "1990"))) + .mrnOverThirteenMonthsLate(new SessionMrnOverThirteenMonthsLate("aassas dasdsa dasdasda das")) + .appellantName(new SessionName("Mrs.", "Ap", "Pellant")) + .appellantDob(new SessionDob(new SessionDate("31", "12", "1998"))) + .appellantIbcaReference(new SessionAppellantIbcaReference("12341234")) + .appellantInMainlandUk(new SessionInMainlandUk("yes")) + .appellantIbcRole(new SessionAppellantIbcRole("myself")) + .appellantContactDetails( + new SessionContactDetails( + "1 Appellant Close", + null, + "Appellant-town", + "Appellant-county", + null, + "TS1 1ST", + null, + "07911123456", + "appellant@gmail.com", + null, + null, + null + ) + ) + .representative(new SessionRepresentative("yes")) + .representativeInMainlandUk(new SessionInMainlandUk("yes")) + .representativeDetails( + new SessionRepresentativeDetails( + new SessionRepName( + "Mr.", + "Re", + "Presentative" + ), + "rep-line1", + "rep-line2", + "rep-town-city", + "rep-county", + null, + "RE7 7ES", + "07222222222", + "representative@gmail.com", + null, + null, + null + ) + ) + .build(); + + assertThatJson(SESSION_SAMPLE_IBC_REP.getSerializedMessage()) + .isEqualTo(sessionDraft); + } + + @Test + public void shouldSerializeIbcInternationalRepSessionDraftAsExpected() { + SessionDraft sessionDraft = SessionDraft.builder() + .benefitType(new SessionBenefitType("Infected Blood Compensation")) + .postcode(new SessionPostcodeChecker("n29ed")) + .createAccount(new SessionCreateAccount("yes")) + .haveAMrn(new SessionHaveAMrn("yes")) + .mrnDate(new SessionMrnDate(new SessionDate("10", "10", "1990"))) + .mrnOverThirteenMonthsLate(new SessionMrnOverThirteenMonthsLate("aassas dasdsa dasdasda das")) + .appellantName(new SessionName("Mrs.", "Ap", "Pellant")) + .appellantDob(new SessionDob(new SessionDate("31", "12", "1998"))) + .appellantIbcaReference(new SessionAppellantIbcaReference("12341234")) + .appellantInMainlandUk(new SessionInMainlandUk("yes")) + .appellantIbcRole(new SessionAppellantIbcRole("myself")) + .appellantContactDetails( + new SessionContactDetails( + "1 Appellant Close", + null, + "Appellant-town", + "Appellant-county", + null, + "TS1 1ST", + null, + "07911123456", + "appellant@gmail.com", + null, + null, + null + ) + ) + .representative(new SessionRepresentative("yes")) + .representativeInMainlandUk(new SessionInMainlandUk("no")) + .representativeInternationalDetails( + new SessionRepresentativeDetails( + new SessionRepName( + "Mr.", + "Re", + "Presentative" + ), + "rep-line1", + "rep-line2", + "rep-town-city", + null, + "Iceland", + "RE7 7ES", + "07222222222", + "representative@gmail.com", + null, + null, + null + ) + ) + .build(); + + assertThatJson(SESSION_SAMPLE_IBC_REP_INTERNATIONAL.getSerializedMessage()) + .isEqualTo(sessionDraft); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/service/converter/ConvertSscsCaseDataIntoSessionDraftTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/service/converter/ConvertSscsCaseDataIntoSessionDraftTest.java index 217c6315508..150959bff55 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/service/converter/ConvertSscsCaseDataIntoSessionDraftTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/service/converter/ConvertSscsCaseDataIntoSessionDraftTest.java @@ -58,7 +58,7 @@ public void attemptToConvertNull() { @Test(expected = NullPointerException.class) public void attemptToConvertNullAppeal() { - SscsCaseData caseData = SscsCaseData.builder().build(); + caseData = SscsCaseData.builder().build(); convertSscsCaseDataIntoSessionDraft.convert(caseData); } @@ -74,7 +74,7 @@ public void givenEvidenceDescriptionIsProvided_shouldReturnSessionEvidenceDescri given(documentDownloadService.getFileSize(anyString())).willReturn(1L); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("my evidence description", actual.getEvidenceDescription().getDescribeTheEvidence()); } @@ -335,37 +335,23 @@ public void convertPopulatedCaseData() { .ccdCaseId("123456") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("Personal Independence Payment (PIP)", actual.getBenefitType().getBenefitType()); assertEquals("yes", actual.getCreateAccount().getCreateAccount()); - assertEquals("yes", actual.getHaveAMrn().getHaveAMrn()); - assertEquals("1", actual.getMrnDate().getMrnDateDetails().getDay()); - assertEquals("2", actual.getMrnDate().getMrnDateDetails().getMonth()); - assertEquals("2010", actual.getMrnDate().getMrnDateDetails().getYear()); + assertMrnDate(actual); assertEquals("1", actual.getDwpIssuingOffice().getPipNumber()); assertEquals("no", actual.getAppointee().getIsAppointee()); - assertEquals("Mrs.", actual.getAppellantName().getTitle()); - assertEquals("Ap", actual.getAppellantName().getFirstName()); - assertEquals("Pellant", actual.getAppellantName().getLastName()); - assertEquals("31", actual.getAppellantDob().getDate().getDay()); - assertEquals("12", actual.getAppellantDob().getDate().getMonth()); - assertEquals("1998", actual.getAppellantDob().getDate().getYear()); + assertAppellantName(actual); + assertAppellantDob(actual); assertEquals("SC 94 27 06 A", actual.getAppellantNino().getNino()); - assertEquals("1 Appellant Close", actual.getAppellantContactDetails().getAddressLine1()); - assertNull(actual.getAppellantContactDetails().getAddressLine2()); - assertEquals("Appellant-town", actual.getAppellantContactDetails().getTownCity()); - assertEquals("Appellant-county", actual.getAppellantContactDetails().getCounty()); - assertEquals("TS1 1ST", actual.getAppellantContactDetails().getPostCode()); - assertEquals("07911123456", actual.getAppellantContactDetails().getPhoneNumber()); - assertEquals("appellant@gmail.com", actual.getAppellantContactDetails().getEmailAddress()); + assertNull(actual.getAppellantIbcaReference()); + assertAppellantAddress(actual); + assertAppellantContact(actual); assertEquals("no", actual.getSameAddress().getIsAddressSameAsAppointee()); assertEquals("yes", actual.getTextReminders().getDoYouWantTextMsgReminders()); assertEquals("yes", actual.getSendToNumber().getUseSameNumber()); assertNull("no", actual.getRepresentative()); - assertEquals("I think I should get more", actual.getReasonForAppealing().getReasonForAppealingItems().get(0).getReasonForAppealing()); - assertEquals("Underpayment", actual.getReasonForAppealing().getReasonForAppealingItems().get(0).getWhatYouDisagreeWith()); - assertEquals("I can't think of anything else", actual.getOtherReasonForAppealing().getOtherReasonForAppealing()); - assertEquals("no", actual.getEvidenceProvide().getEvidenceProvide()); + assertReasonsAndEvidence(actual); assertEquals("123456", actual.getCcdCaseId()); assertNull(actual.getRepresentativeDetails()); } @@ -447,7 +433,7 @@ public void convertPopulatedCaseDataWithDifferentMobileNumber() { .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("07911123456", actual.getAppellantContactDetails().getPhoneNumber()); assertEquals("yes", actual.getTextReminders().getDoYouWantTextMsgReminders()); assertEquals("no", actual.getSendToNumber().getUseSameNumber()); @@ -455,7 +441,7 @@ public void convertPopulatedCaseDataWithDifferentMobileNumber() { @Test public void convertPopulatedCaseDataWithNoMrn() { - SscsCaseData caseData = SscsCaseData.builder() + caseData = SscsCaseData.builder() .appeal(Appeal.builder() .benefitType(BenefitType.builder() .code("PIP") @@ -527,39 +513,27 @@ public void convertPopulatedCaseDataWithNoMrn() { .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("Personal Independence Payment (PIP)", actual.getBenefitType().getBenefitType()); assertEquals("yes", actual.getCreateAccount().getCreateAccount()); assertEquals("no", actual.getHaveAMrn().getHaveAMrn()); assertEquals("I can't find the letter.", actual.getNoMrn().getReasonForNoMrn()); assertEquals("no", actual.getAppointee().getIsAppointee()); - assertEquals("Mrs.", actual.getAppellantName().getTitle()); - assertEquals("Ap", actual.getAppellantName().getFirstName()); - assertEquals("Pellant", actual.getAppellantName().getLastName()); - assertEquals("31", actual.getAppellantDob().getDate().getDay()); - assertEquals("12", actual.getAppellantDob().getDate().getMonth()); - assertEquals("1998", actual.getAppellantDob().getDate().getYear()); + assertAppellantName(actual); + assertAppellantDob(actual); assertEquals("SC 94 27 06 A", actual.getAppellantNino().getNino()); - assertEquals("1 Appellant Close", actual.getAppellantContactDetails().getAddressLine1()); - assertNull(actual.getAppellantContactDetails().getAddressLine2()); - assertEquals("Appellant-town", actual.getAppellantContactDetails().getTownCity()); - assertEquals("Appellant-county", actual.getAppellantContactDetails().getCounty()); - assertEquals("TS1 1ST", actual.getAppellantContactDetails().getPostCode()); - assertEquals("07911123456", actual.getAppellantContactDetails().getPhoneNumber()); - assertEquals("appellant@gmail.com", actual.getAppellantContactDetails().getEmailAddress()); + assertAppellantAddress(actual); + assertAppellantContact(actual); assertEquals("yes", actual.getTextReminders().getDoYouWantTextMsgReminders()); assertEquals("yes", actual.getSendToNumber().getUseSameNumber()); assertNull("no", actual.getRepresentative()); - assertEquals("I think I should get more", actual.getReasonForAppealing().getReasonForAppealingItems().get(0).getReasonForAppealing()); - assertEquals("Underpayment", actual.getReasonForAppealing().getReasonForAppealingItems().get(0).getWhatYouDisagreeWith()); - assertEquals("I can't think of anything else", actual.getOtherReasonForAppealing().getOtherReasonForAppealing()); - assertEquals("no", actual.getEvidenceProvide().getEvidenceProvide()); + assertReasonsAndEvidence(actual); assertNull(actual.getRepresentativeDetails()); } @Test public void convertPopulatedCaseDataWithAppointee() { - SscsCaseData caseData = SscsCaseData.builder() + caseData = SscsCaseData.builder() .appeal(Appeal.builder() .benefitType(BenefitType.builder() .code("PIP") @@ -598,7 +572,7 @@ public void convertPopulatedCaseDataWithAppointee() { ) .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getAppointee().getIsAppointee()); assertEquals("Mr.", actual.getAppointeeName().getTitle()); assertEquals("Ap", actual.getAppointeeName().getFirstName()); @@ -618,7 +592,7 @@ public void convertPopulatedCaseDataWithAppointee() { @Test public void convertPopulatedCaseDataWithAppointeeAtSameAddress() { - SscsCaseData caseData = SscsCaseData.builder() + caseData = SscsCaseData.builder() .appeal(Appeal.builder() .benefitType(BenefitType.builder() .code("PIP") @@ -656,7 +630,7 @@ public void convertPopulatedCaseDataWithAppointeeAtSameAddress() { ) .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getAppointee().getIsAppointee()); assertEquals("Mr.", actual.getAppointeeName().getTitle()); assertEquals("Ap", actual.getAppointeeName().getFirstName()); @@ -676,7 +650,7 @@ public void convertPopulatedCaseDataWithAppointeeAtSameAddress() { @Test public void convertPopulatedCaseDataWithAppointeeNotSpecified() { - SscsCaseData caseData = SscsCaseData.builder() + caseData = SscsCaseData.builder() .appeal(Appeal.builder() .benefitType(BenefitType.builder() .code("PIP") @@ -883,54 +857,32 @@ public void convertPopulatedCaseDataWithRep() { .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("Personal Independence Payment (PIP)", actual.getBenefitType().getBenefitType()); assertEquals("yes", actual.getCreateAccount().getCreateAccount()); - assertEquals("yes", actual.getHaveAMrn().getHaveAMrn()); - assertEquals("1", actual.getMrnDate().getMrnDateDetails().getDay()); - assertEquals("2", actual.getMrnDate().getMrnDateDetails().getMonth()); - assertEquals("2010", actual.getMrnDate().getMrnDateDetails().getYear()); + assertMrnDate(actual); assertEquals("1", actual.getDwpIssuingOffice().getPipNumber()); assertEquals("no", actual.getAppointee().getIsAppointee()); - assertEquals("Mrs.", actual.getAppellantName().getTitle()); - assertEquals("Ap", actual.getAppellantName().getFirstName()); - assertEquals("Pellant", actual.getAppellantName().getLastName()); - assertEquals("31", actual.getAppellantDob().getDate().getDay()); - assertEquals("12", actual.getAppellantDob().getDate().getMonth()); - assertEquals("1998", actual.getAppellantDob().getDate().getYear()); + assertAppellantName(actual); + assertAppellantDob(actual); assertEquals("SC 94 27 06 A", actual.getAppellantNino().getNino()); - assertEquals("1 Appellant Close", actual.getAppellantContactDetails().getAddressLine1()); - assertNull(actual.getAppellantContactDetails().getAddressLine2()); - assertEquals("Appellant-town", actual.getAppellantContactDetails().getTownCity()); - assertEquals("Appellant-county", actual.getAppellantContactDetails().getCounty()); - assertEquals("TS1 1ST", actual.getAppellantContactDetails().getPostCode()); - assertEquals("07911123456", actual.getAppellantContactDetails().getPhoneNumber()); - assertEquals("appellant@gmail.com", actual.getAppellantContactDetails().getEmailAddress()); + assertAppellantAddress(actual); + assertAppellantContact(actual); assertEquals("yes", actual.getTextReminders().getDoYouWantTextMsgReminders()); assertEquals("yes", actual.getSendToNumber().getUseSameNumber()); assertEquals("yes", actual.getRepresentative().getHasRepresentative()); assertEquals("Miss.", actual.getRepresentativeDetails().getName().getTitle()); assertEquals("Re", actual.getRepresentativeDetails().getName().getFirst()); assertEquals("Presentative", actual.getRepresentativeDetails().getName().getLast()); - assertEquals("I think I should get more", actual.getReasonForAppealing().getReasonForAppealingItems().get(0).getReasonForAppealing()); - assertEquals("Underpayment", actual.getReasonForAppealing().getReasonForAppealingItems().get(0).getWhatYouDisagreeWith()); - assertEquals("I can't think of anything else", actual.getOtherReasonForAppealing().getOtherReasonForAppealing()); - assertEquals("no", actual.getEvidenceProvide().getEvidenceProvide()); - assertEquals("Miss.", actual.getRepresentativeDetails().getName().getTitle()); - assertEquals("Re", actual.getRepresentativeDetails().getName().getFirst()); - assertEquals("Presentative", actual.getRepresentativeDetails().getName().getLast()); + assertReasonsAndEvidence(actual); assertEquals("07333333333", actual.getRepresentativeDetails().getPhoneNumber()); assertEquals("rep@gmail.com", actual.getRepresentativeDetails().getEmailAddress()); - assertEquals("1 Rep Cres", actual.getRepresentativeDetails().getAddressLine1()); - assertNull(actual.getRepresentativeDetails().getAddressLine2()); - assertEquals("Rep-town", actual.getRepresentativeDetails().getTownCity()); - assertEquals("Rep-county", actual.getRepresentativeDetails().getCounty()); - assertEquals("TS3 3ST", actual.getRepresentativeDetails().getPostCode()); + assertRepAddress(actual); } @Test public void convertPopulatedCaseDataWithRepNoAddress() { - SscsCaseData caseData = SscsCaseData.builder() + caseData = SscsCaseData.builder() .appeal(Appeal.builder() .benefitType(BenefitType.builder() .code("PIP") @@ -1009,7 +961,7 @@ public void convertPopulatedCaseDataWithRepNoAddress() { .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertNull(actual.getRepresentativeDetails().getAddressLine1()); assertNull(actual.getRepresentativeDetails().getAddressLine2()); assertNull(actual.getRepresentativeDetails().getTownCity()); @@ -1019,7 +971,7 @@ public void convertPopulatedCaseDataWithRepNoAddress() { @Test public void convertPopulatedCaseDataWithRepNoContact() { - SscsCaseData caseData = SscsCaseData.builder() + caseData = SscsCaseData.builder() .appeal(Appeal.builder() .benefitType(BenefitType.builder() .code("PIP") @@ -1103,7 +1055,7 @@ public void convertPopulatedCaseDataWithRepNoContact() { .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertNull(actual.getRepresentativeDetails().getPhoneNumber()); assertNull(actual.getRepresentativeDetails().getEmailAddress()); } @@ -1179,7 +1131,7 @@ public void convertPopulatedCaseDataWhenAttendingHearing() { .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getTheHearing().getAttendHearing()); assertEquals("yes", actual.getHearingAvailability().getScheduleHearing()); assertEquals("no", actual.getHearingSupport().getArrangements()); @@ -1271,7 +1223,7 @@ public void convertPopulatedCaseDataWhenAttendingHearingWithSupport() { .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getTheHearing().getAttendHearing()); assertEquals("yes", actual.getHearingAvailability().getScheduleHearing()); assertEquals("yes", actual.getHearingSupport().getArrangements()); @@ -1371,7 +1323,7 @@ public void convertPopulatedCaseDataWhenAttendingHearingWithSupportNoInterpreter .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getTheHearing().getAttendHearing()); assertEquals("yes", actual.getHearingAvailability().getScheduleHearing()); assertEquals("yes", actual.getHearingSupport().getArrangements()); @@ -1409,7 +1361,7 @@ public void convertPopulatedCaseDataWhenAttendingHearingWithSupportNoArrangement .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getTheHearing().getAttendHearing()); assertEquals("yes", actual.getHearingAvailability().getScheduleHearing()); assertEquals("yes", actual.getHearingSupport().getArrangements()); @@ -1440,7 +1392,7 @@ public void convertPopulatedCaseDataWhenAttendingHearingWithSupportNullObjectsAr .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getTheHearing().getAttendHearing()); assertEquals("yes", actual.getHearingAvailability().getScheduleHearing()); assertEquals("yes", actual.getHearingSupport().getArrangements()); @@ -1458,7 +1410,7 @@ public void givenHearingWithSupportAndNoArrangement_shouldReturnNullSessionHeari .build()) .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals(expected, actual.getHearingArrangements()); } @@ -1528,7 +1480,7 @@ public void convertPopulatedCaseDataWhenAttendingHearingWithSupportNotListedArra .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getTheHearing().getAttendHearing()); assertEquals("yes", actual.getHearingAvailability().getScheduleHearing()); assertEquals("yes", actual.getHearingSupport().getArrangements()); @@ -1555,7 +1507,7 @@ public void convertPopulatedCaseDataWhenAttendingHearingWithSupportNullArrangeme .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getTheHearing().getAttendHearing()); assertEquals("yes", actual.getHearingAvailability().getScheduleHearing()); assertEquals("yes", actual.getHearingSupport().getArrangements()); @@ -1656,7 +1608,7 @@ public void convertPopulatedCaseDataWhenAttendingHearingButCantAttendOnSomeDates .evidencePresent("no") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getTheHearing().getAttendHearing()); assertEquals("yes", actual.getHearingAvailability().getScheduleHearing()); assertEquals("no", actual.getHearingSupport().getArrangements()); @@ -1699,7 +1651,7 @@ public void convertPopulatedCaseDataWhenLanguagePreferenceWelshIsGiven() { .evidencePresent("no") .languagePreferenceWelsh("yes") .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertEquals("yes", actual.getLanguagePreferenceWelsh().getLanguagePreferenceWelsh()); } @@ -1723,8 +1675,280 @@ public void convertPopulatedCaseDataWhenLanguagePreferenceWelshIsNotGiven() { .evidencePresent("no") .languagePreferenceWelsh(null) .build(); - SessionDraft actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); assertNull(actual.getLanguagePreferenceWelsh()); } + @Test + public void convertPopulatedIbcCaseData() { + caseData = SscsCaseData.builder() + .appeal(Appeal.builder() + .benefitType(BenefitType.builder() + .code("infectedBloodCompensation") + .description("Infected Blood Compensation") + .build() + ) + .appellant(Appellant.builder() + .name(Name.builder() + .title("Mrs.") + .firstName("Ap") + .lastName("Pellant") + .build() + ) + .ibcRole("myself") + .identity(Identity.builder() + .dob("1998-12-31") + .ibcaReference("1234567890") + .build() + ) + .address(Address.builder() + .line1("1 Appellant Close") + .town("Appellant-town") + .county("Appellant-county") + .postcode("TS1 1ST") + .inMainlandUk(YesNo.YES) + .build() + ) + .contact(Contact.builder() + .mobile("07911123456") + .email("appellant@gmail.com") + .build() + ) + .build() + ) + .mrnDetails(MrnDetails.builder() + .mrnDate("2010-02-01") + .mrnLateReason("Forgot to send it") + .build() + ) + .appealReasons( + AppealReasons.builder() + .reasons( + Collections.singletonList( + AppealReason.builder() + .value(AppealReasonDetails.builder() + .reason("Underpayment") + .description("I think I should get more") + .build() + ) + .build() + ) + ) + .otherReasons("I can't think of anything else") + .build() + ) + .hearingOptions(null) + .rep(Representative.builder().build()) + .build() + ) + .subscriptions(Subscriptions.builder() + .appellantSubscription(Subscription.builder() + .subscribeEmail("Yes") + .email("appellant@gmail.com") + .subscribeSms("Yes") + .mobile("07911123456") + .build() + ) + .build() + ) + .sscsDocument(Collections.emptyList()) + .evidencePresent("no") + .ccdCaseId("123456") + .build(); + + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + assertEquals("Infected Blood Compensation", actual.getBenefitType().getBenefitType()); + assertEquals("yes", actual.getCreateAccount().getCreateAccount()); + assertMrnDate(actual); + assertNull(actual.getDwpIssuingOffice()); + assertNull(actual.getAppointee()); + assertEquals("myself", actual.getAppellantIbcRole().getIbcRole()); + assertAppellantName(actual); + assertAppellantDob(actual); + assertNull(actual.getAppellantNino()); + assertEquals("1234567890", actual.getAppellantIbcaReference().getIbcaReference()); + assertNull(actual.getAppellantInternationalContactDetails()); + assertAppellantAddress(actual); + assertNull(actual.getAppellantContactDetails().getCountry()); + assertNull(actual.getAppellantContactDetails().getPortOfEntry()); + assertAppellantContact(actual); + assertEquals("yes", actual.getAppellantInMainlandUk().getInMainlandUk()); + assertNull(actual.getSameAddress()); + assertEquals("yes", actual.getTextReminders().getDoYouWantTextMsgReminders()); + assertEquals("yes", actual.getSendToNumber().getUseSameNumber()); + assertNull("no", actual.getRepresentative()); + assertReasonsAndEvidence(actual); + assertEquals("123456", actual.getCcdCaseId()); + assertNull(actual.getRepresentativeDetails()); + } + + @Test + public void convertPopulatedIbcInternationalCaseData() { + caseData = SscsCaseData.builder() + .appeal(Appeal.builder() + .benefitType(BenefitType.builder() + .code("infectedBloodCompensation") + .description("Infected Blood Compensation") + .build() + ) + .appellant(Appellant.builder() + .address(Address.builder() + .line1("1 Appellant Close") + .town("Appellant-town") + .country("Iceland") + .postcode("TS1 1ST") + .portOfEntry("some-port") + .inMainlandUk(YesNo.NO) + .build() + ) + .contact(Contact.builder() + .mobile("07911123456") + .email("appellant@gmail.com") + .build() + ) + .build() + ) + .build() + ) + .ccdCaseId("123456") + .build(); + + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + assertEquals("Infected Blood Compensation", actual.getBenefitType().getBenefitType()); + assertEquals("yes", actual.getCreateAccount().getCreateAccount()); + assertNull(actual.getAppellantContactDetails()); + assertEquals("1 Appellant Close", actual.getAppellantInternationalContactDetails().getAddressLine1()); + assertNull(actual.getAppellantInternationalContactDetails().getAddressLine2()); + assertEquals("Appellant-town", actual.getAppellantInternationalContactDetails().getTownCity()); + assertNull(actual.getAppellantInternationalContactDetails().getCounty()); + assertEquals("Iceland", actual.getAppellantInternationalContactDetails().getCountry()); + assertEquals("some-port", actual.getAppellantInternationalContactDetails().getPortOfEntry()); + assertEquals("TS1 1ST", actual.getAppellantInternationalContactDetails().getPostCode()); + assertEquals("07911123456", actual.getAppellantInternationalContactDetails().getPhoneNumber()); + assertEquals("appellant@gmail.com", actual.getAppellantInternationalContactDetails().getEmailAddress()); + assertEquals("no", actual.getAppellantInMainlandUk().getInMainlandUk()); + assertNull("no", actual.getRepresentative()); + assertNull(actual.getRepresentativeDetails()); + } + + @Test + public void convertPopulatedIbcRepCaseData() { + caseData = SscsCaseData.builder() + .appeal(Appeal.builder() + .benefitType(BenefitType.builder() + .code("infectedBloodCompensation") + .description("Infected Blood Compensation") + .build() + ) + .rep(Representative.builder() + .hasRepresentative("Yes") + .name(Name.builder().title("Miss.").firstName("Re").lastName("Presentative").build()) + .contact(null) + .address(Address.builder() + .line1("1 Rep Cres") + .town("Rep-town") + .county("Rep-county") + .postcode("TS3 3ST") + .inMainlandUk(YesNo.YES) + .build()) + .build()) + .build() + ) + .ccdCaseId("123456") + .build(); + + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + assertEquals("Infected Blood Compensation", actual.getBenefitType().getBenefitType()); + assertEquals("yes", actual.getCreateAccount().getCreateAccount()); + assertEquals("yes", actual.getRepresentative().getHasRepresentative()); + assertNull(actual.getRepresentativeInternationalDetails()); + assertRepAddress(actual); + assertEquals("yes", actual.getRepresentativeInMainlandUk().getInMainlandUk()); + } + + @Test + public void convertPopulatedIbcInternationalRepCaseData() { + caseData = SscsCaseData.builder() + .appeal(Appeal.builder() + .benefitType(BenefitType.builder() + .code("infectedBloodCompensation") + .description("Infected Blood Compensation") + .build() + ) + .rep(Representative.builder() + .hasRepresentative("Yes") + .name(Name.builder().title("Miss.").firstName("Re").lastName("Presentative").build()) + .contact(null) + .address(Address.builder() + .line1("1 Rep Cres") + .town("Rep-town") + .country("Iceland") + .postcode("TS3 3ST") + .inMainlandUk(YesNo.NO) + .build()) + .build()) + .build() + ) + .ccdCaseId("123456") + .build(); + + actual = convertSscsCaseDataIntoSessionDraft.convert(caseData); + assertEquals("Infected Blood Compensation", actual.getBenefitType().getBenefitType()); + assertEquals("yes", actual.getCreateAccount().getCreateAccount()); + assertEquals("yes", actual.getRepresentative().getHasRepresentative()); + assertNull(actual.getRepresentativeDetails()); + assertEquals("1 Rep Cres", actual.getRepresentativeInternationalDetails().getAddressLine1()); + assertNull(actual.getRepresentativeInternationalDetails().getAddressLine2()); + assertEquals("Rep-town", actual.getRepresentativeInternationalDetails().getTownCity()); + assertEquals("Iceland", actual.getRepresentativeInternationalDetails().getCountry()); + assertEquals("TS3 3ST", actual.getRepresentativeInternationalDetails().getPostCode()); + assertEquals("no", actual.getRepresentativeInMainlandUk().getInMainlandUk()); + } + + private static void assertMrnDate(SessionDraft actual) { + assertEquals("yes", actual.getHaveAMrn().getHaveAMrn()); + assertEquals("1", actual.getMrnDate().getMrnDateDetails().getDay()); + assertEquals("2", actual.getMrnDate().getMrnDateDetails().getMonth()); + assertEquals("2010", actual.getMrnDate().getMrnDateDetails().getYear()); + } + + private static void assertAppellantName(SessionDraft actual) { + assertEquals("Mrs.", actual.getAppellantName().getTitle()); + assertEquals("Ap", actual.getAppellantName().getFirstName()); + assertEquals("Pellant", actual.getAppellantName().getLastName()); + } + + private static void assertAppellantDob(SessionDraft actual) { + assertEquals("31", actual.getAppellantDob().getDate().getDay()); + assertEquals("12", actual.getAppellantDob().getDate().getMonth()); + assertEquals("1998", actual.getAppellantDob().getDate().getYear()); + } + + private static void assertAppellantAddress(SessionDraft actual) { + assertEquals("1 Appellant Close", actual.getAppellantContactDetails().getAddressLine1()); + assertNull(actual.getAppellantContactDetails().getAddressLine2()); + assertEquals("Appellant-town", actual.getAppellantContactDetails().getTownCity()); + assertEquals("Appellant-county", actual.getAppellantContactDetails().getCounty()); + assertEquals("TS1 1ST", actual.getAppellantContactDetails().getPostCode()); + } + + private static void assertAppellantContact(SessionDraft actual) { + assertEquals("07911123456", actual.getAppellantContactDetails().getPhoneNumber()); + assertEquals("appellant@gmail.com", actual.getAppellantContactDetails().getEmailAddress()); + } + + private static void assertReasonsAndEvidence(SessionDraft actual) { + assertEquals("I think I should get more", actual.getReasonForAppealing().getReasonForAppealingItems().get(0).getReasonForAppealing()); + assertEquals("Underpayment", actual.getReasonForAppealing().getReasonForAppealingItems().get(0).getWhatYouDisagreeWith()); + assertEquals("I can't think of anything else", actual.getOtherReasonForAppealing().getOtherReasonForAppealing()); + assertEquals("no", actual.getEvidenceProvide().getEvidenceProvide()); + } + + private static void assertRepAddress(SessionDraft actual) { + assertEquals("1 Rep Cres", actual.getRepresentativeDetails().getAddressLine1()); + assertNull(actual.getRepresentativeDetails().getAddressLine2()); + assertEquals("Rep-town", actual.getRepresentativeDetails().getTownCity()); + assertEquals("Rep-county", actual.getRepresentativeDetails().getCounty()); + assertEquals("TS3 3ST", actual.getRepresentativeDetails().getPostCode()); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/util/SerializeJsonMessageManager.java b/src/test/java/uk/gov/hmcts/reform/sscs/util/SerializeJsonMessageManager.java index 99e4e341599..5fbd358d675 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/util/SerializeJsonMessageManager.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/util/SerializeJsonMessageManager.java @@ -90,6 +90,10 @@ public enum SerializeJsonMessageManager { HEARING_RECORDING_CCD("tya/hearingRecordingCcd.json"), HEARING_RECORDING_MYA("tya/hearingRecordingMya.json"), SESSION_SAMPLE("drafts/session-sample.json"), + SESSION_SAMPLE_IBC("drafts/session-sample-ibc.json"), + SESSION_SAMPLE_IBC_INTERNATIONAL("drafts/session-sample-ibc-international.json"), + SESSION_SAMPLE_IBC_REP("drafts/session-sample-ibc-rep.json"), + SESSION_SAMPLE_IBC_REP_INTERNATIONAL("drafts/session-sample-ibc-rep-international.json"), SESSION_SAMPLE_ESA("drafts/session-sample-esa.json"), SESSION_SAMPLE_WITH_APPOINTEE("drafts/session-sample-with-appointee.json"), SESSION_SAMPLE_WITH_APPOINTEE_AT_SAME_ADDRESS("drafts/session-sample-with-appointee-at-same-address.json"), diff --git a/src/test/resources/drafts/session-sample-ibc-international.json b/src/test/resources/drafts/session-sample-ibc-international.json new file mode 100644 index 00000000000..c94d25afa38 --- /dev/null +++ b/src/test/resources/drafts/session-sample-ibc-international.json @@ -0,0 +1,57 @@ +{ + "BenefitType": { + "benefitType": "Infected Blood Compensation" + }, + "PostcodeChecker": { + "postcode": "n29ed" + }, + "CreateAccount": { + "createAccount": "yes" + }, + "HaveAMRN": { + "haveAMRN": "yes" + }, + "MRNDate": { + "mrnDate": { + "day": "10", + "month": "10", + "year": "1990" + } + }, + "MRNOverThirteenMonthsLate": { + "reasonForBeingLate": "aassas dasdsa dasdasda das" + }, + "AppellantName": { + "title": "Mrs.", + "firstName": "Ap", + "lastName": "Pellant" + }, + "AppellantDOB": { + "date": { + "day": "31", + "month": "12", + "year": "1998" + } + }, + "AppellantIBCAReference": { + "ibcaReference": "12341234" + }, + "AppellantInternationalContactDetails": { + "addressLine1": "1 Appellant Close", + "townCity": "Appellant-town", + "country": "Iceland", + "postCode": "TS1 1ST", + "portOfEntry": "some-port-code", + "phoneNumber": "07911123456", + "emailAddress": "appellant@gmail.com" + }, + "AppellantRole": { + "ibcRole": "myself" + }, + "AppellantInMainlandUk": { + "inMainlandUk": "no" + }, + "Representative": { + "hasRepresentative": "no" + } +} \ No newline at end of file diff --git a/src/test/resources/drafts/session-sample-ibc-rep-international.json b/src/test/resources/drafts/session-sample-ibc-rep-international.json new file mode 100644 index 00000000000..4121cde1eca --- /dev/null +++ b/src/test/resources/drafts/session-sample-ibc-rep-international.json @@ -0,0 +1,73 @@ +{ + "BenefitType": { + "benefitType": "Infected Blood Compensation" + }, + "PostcodeChecker": { + "postcode": "n29ed" + }, + "CreateAccount": { + "createAccount": "yes" + }, + "HaveAMRN": { + "haveAMRN": "yes" + }, + "MRNDate": { + "mrnDate": { + "day": "10", + "month": "10", + "year": "1990" + } + }, + "MRNOverThirteenMonthsLate": { + "reasonForBeingLate": "aassas dasdsa dasdasda das" + }, + "AppellantName": { + "title": "Mrs.", + "firstName": "Ap", + "lastName": "Pellant" + }, + "AppellantDOB": { + "date": { + "day": "31", + "month": "12", + "year": "1998" + } + }, + "AppellantIBCAReference": { + "ibcaReference": "12341234" + }, + "AppellantContactDetails": { + "addressLine1": "1 Appellant Close", + "townCity": "Appellant-town", + "county": "Appellant-county", + "postCode": "TS1 1ST", + "phoneNumber": "07911123456", + "emailAddress": "appellant@gmail.com" + }, + "AppellantRole": { + "ibcRole": "myself" + }, + "AppellantInMainlandUk": { + "inMainlandUk": "yes" + }, + "Representative": { + "hasRepresentative": "yes" + }, + "RepresentativeInMainlandUk": { + "inMainlandUk": "no" + }, + "RepresentativeInternationalDetails": { + "name": { + "title": "Mr.", + "first": "Re", + "last": "Presentative" + }, + "addressLine1": "rep-line1", + "addressLine2": "rep-line2", + "townCity": "rep-town-city", + "country": "Iceland", + "postCode": "RE7 7ES", + "emailAddress": "representative@gmail.com", + "phoneNumber": "07222222222" + } +} \ No newline at end of file diff --git a/src/test/resources/drafts/session-sample-ibc-rep.json b/src/test/resources/drafts/session-sample-ibc-rep.json new file mode 100644 index 00000000000..6a7f22219a0 --- /dev/null +++ b/src/test/resources/drafts/session-sample-ibc-rep.json @@ -0,0 +1,73 @@ +{ + "BenefitType": { + "benefitType": "Infected Blood Compensation" + }, + "PostcodeChecker": { + "postcode": "n29ed" + }, + "CreateAccount": { + "createAccount": "yes" + }, + "HaveAMRN": { + "haveAMRN": "yes" + }, + "MRNDate": { + "mrnDate": { + "day": "10", + "month": "10", + "year": "1990" + } + }, + "MRNOverThirteenMonthsLate": { + "reasonForBeingLate": "aassas dasdsa dasdasda das" + }, + "AppellantName": { + "title": "Mrs.", + "firstName": "Ap", + "lastName": "Pellant" + }, + "AppellantDOB": { + "date": { + "day": "31", + "month": "12", + "year": "1998" + } + }, + "AppellantIBCAReference": { + "ibcaReference": "12341234" + }, + "AppellantContactDetails": { + "addressLine1": "1 Appellant Close", + "townCity": "Appellant-town", + "county": "Appellant-county", + "postCode": "TS1 1ST", + "phoneNumber": "07911123456", + "emailAddress": "appellant@gmail.com" + }, + "AppellantRole": { + "ibcRole": "myself" + }, + "AppellantInMainlandUk": { + "inMainlandUk": "yes" + }, + "Representative": { + "hasRepresentative": "yes" + }, + "RepresentativeInMainlandUk": { + "inMainlandUk": "yes" + }, + "RepresentativeDetails": { + "name": { + "title": "Mr.", + "first": "Re", + "last": "Presentative" + }, + "addressLine1": "rep-line1", + "addressLine2": "rep-line2", + "townCity": "rep-town-city", + "county": "rep-county", + "postCode": "RE7 7ES", + "emailAddress": "representative@gmail.com", + "phoneNumber": "07222222222" + } +} \ No newline at end of file diff --git a/src/test/resources/drafts/session-sample-ibc.json b/src/test/resources/drafts/session-sample-ibc.json new file mode 100644 index 00000000000..e06ba6ab016 --- /dev/null +++ b/src/test/resources/drafts/session-sample-ibc.json @@ -0,0 +1,56 @@ +{ + "BenefitType": { + "benefitType": "Infected Blood Compensation" + }, + "PostcodeChecker": { + "postcode": "n29ed" + }, + "CreateAccount": { + "createAccount": "yes" + }, + "HaveAMRN": { + "haveAMRN": "yes" + }, + "MRNDate": { + "mrnDate": { + "day": "10", + "month": "10", + "year": "1990" + } + }, + "MRNOverThirteenMonthsLate": { + "reasonForBeingLate": "aassas dasdsa dasdasda das" + }, + "AppellantName": { + "title": "Mrs.", + "firstName": "Ap", + "lastName": "Pellant" + }, + "AppellantDOB": { + "date": { + "day": "31", + "month": "12", + "year": "1998" + } + }, + "AppellantIBCAReference": { + "ibcaReference": "12341234" + }, + "AppellantContactDetails": { + "addressLine1": "1 Appellant Close", + "townCity": "Appellant-town", + "county": "Appellant-county", + "postCode": "TS1 1ST", + "phoneNumber": "07911123456", + "emailAddress": "appellant@gmail.com" + }, + "AppellantRole": { + "ibcRole": "myself" + }, + "AppellantInMainlandUk": { + "inMainlandUk": "yes" + }, + "Representative": { + "hasRepresentative": "no" + } +} \ No newline at end of file