Skip to content

Commit

Permalink
[NFDIV-4288] Validate address present on solicitor submit (#4254)
Browse files Browse the repository at this point in the history
* Introduce non-confidential address fields

* Checkstyle corrections

* Update tests and add back old search fields

* Add test for new case task

* Set up search fields and refactor

* Remove old method reference from solicitor create application IT

* Fix integration tests

* Checkstyle correction

* Remove confidential address from applicant with address helper

* Update functional tests

* Refactor

* Checkstyle corrections

* Remove search role field for judge

* Add applicant addresses to search fields for judges

* Blank out nonConfidential address fields after contact details have been viewed

* Dummy commit to redeploy

* Grant back address read permissions for citizen case roles

* Validate address present on solicitor submit

* Reduce validation to cover applicant 1

* Update tests
  • Loading branch information
adamg-hmcts authored Jan 7, 2025
1 parent 5d6c603 commit 258150c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import uk.gov.hmcts.ccd.sdk.type.AddressGlobalUK;
import uk.gov.hmcts.ccd.sdk.type.DynamicList;
import uk.gov.hmcts.divorce.common.config.WebMvcConfig;
import uk.gov.hmcts.divorce.divorcecase.model.Applicant;
import uk.gov.hmcts.divorce.divorcecase.model.CaseData;
import uk.gov.hmcts.divorce.notification.NotificationService;
import uk.gov.hmcts.divorce.payment.model.CreditAccountPaymentResponse;
Expand Down Expand Up @@ -121,6 +123,7 @@ static void tearDown() {
public void createsOrderSummaryToPrepareCaseForPayment() throws Exception {
var data = caseDataWithStatementOfTruth();
data.getApplication().setApplicationFeeOrderSummary(null);
data.getApplicant1().setAddress(AddressGlobalUK.builder().addressLine1("test").build());

when(serviceTokenGenerator.generate()).thenReturn(TEST_SERVICE_AUTH_TOKEN);

Expand Down Expand Up @@ -181,6 +184,11 @@ public void givenFeeEventIsNotAvailableWhenCallbackIsInvokedThenReturn404FeeEven

CaseData data = new CaseData();
data.getApplication().setApplicationFeeServiceRequestReference(TEST_SERVICE_REFERENCE);
data.setApplicant1(
Applicant.builder()
.address(AddressGlobalUK.builder().addressLine1("test").build())
.build()
);

mockMvc.perform(post(ABOUT_TO_START_URL)
.contentType(APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ public AboutToStartOrSubmitResponse<CaseData, State> aboutToStart(final CaseDeta
log.info("Retrieving order summary");
final CaseData caseData = details.getData();

if (caseData.getApplicant1().getAddress() == null) {
return AboutToStartOrSubmitResponse.<CaseData, State>builder()
.data(caseData)
.errors(List.of("Please enter an address for the applicant using the 'Amend divorce application' event."))
.warnings(null)
.build();
}

var application = caseData.getApplication();
OrderSummary orderSummary = paymentSetupService.createApplicationFeeOrderSummary(caseData, details.getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import uk.gov.hmcts.ccd.sdk.api.CaseDetails;
import uk.gov.hmcts.ccd.sdk.api.Event;
import uk.gov.hmcts.ccd.sdk.api.callback.AboutToStartOrSubmitResponse;
import uk.gov.hmcts.ccd.sdk.type.AddressGlobalUK;
import uk.gov.hmcts.ccd.sdk.type.DynamicList;
import uk.gov.hmcts.ccd.sdk.type.DynamicListElement;
import uk.gov.hmcts.ccd.sdk.type.ListValue;
Expand Down Expand Up @@ -89,7 +90,8 @@ void shouldSetOrderSummaryAndSolicitorFeesInPoundsAndSolicitorRolesAndPbaNumbers

final long caseId = TEST_CASE_ID;
final CaseDetails<CaseData, State> caseDetails = new CaseDetails<>();
final CaseData caseData = CaseData.builder().build();
final CaseData caseData = validApplicant1CaseData();
caseData.getApplicant1().setAddress(AddressGlobalUK.builder().addressLine1("test").build());
caseDetails.setData(caseData);
caseDetails.setId(caseId);

Expand Down

0 comments on commit 258150c

Please sign in to comment.