Skip to content

Commit

Permalink
CIV-11161 - Docmosis: Manual Determination -"Claimant's Response" (#3656
Browse files Browse the repository at this point in the history
)

* CIV-11571 Fix court location if no specific court (#3569)

* CIV-11571: Add null checking

* CIV-11571: Add unit test

---------

Co-authored-by: jarekPierchala <[email protected]>

* CIV-8241 Manual Determination - Lip Notifications (#3529)

* added changes for claimant response cui event.

* CIV-8291 : Functional code - Need to refactor

* CIV-8291 : Refactor duplicated methods to a common service

* CIV-8291 : Handler Test

* CIV-8291 : Fix checkStyle

* CIV-8291 : Fix checkStyle

* CIV-8291 : Adding mocks

* CIV-8291 : Adding mocks

* CIV-8291 : Adding mocks

* CIV-8291 : Change final state to PROCEEDS_IN_HERITAGE_SYSTEM

* CIV-8291 : Dev comments

* CIV-8291 : Dev comments

* CIV-8291 : Dev comments

* CIV-8291 : Dev comments

* CIV-8241: Set Up Notification

* CIV-8241: Set Up Notification

* CIV-8241: Set Up Notification

* CIV-8241: Set Up Notification

* CIV-8241: Set Up Notification

* CIV-8241: Set Up Notification Test

* CIV-8241: Set Up Notification Test

* CIV-8241: Roll back one line

* CIV-8241: Change method name

* Update build.gradle

* Update build.gradle

---------

Co-authored-by: neeta-hmcts <[email protected]>
Co-authored-by: sankhajuria <[email protected]>
Co-authored-by: hmcts-version1-pablo <[email protected]>
Co-authored-by: Pablo Ortiz <[email protected]>
Co-authored-by: Raja Mani <[email protected]>
Co-authored-by: jarekPierchala <[email protected]>

* CIV-10727 Assisted order uplift (#3550)

* CIV-11158 Save hearing location in case data
* Added setting assisted order courtLocation to hearingLocation or caseManagementLocation is hearingLocation is not defined
* Fixed not filtering courtLocations by caseTypeId
---------

Co-authored-by: sankaviv1 <[email protected]>
Co-authored-by: sankaviv1 <[email protected]>
Co-authored-by: GarethLancaster <[email protected]>
Co-authored-by: douglasrice <[email protected]>

* CIV-11695 - Update ClaimantResponseCuiCallbackHandler.java (#3616)

* Update ClaimantResponseCuiCallbackHandler.java

* fix for judicial referral

* fixed claim state issue and unit tests.

---------

Co-authored-by: neeta-hmcts <[email protected]>
Co-authored-by: neeta-hmcts <[email protected]>
Co-authored-by: Pablo Ortiz <[email protected]>
Co-authored-by: annika-moorthy <[email protected]>

* CIV-8905 Claimant Dashboard Status "Mediation E2E, Manual Determination (org), ITP failed" (#3564)

* CIV-8905 Added functionality for dashboard status

* CIV-8905 Added functionality for dashboard status

* CIV-8905 Fixed AC 4

* CIV-11363 add trigger event (#3633)

* CIV-11363 add trigger event

* CIV-8905 Merged with bulk_tasks

---------

Co-authored-by: Pablo Ortiz <[email protected]>
Co-authored-by: MMNycz <[email protected]>

* CIV-8454 Trigger service request after CCD case creation (#3597)

* CIV-8454 Trigger service request after CCD case creation

* CIV-8454 Move Service Request creation to Camunda

* CIV-8454 Undo flow state change - not required

* CIV-8454 Remove empty lines

* CIV-8454 Add test for service request handler CUI

* CIV-8454 Only create service request when no help with fees

* CIV-8454 Change event name

* CIV-11144 updated witness summary to add date (#3623)

* updated witness summary to add date

* Update Jenkinsfile_CNP point at CCD

* Update Jenkinsfile_CNP

* CIV-11363 add caseId to caseIdForRetrigger.txt (#3646)

* CIV-11363 add caseId to caseIdForRetrigger.txt

* adding not suitable for sdo too

* update caseIdForRetriger

---------

Co-authored-by: Astha Malviya <[email protected]>

* testing master build (#3650)

Co-authored-by: sankhajuria <[email protected]>

---------

Co-authored-by: Raja Mani <[email protected]>
Co-authored-by: drummondjm <[email protected]>
Co-authored-by: MMNycz <[email protected]>
Co-authored-by: Astha Malviya <[email protected]>
Co-authored-by: asthamalviya <[email protected]>
Co-authored-by: sankhajuria <[email protected]>
Co-authored-by: jarekPierchala <[email protected]>

* CIV-11161 docmosis form generate

* CIV-11161 build issue fixed

* CIV-11161 checkstyle issue fix

* CIV-11161 test code updated

* CIV-11161 test case updated

* CIV-11161 - testcase updated

* CIV-11161 review comments fixed

* CIV-11161 common jar version updated

* CIV-11161 common jar version updated

* CIV-11161 common jar version updated

* CIV-11161 common jar version updated

* CIV-11161 rebase issue fixed

---------

Co-authored-by: jarekPierchala <[email protected]>
Co-authored-by: kenneth-hmcts <[email protected]>
Co-authored-by: jarekPierchala <[email protected]>
Co-authored-by: neeta-hmcts <[email protected]>
Co-authored-by: sankhajuria <[email protected]>
Co-authored-by: hmcts-version1-pablo <[email protected]>
Co-authored-by: Pablo Ortiz <[email protected]>
Co-authored-by: Raja Mani <[email protected]>
Co-authored-by: Gareth Lancaster <[email protected]>
Co-authored-by: sankaviv1 <[email protected]>
Co-authored-by: sankaviv1 <[email protected]>
Co-authored-by: GarethLancaster <[email protected]>
Co-authored-by: douglasrice <[email protected]>
Co-authored-by: jeswanth-hmcts <[email protected]>
Co-authored-by: neeta-hmcts <[email protected]>
Co-authored-by: annika-moorthy <[email protected]>
Co-authored-by: marianadpereira <[email protected]>
Co-authored-by: Manish Garg <[email protected]>
Co-authored-by: MMNycz <[email protected]>
Co-authored-by: Paul Pearson <[email protected]>
Co-authored-by: drummondjm <[email protected]>
Co-authored-by: Astha Malviya <[email protected]>
Co-authored-by: asthamalviya <[email protected]>
Co-authored-by: Harry H <[email protected]>
Co-authored-by: marianadpereira <[email protected]>
  • Loading branch information
1 parent f1c52ba commit 69b1bc9
Show file tree
Hide file tree
Showing 12 changed files with 576 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ configurations.all {
}

dependencies {
implementation 'com.github.hmcts:civil-commons:1.0.42'
implementation 'com.github.hmcts:civil-commons:V1.0.41-9040-1412'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ public enum CaseEvent {
SEND_HEARING_TO_LIP_CLAIMANT(CAMUNDA),
SEND_FINAL_ORDER_TO_LIP_DEFENDANT(CAMUNDA),
SEND_FINAL_ORDER_TO_LIP_CLAIMANT(CAMUNDA),
RETRIGGER_CASES(CAMUNDA),
GENERATE_LIP_CLAIMANT_MANUAL_DETERMINATION(CAMUNDA);


RETRIGGER_CASES(CAMUNDA);
private final UserType userType;

public boolean isCamundaEvent() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.docmosis;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse;
import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.callback.CallbackHandler;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.Callback;
import uk.gov.hmcts.reform.civil.callback.CallbackType;
import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.SystemGeneratedDocumentService;
import uk.gov.hmcts.reform.civil.service.docmosis.manualdetermination.ClaimantLipManualDeterminationFormGenerator;

import java.util.Collections;
import java.util.List;
import java.util.Map;

import static uk.gov.hmcts.reform.civil.callback.CallbackParams.Params.BEARER_TOKEN;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.GENERATE_LIP_CLAIMANT_MANUAL_DETERMINATION;

@Service
@RequiredArgsConstructor
public class GenerateClaimantLipManualDeterminationCallBackHandler extends CallbackHandler {

private static final List<CaseEvent> EVENTS = Collections.singletonList(GENERATE_LIP_CLAIMANT_MANUAL_DETERMINATION);
private static final String TASK_ID = "Generate_LIP_Claimant_MD";
private final ObjectMapper objectMapper;
private final ClaimantLipManualDeterminationFormGenerator claimantLipManualDeterminationFormGenerator;
private final SystemGeneratedDocumentService systemGeneratedDocumentService;
private final Map<String, Callback> callbackMap = Map.of(callbackKey(CallbackType.ABOUT_TO_SUBMIT),
this::prepareClaimantLipManualDetermination);

@Override
public String camundaActivityId(CallbackParams callbackParams) {
return TASK_ID;
}

@Override
protected Map<String, Callback> callbacks() {
return callbackMap;
}

@Override
public List<CaseEvent> handledEvents() {
return EVENTS;
}

private CallbackResponse prepareClaimantLipManualDetermination(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();

if (!caseData.getRespondent1().isCompanyOROrganisation()) {
return AboutToStartOrSubmitCallbackResponse.builder().build();
}

CaseData.CaseDataBuilder<?, ?> caseDataBuilder = caseData.toBuilder();
CaseDocument claimantResponseForm = claimantLipManualDeterminationFormGenerator.generate(callbackParams.getCaseData(),
callbackParams.getParams().get(BEARER_TOKEN).toString());
caseDataBuilder.systemGeneratedCaseDocuments(systemGeneratedDocumentService
.getSystemGeneratedDocumentsWithAddedDocument(claimantResponseForm, caseData));
return AboutToStartOrSubmitCallbackResponse.builder().data(caseDataBuilder.build().toMap(objectMapper)).build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package uk.gov.hmcts.reform.civil.model.docmosis.manualdetermination;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import uk.gov.hmcts.reform.civil.enums.PaymentType;
import uk.gov.hmcts.reform.civil.enums.RespondentResponseTypeSpec;
import uk.gov.hmcts.reform.civil.model.common.MappableObject;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Getter
@Builder
@AllArgsConstructor
@EqualsAndHashCode
public class ClaimantLipManualDeterminationForm implements MappableObject {

private final String referenceNumber;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
@JsonSerialize(using = LocalDateSerializer.class)
private final LocalDate claimIssueDate;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd MMMM yyyy 'at' HH:mm a")
@JsonSerialize(using = LocalDateTimeSerializer.class)
private final LocalDateTime claimantResponseSubmitDate;
@JsonFormat(shape = JsonFormat.Shape.STRING)
private final BigDecimal defendantAdmittedAmount;
private final PaymentType repaymentType;
@JsonFormat(shape = JsonFormat.Shape.STRING)
private BigDecimal regularPaymentAmount;
private String repaymentFrequency;
private final String claimantRequestRepaymentBy;
private final RespondentResponseTypeSpec claimResponseType;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
@JsonSerialize(using = LocalDateSerializer.class)
private final LocalDate firstRepaymentDate;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
@JsonSerialize(using = LocalDateSerializer.class)
private final LocalDate lastRepaymentDate;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
@JsonSerialize(using = LocalDateSerializer.class)
private final LocalDate paymentSetDateForDefendant;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public enum DocmosisTemplates {

// judge final Order
FREE_FORM_ORDER_PDF("CV-UNS-DEC-ENG-01099.docx", "Order_%s.pdf"),
ASSISTED_ORDER_PDF("CV-UNS-DEC-ENG-01283.docx", "Order_%s.pdf");
ASSISTED_ORDER_PDF("CV-UNS-DEC-ENG-01283.docx", "Order_%s.pdf"),
CLAIMANT_LIP_MANUAL_DETERMINATION_PDF("CV-SPC-CLM-ENG-00001-LIP-MD.docx", "%s_request-org-repayment-amount.pdf");
private final String template;
private final String documentTitle;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package uk.gov.hmcts.reform.civil.service.docmosis.manualdetermination;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.civil.documentmanagement.DocumentManagementService;
import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument;
import uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType;
import uk.gov.hmcts.reform.civil.documentmanagement.model.PDF;
import uk.gov.hmcts.reform.civil.enums.PaymentFrequencyClaimantResponseLRspec;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.PaymentBySetDate;
import uk.gov.hmcts.reform.civil.model.docmosis.DocmosisDocument;
import uk.gov.hmcts.reform.civil.model.docmosis.manualdetermination.ClaimantLipManualDeterminationForm;
import uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates;
import uk.gov.hmcts.reform.civil.service.docmosis.DocumentGeneratorService;
import uk.gov.hmcts.reform.civil.service.docmosis.TemplateDataGenerator;
import uk.gov.hmcts.reform.civil.service.docmosis.utils.ClaimantResponseUtils;

import java.time.LocalDate;

import static java.util.Objects.nonNull;
import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.CLAIMANT_LIP_MANUAL_DETERMINATION_PDF;

@Service
@Getter
@RequiredArgsConstructor
public class ClaimantLipManualDeterminationFormGenerator implements TemplateDataGenerator<ClaimantLipManualDeterminationForm> {

private final DocumentManagementService documentManagementService;
private final DocumentGeneratorService documentGeneratorService;

public CaseDocument generate(CaseData caseData, String authorisation) {
ClaimantLipManualDeterminationForm templateData = getTemplateData(caseData);
DocmosisTemplates template = getDocmosisTemplate();
DocmosisDocument docmosisDocument = documentGeneratorService.generateDocmosisDocument(templateData, template);
PDF lipManualDeterminationPdf = new PDF(getFileName(template, caseData), docmosisDocument.getBytes(), DocumentType.LIP_MANUAL_DETERMINATION);
return documentManagementService.uploadDocument(
authorisation,
lipManualDeterminationPdf);
}

private String getFileName(DocmosisTemplates template, CaseData caseData) {
return String.format(template.getDocumentTitle(), caseData.getLegacyCaseReference());
}

@Override
public ClaimantLipManualDeterminationForm getTemplateData(CaseData caseData) {
ClaimantLipManualDeterminationForm.ClaimantLipManualDeterminationFormBuilder
manualDeterminationForm = ClaimantLipManualDeterminationForm.builder()
.referenceNumber(caseData.getLegacyCaseReference())
.claimIssueDate(caseData.getIssueDate())
.claimantResponseSubmitDate(caseData.getApplicant1ResponseDate())
.defendantAdmittedAmount(caseData.getRespondToAdmittedClaimOwingAmountPounds())
.claimantRequestRepaymentBy(ClaimantResponseUtils.getClaimantRepaymentType(caseData))
.claimResponseType(caseData.getRespondent1ClaimResponseTypeForSpec())
.regularPaymentAmount(caseData.getApplicant1SuggestInstalmentsPaymentAmountForDefendantSpec())
.repaymentFrequency(getRepaymentFrequency(caseData.getApplicant1SuggestInstalmentsRepaymentFrequencyForDefendantSpec()))
.repaymentType(caseData.getApplicant1RepaymentOptionForDefendantSpec())
.firstRepaymentDate(caseData.getApplicant1SuggestInstalmentsFirstRepaymentDateForDefendantSpec())
.lastRepaymentDate(ClaimantResponseUtils.getClaimantFinalRepaymentDate(caseData))
.paymentSetDateForDefendant(getRepaymentSetByDate(caseData.getApplicant1RequestedPaymentDateForDefendantSpec()));
return manualDeterminationForm.build();
}

private DocmosisTemplates getDocmosisTemplate() {
return CLAIMANT_LIP_MANUAL_DETERMINATION_PDF;
}

private String getRepaymentFrequency(PaymentFrequencyClaimantResponseLRspec claimantSuggestedRepaymentFrequency) {
return (nonNull(claimantSuggestedRepaymentFrequency)) ? claimantSuggestedRepaymentFrequency.getLabel() : null;
}

private LocalDate getRepaymentSetByDate(PaymentBySetDate paymentBySetDate) {
return (nonNull(paymentBySetDate)) ? paymentBySetDate.getPaymentSetDate() : null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package uk.gov.hmcts.reform.civil.service.docmosis.utils;

import uk.gov.hmcts.reform.civil.enums.PaymentFrequencyClaimantResponseLRspec;
import uk.gov.hmcts.reform.civil.enums.PaymentType;
import uk.gov.hmcts.reform.civil.model.CaseData;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;

import static java.util.Objects.isNull;

public class ClaimantResponseUtils {

private ClaimantResponseUtils() {
//NO-OP
}

public static String getClaimantRepaymentType(CaseData caseData) {
PaymentType claimantRepaymentOption = caseData.getApplicant1RepaymentOptionForDefendantSpec();
if (claimantRepaymentOption == null) {
return "No payment type selected";
}
if (claimantRepaymentOption == PaymentType.REPAYMENT_PLAN) {
return "By installments";
} else {
return claimantRepaymentOption.getDisplayedValue();
}
}

public static LocalDate getClaimantFinalRepaymentDate(CaseData caseData) {
BigDecimal paymentAmount = caseData.getApplicant1SuggestInstalmentsPaymentAmountForDefendantSpec();
LocalDate firstRepaymentDate = caseData.getApplicant1SuggestInstalmentsFirstRepaymentDateForDefendantSpec();
PaymentFrequencyClaimantResponseLRspec repaymentFrequency = caseData.getApplicant1SuggestInstalmentsRepaymentFrequencyForDefendantSpec();

BigDecimal claimantTotalAmount = caseData.getTotalClaimAmount();
if (isNull(firstRepaymentDate) || isNull(paymentAmount) || isNull(repaymentFrequency)) {
return null;
}
long numberOfInstallmentsAfterFirst = getNumberOfInstallmentsAfterFirst(claimantTotalAmount, paymentAmount);

return switch (repaymentFrequency) {
case ONCE_ONE_WEEK -> firstRepaymentDate.plusWeeks(numberOfInstallmentsAfterFirst);
case ONCE_TWO_WEEKS -> firstRepaymentDate.plusWeeks(2 * numberOfInstallmentsAfterFirst);
default -> firstRepaymentDate.plusMonths(numberOfInstallmentsAfterFirst);
};
}

private static long getNumberOfInstallmentsAfterFirst(BigDecimal totalAmount, BigDecimal paymentAmount) {
return totalAmount.divide(paymentAmount, 0, RoundingMode.CEILING).longValue() - 1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.docmosis;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument;
import uk.gov.hmcts.reform.civil.documentmanagement.model.Document;
import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.Party;
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder;
import uk.gov.hmcts.reform.civil.sampledata.PartyBuilder;
import uk.gov.hmcts.reform.civil.service.SystemGeneratedDocumentService;
import uk.gov.hmcts.reform.civil.service.docmosis.manualdetermination.ClaimantLipManualDeterminationFormGenerator;

import java.time.LocalDateTime;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.GENERATE_LIP_CLAIMANT_MANUAL_DETERMINATION;
import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.LIP_MANUAL_DETERMINATION;

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = {
GenerateClaimantLipManualDeterminationCallBackHandler.class,
JacksonAutoConfiguration.class
})
class GenerateClaimantLipManualDeterminationCallBackHandlerTest extends BaseCallbackHandlerTest {

private static final String BEARER_TOKEN = "BEARER_TOKEN";
private static final CaseDocument FORM = CaseDocument.builder()
.createdBy("John")
.documentName("document name")
.documentSize(0L)
.documentType(LIP_MANUAL_DETERMINATION)
.createdDatetime(LocalDateTime.now())
.documentLink(Document.builder()
.documentUrl("fake-url")
.documentFileName("file-name")
.documentBinaryUrl("binary-url")
.build())
.build();
@Autowired
private final ObjectMapper mapper = new ObjectMapper();
@Autowired
private GenerateClaimantLipManualDeterminationCallBackHandler handler;
@MockBean
private ClaimantLipManualDeterminationFormGenerator lipManualDeterminationHandlerFormGenerator;
@MockBean
private SystemGeneratedDocumentService systemGeneratedDocumentService;

@Test
void shouldGenerateForm_whenAboutToSubmitCalled() {
given(lipManualDeterminationHandlerFormGenerator.generate(any(CaseData.class), anyString())).willReturn(FORM);

CaseData caseData = CaseDataBuilder.builder()
.respondent1(PartyBuilder.builder()
.soleTrader().build().toBuilder()
.type(Party.Type.COMPANY)
.build())
.build();

handler.handle(callbackParamsOf(caseData, ABOUT_TO_SUBMIT));
verify(lipManualDeterminationHandlerFormGenerator).generate(caseData, BEARER_TOKEN);
}

@Test
void shouldNotGenerateForm_whenPartyTypeIsNotCompanyORNotOrganisation() {
given(lipManualDeterminationHandlerFormGenerator.generate(any(CaseData.class), anyString())).willReturn(FORM);

CaseData caseData = CaseDataBuilder.builder()
.respondent1(PartyBuilder.builder()
.soleTrader().build().toBuilder()
.type(Party.Type.SOLE_TRADER)
.build())
.build();

CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT);
params.getRequest().setEventId(GENERATE_LIP_CLAIMANT_MANUAL_DETERMINATION.name());

handler.handle(params);
verify(lipManualDeterminationHandlerFormGenerator, never()).generate(any(CaseData.class), anyString());
verify(systemGeneratedDocumentService, never()).getSystemGeneratedDocumentsWithAddedDocument(any(CaseDocument.class), any(CaseData.class));
}

@Test
void shouldReturnCorrectActivityId_whenRequestedMDForm() {
CaseData caseData = CaseDataBuilder.builder().atStatePendingClaimIssued().build();

CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT);

assertThat(handler.camundaActivityId(params)).isEqualTo("Generate_LIP_Claimant_MD");
}

@Test
void testHandledEvents() {
assertThat(handler.handledEvents()).contains(GENERATE_LIP_CLAIMANT_MANUAL_DETERMINATION);
}
}
Loading

0 comments on commit 69b1bc9

Please sign in to comment.