Skip to content

Commit

Permalink
DTSCCI-1355: fix npe on defendent resp
Browse files Browse the repository at this point in the history
  • Loading branch information
rishikrsharma committed Dec 16, 2024
1 parent 8b3870b commit 1294376
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public boolean shouldRecordScenario(CaseData caseData) {

@Override
public String getScenario(CaseData caseData) {

if (caseData.getRespondent1ClaimResponseTypeForSpec() == null) {
return null;
}
return switch (caseData.getRespondent1ClaimResponseTypeForSpec()) {
case FULL_DEFENCE -> getFullDefenceScenario(caseData);
case FULL_ADMISSION -> getFullAdmissionScenario(caseData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_CLAIMANT_DASHBOARD_NOTIFICATION_FOR_DEFENDANT_RESPONSE;
Expand All @@ -54,13 +55,13 @@
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DEFENDANT_FULL_ADMIT_PAY_IMMEDIATELY_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DEFENDANT_FULL_OR_PART_ADMIT_PAY_SET_DATE_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DEFENDANT_FULL_OR_PART_ADMIT_PAY_SET_DATE_ORG_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DEFENDANT_RESPONSE_FULL_DEFENCE_FULL_DISPUTE_CLAIMANT_CARM;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DEFENDANT_RESPONSE_FULL_DEFENCE_FULL_DISPUTE_MEDIATION_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DEFENDANT_RESPONSE_FULLDISPUTE_MULTI_INT_FAST_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DEFENDANT_RESPONSE_FULL_DEFENCE_ALREADY_PAID_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DEFENDANT_RESPONSE_FULL_DEFENCE_FULL_DISPUTE_CLAIMANT_CARM;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_DEFENDANT_RESPONSE_FULL_DEFENCE_FULL_DISPUTE_MEDIATION_CLAIMANT;

@ExtendWith(MockitoExtension.class)
public class DefendantResponseClaimantNotificationHandlerTest extends BaseCallbackHandlerTest {
class DefendantResponseClaimantNotificationHandlerTest extends BaseCallbackHandlerTest {

@InjectMocks
private DefendantResponseClaimantNotificationHandler handler;
Expand Down Expand Up @@ -155,7 +156,7 @@ void configureDashboardNotificationsForDefendantResponseForFullAdmitPayByDate(En
CaseData caseData = CaseDataBuilder.builder().atStateRespondentFullAdmissionSpec().build()
.toBuilder()
.legacyCaseReference("reference")
.ccdCaseReference(Long.valueOf(23055L))
.ccdCaseReference(23055L)
.applicant1Represented(YesOrNo.NO)
.respondent1(Party.builder()
.type(Party.Type.valueOf(partyType.name())).build())
Expand Down Expand Up @@ -192,7 +193,7 @@ void configureDashboardNotificationsForDefendantResponseForFullAdmitImmediatelyC
CaseData caseData = CaseDataBuilder.builder().atStateRespondentFullAdmissionSpec().build()
.toBuilder()
.legacyCaseReference("reference")
.ccdCaseReference(Long.valueOf(1234L))
.ccdCaseReference(1234L)
.applicant1Represented(YesOrNo.NO)
.respondToClaimAdmitPartLRspec(RespondToClaimAdmitPartLRspec
.builder()
Expand Down Expand Up @@ -486,7 +487,7 @@ void configureDashboardNotificationsForDefendantResponseFullDefenceDisputeAllCla
CaseData caseData = CaseDataBuilder.builder().atStateRespondentFullDefenceSpec().build()
.toBuilder()
.legacyCaseReference("reference")
.ccdCaseReference(Long.valueOf(1234L))
.ccdCaseReference(1234L)
.applicant1Represented(YesOrNo.NO)
.respondent1(Party.builder().type(Party.Type.INDIVIDUAL).build())
.respondToClaimAdmitPartLRspec(RespondToClaimAdmitPartLRspec
Expand Down Expand Up @@ -514,4 +515,30 @@ void configureDashboardNotificationsForDefendantResponseFullDefenceDisputeAllCla
ScenarioRequestParams.builder().params(params).build()
);
}

@Test
void willNotConfigureDashboardNotificationsForDefendantResponseWhenRespondent1ClaimResponseTypeForSpecIsNull() {
//given
LocalDate paymentDate = OffsetDateTime.now().toLocalDate().minusDays(5);
CaseData caseData = CaseDataBuilder.builder().atStateRespondentFullDefenceSpec().build()
.toBuilder()
.legacyCaseReference("reference")
.ccdCaseReference(12345673L)
.applicant1Represented(YesOrNo.NO)
.responseClaimTrack(SMALL_CLAIM.name())
.respondToClaim(RespondToClaim.builder()
.howMuchWasPaid(new BigDecimal(1000))
.whenWasThisAmountPaid(paymentDate)
.build())
.totalClaimAmount(new BigDecimal(1500))
.build();

CallbackParams callbackParams = CallbackParamsBuilder.builder()
.of(ABOUT_TO_SUBMIT, caseData)
.build();
//when
handler.handle(callbackParams);
//then
verifyNoInteractions(dashboardApiClient);
}
}

0 comments on commit 1294376

Please sign in to comment.