Skip to content

Commit

Permalink
CIV-11105 (#2787)
Browse files Browse the repository at this point in the history
* CIV-11105 pilot court not populated when claimant rejects mediation

* clean up code
  • Loading branch information
zikrurR authored Oct 31, 2023
1 parent 535f3a5 commit 9d7f487
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 44 deletions.
7 changes: 6 additions & 1 deletion config/owasp/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@
<cve>CVE-2020-5408</cve>
<cve>CVE-2016-1000027</cve>
<cve>CVE-2023-41080</cve>
<cve>CVE-2023-31419</cve>
<cve>CVE-2023-31418</cve>
<cve>CVE-2023-5072</cve>
<cve>CVE-2023-42795</cve>
<cve>CVE-2023-45648</cve>
</suppress>
<suppress until="2023-04-18">
<cve>CVE-2023-20860</cve>
</suppress>
</suppressions>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.springframework.stereotype.Service;
import uk.gov.hmcts.cmc.ccd.domain.CaseEvent;
import uk.gov.hmcts.cmc.claimstore.services.pilotcourt.PilotCourtService;
import uk.gov.hmcts.cmc.domain.models.Claim;
import uk.gov.hmcts.cmc.domain.models.claimantresponse.ClaimantResponse;
import uk.gov.hmcts.cmc.domain.models.claimantresponse.ResponseRejection;
Expand All @@ -18,8 +17,6 @@
import static uk.gov.hmcts.cmc.ccd.domain.CaseEvent.DIRECTIONS_QUESTIONNAIRE_DEADLINE;
import static uk.gov.hmcts.cmc.ccd.domain.CaseEvent.REFERRED_TO_MEDIATION;
import static uk.gov.hmcts.cmc.ccd.domain.CaseEvent.WAITING_TRANSFER;
import static uk.gov.hmcts.cmc.claimstore.services.pilotcourt.Pilot.JDDO;
import static uk.gov.hmcts.cmc.claimstore.services.pilotcourt.Pilot.LA;
import static uk.gov.hmcts.cmc.claimstore.utils.ClaimantResponseHelper.isOptedForMediation;
import static uk.gov.hmcts.cmc.claimstore.utils.TheirDetailsHelper.isDefendantBusiness;
import static uk.gov.hmcts.cmc.claimstore.utils.TheirDetailsHelper.isDefendantIndividual;
Expand All @@ -36,10 +33,8 @@

@Service
public class DirectionsQuestionnaireService {
private final PilotCourtService pilotCourtService;

public DirectionsQuestionnaireService(PilotCourtService pilotCourtService) {
this.pilotCourtService = pilotCourtService;
public DirectionsQuestionnaireService() {
}

public CaseEvent prepareCaseEvent(ResponseRejection responseRejection, Claim claim) {
Expand All @@ -51,13 +46,11 @@ public CaseEvent prepareCaseEvent(ResponseRejection responseRejection, Claim cla
return DIRECTIONS_QUESTIONNAIRE_DEADLINE;
}

String preferredCourt = getPreferredCourt(claim);

if (isLegalAdvisorPilot(claim) && pilotCourtService.isPilotCourt(preferredCourt, LA, claim.getCreatedAt())) {
if (isLegalAdvisorPilot(claim)) {
return ASSIGNING_FOR_LEGAL_ADVISOR_DIRECTIONS;
}

if (isJudgePilot(claim) && pilotCourtService.isPilotCourt(preferredCourt, JDDO, claim.getCreatedAt())) {
if (isJudgePilot(claim)) {
return ASSIGNING_FOR_JUDGE_DIRECTIONS;
}

Expand All @@ -66,13 +59,11 @@ public CaseEvent prepareCaseEvent(ResponseRejection responseRejection, Claim cla

public String getDirectionsCaseState(Claim claim) {

String preferredCourt = getPreferredCourt(claim);

if (isLegalAdvisorPilot(claim) && pilotCourtService.isPilotCourt(preferredCourt, LA, claim.getCreatedAt())) {
if (isLegalAdvisorPilot(claim)) {
return READY_FOR_LEGAL_ADVISOR_DIRECTIONS.getValue();
}

if (isJudgePilot(claim) && pilotCourtService.isPilotCourt(preferredCourt, JDDO, claim.getCreatedAt())) {
if (isJudgePilot(claim)) {
return READY_FOR_JUDGE_DIRECTIONS.getValue();
}

Expand Down Expand Up @@ -134,4 +125,4 @@ private static String getClaimantHearingCourt(ClaimantResponse claimantResponse)
throw new IllegalStateException("No preferred court as claimant response is not rejection.");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import uk.gov.hmcts.cmc.claimstore.services.ccd.callbacks.CallbackHandler;
import uk.gov.hmcts.cmc.claimstore.services.ccd.callbacks.CallbackParams;
import uk.gov.hmcts.cmc.claimstore.services.ccd.callbacks.CallbackType;
import uk.gov.hmcts.cmc.claimstore.services.pilotcourt.PilotCourtService;
import uk.gov.hmcts.cmc.claimstore.utils.CaseDetailsConverter;
import uk.gov.hmcts.cmc.domain.models.Address;
import uk.gov.hmcts.cmc.domain.models.Claim;
Expand All @@ -50,8 +49,6 @@
import static uk.gov.hmcts.cmc.claimstore.services.ccd.Role.CASEWORKER;
import static uk.gov.hmcts.cmc.claimstore.services.ccd.callbacks.CallbackParams.Params.BEARER_TOKEN;
import static uk.gov.hmcts.cmc.claimstore.services.ccd.callbacks.caseworker.PaperResponseOCON9xFormCallbackHandler.OCON9X_SUBTYPE;
import static uk.gov.hmcts.cmc.claimstore.services.pilotcourt.Pilot.JDDO;
import static uk.gov.hmcts.cmc.claimstore.services.pilotcourt.Pilot.LA;

@Service
public class PaperResponseFullDefenceCallbackHandler extends CallbackHandler {
Expand All @@ -68,7 +65,6 @@ public class PaperResponseFullDefenceCallbackHandler extends CallbackHandler {
private final CaseEventService caseEventService;
private final LaunchDarklyClient launchDarklyClient;
private final DefenceResponseNotificationService defenceResponseNotificationService;
private final PilotCourtService pilotCourtService;

public PaperResponseFullDefenceCallbackHandler(CaseDetailsConverter caseDetailsConverter, Clock clock,
EventProducer eventProducer, CaseMapper caseMapper,
Expand All @@ -77,8 +73,7 @@ public PaperResponseFullDefenceCallbackHandler(CaseDetailsConverter caseDetailsC
CaseEventService caseEventService,
LaunchDarklyClient launchDarklyClient,
DefenceResponseNotificationService
defenceResponseNotificationService,
PilotCourtService pilotCourtService) {
defenceResponseNotificationService) {
this.caseDetailsConverter = caseDetailsConverter;
this.clock = clock;
this.eventProducer = eventProducer;
Expand All @@ -88,7 +83,6 @@ public PaperResponseFullDefenceCallbackHandler(CaseDetailsConverter caseDetailsC
this.caseEventService = caseEventService;
this.launchDarklyClient = launchDarklyClient;
this.defenceResponseNotificationService = defenceResponseNotificationService;
this.pilotCourtService = pilotCourtService;
}

protected Map<CallbackType, Callback> callbacks() {
Expand Down Expand Up @@ -149,7 +143,7 @@ private CallbackResponse aboutToSubmit(CallbackParams callbackParams) {
caseDetailsConverter.calculateIntentionToProceedDeadline(LocalDateTime.now(clock));

if (!StringUtils.isBlank(ccdCase.getPreferredDQCourt())) {
preferredDQPilotCourt = getpreferredDQPilotCourt(ccdCase.getPreferredDQCourt(), ccdCase.getSubmittedOn());
preferredDQPilotCourt = ccdCase.getPreferredDQCourt();
}

CCDCase updatedCcdCase = ccdCase.toBuilder()
Expand Down Expand Up @@ -368,12 +362,4 @@ public List<Role> getSupportedRoles() {
return ROLES;
}

private String getpreferredDQPilotCourt(String courtName, LocalDateTime createdOn) {
if (pilotCourtService.isPilotCourt(courtName, LA, createdOn)
|| pilotCourtService.isPilotCourt(courtName, JDDO, createdOn)) {
return courtName;
} else {
return null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import uk.gov.hmcts.cmc.ccd.domain.CaseEvent;
import uk.gov.hmcts.cmc.claimstore.services.pilotcourt.PilotCourtService;
import uk.gov.hmcts.cmc.domain.models.Claim;
import uk.gov.hmcts.cmc.domain.models.claimantresponse.ResponseAcceptation;
import uk.gov.hmcts.cmc.domain.models.claimantresponse.ResponseRejection;
Expand All @@ -23,9 +21,6 @@
import uk.gov.hmcts.cmc.domain.models.sampledata.SampleClaimData;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import static uk.gov.hmcts.cmc.ccd.domain.CaseEvent.ASSIGNING_FOR_JUDGE_DIRECTIONS;
import static uk.gov.hmcts.cmc.ccd.domain.CaseEvent.ASSIGNING_FOR_LEGAL_ADVISOR_DIRECTIONS;
import static uk.gov.hmcts.cmc.ccd.domain.CaseEvent.DIRECTIONS_QUESTIONNAIRE_DEADLINE;
Expand Down Expand Up @@ -122,15 +117,11 @@ public class DirectionsQuestionnaireServiceTest {
)
.build();

@Mock
private PilotCourtService pilotCourtService;

private DirectionsQuestionnaireService directionsQuestionnaireService;

@Before
public void setUp() {
when(pilotCourtService.isPilotCourt(eq(PILOT_COURT_NAME), any(), any())).thenReturn(true);
directionsQuestionnaireService = new DirectionsQuestionnaireService(pilotCourtService);
directionsQuestionnaireService = new DirectionsQuestionnaireService();
}

@Test
Expand Down Expand Up @@ -547,4 +538,4 @@ public void shouldReturnNullIfDQNotPresent() {

assertThat(directionsQuestionnaireService.getPreferredIndieSolCourt(claim)).isEqualTo(null);
}
}
}

0 comments on commit 9d7f487

Please sign in to comment.