Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
import uk.gov.hmcts.reform.pcs.ccd.service.PcsCaseService;
import uk.gov.hmcts.reform.pcs.ccd.service.genapp.GenAppService;
import uk.gov.hmcts.reform.pcs.ccd.service.party.PartyService;
import uk.gov.hmcts.reform.pcs.ccd.util.AddressFormatter;

import java.util.List;

import static uk.gov.hmcts.reform.pcs.ccd.accesscontrol.CaseworkerRoles.CASEWORKER_ROLES;
import static uk.gov.hmcts.reform.pcs.ccd.accesscontrol.JudicialHistoryRoles.JUDICIAL_HISTORY_ROLES;
import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.enterGenApp;
import static uk.gov.hmcts.reform.pcs.ccd.util.AddressFormatter.COMMA_DELIMITER;

@Component
@RequiredArgsConstructor
Expand All @@ -45,6 +47,7 @@ public class EnterGenApp implements CCDConfig<PCSCase, State, UserRole> {
private final PartyService partyService;
private final GenAppService genAppService;
private final ApplicationDetails applicationDetails;
private final AddressFormatter addressFormatter;

@Override
public void configureDecentralised(DecentralisedConfigBuilder<PCSCase, State, UserRole> configBuilder) {
Expand Down Expand Up @@ -111,7 +114,27 @@ private SubmitResponse<State> submit(EventPayload<PCSCase, State> eventPayload)

genAppService.createGenAppEntity(caseData, pcsCaseEntity, applicantParty, GenAppState.GEN_APP_ISSUED);

return SubmitResponse.<State>builder().build();
return SubmitResponse.<State>builder()
.confirmationBody(buildConfirmationMarkdown(
caseData, eventPayload.caseReference(), caseData.getCaseNameHmctsInternal()))
.build();
}

private String buildConfirmationMarkdown(PCSCase pcsCase, long caseReference, String caseName) {
String address = addressFormatter.formatShortAddress(pcsCase.getPropertyAddress(), COMMA_DELIMITER);
return """
---
<div class="govuk-panel govuk-panel--confirmation govuk-!-padding-top-3 govuk-!-padding-bottom-3">
<span class="govuk-panel__title govuk-!-font-size-36">Application entered</span><br>
<span class="govuk-panel__body">Case number: %s</span><br>
<span class="govuk-panel__body">%s</span>
<span class="govuk-panel__body">%s</span>
</div>

<h3 class="govuk-heading-s">What happens next</h3>
<p class="govuk-body govuk-!-margin-bottom-6">If the application was made without notice, only the applicant
will be informed. Otherwise, all parties will be informed.</p>
""".formatted(caseReference, address, caseName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import uk.gov.hmcts.ccd.sdk.api.callback.SubmitResponse;
import uk.gov.hmcts.ccd.sdk.type.DynamicList;
import uk.gov.hmcts.ccd.sdk.type.DynamicListElement;
import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase;
import uk.gov.hmcts.reform.pcs.ccd.domain.State;
import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo;
import uk.gov.hmcts.reform.pcs.ccd.domain.caseworker.EnterGenAppRequest;
import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity;
Expand All @@ -20,6 +22,7 @@
import uk.gov.hmcts.reform.pcs.ccd.service.PcsCaseService;
import uk.gov.hmcts.reform.pcs.ccd.service.genapp.GenAppService;
import uk.gov.hmcts.reform.pcs.ccd.service.party.PartyService;
import uk.gov.hmcts.reform.pcs.ccd.util.AddressFormatter;

import java.util.List;
import java.util.UUID;
Expand All @@ -45,10 +48,13 @@ class EnterGenAppTest extends BaseEventTest {
private ApplicationDetails applicationDetails;
@Mock
private GenAppService genAppService;
@Mock
private AddressFormatter addressFormatter;

@BeforeEach
void setUp() {
EnterGenApp enterGenApp = new EnterGenApp(pcsCaseService, partyService, genAppService, applicationDetails);
EnterGenApp enterGenApp = new EnterGenApp(pcsCaseService, partyService, genAppService, applicationDetails,
addressFormatter);
setEventUnderTest(enterGenApp);
}

Expand Down Expand Up @@ -136,14 +142,16 @@ void shouldCreateGenAppEntityOnSubmit() {
PCSCase caseData = PCSCase.builder()
.enterGenAppRequest(enterGenAppRequest)
.partyRadioList(partyRadioList)
.caseNameHmctsInternal("Smith v Doe")
.build();

// When
callSubmitHandler(caseData);
SubmitResponse<State> response = callSubmitHandler(caseData);

// Then
verify(genAppService)
.createGenAppEntity(caseData, pcsCaseEntity, applicantParty, GEN_APP_ISSUED);
assertThat(response.getConfirmationBody()).contains("Smith v Doe");
}

}