Skip to content

Commit 860a450

Browse files
authored
Applicant DQ changes (#2019)
* fixing respondent dq bug * refactoring applicant dq code * removing unused method parameters * removing unused method parameters * unit test updates * fixing checkstyle * improving unit test coverage * improving unit test coverage
1 parent 1cdcdcf commit 860a450

File tree

3 files changed

+412
-14
lines changed

3 files changed

+412
-14
lines changed

src/main/java/uk/gov/hmcts/reform/civil/utils/CaseMigrationUtility.java

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ && ofNullable(respondent1DQ.getRespondent1DQRequestedCourt().getResponseCourtCod
273273
.caseLocation(caseLocation)
274274
.build()).build());
275275

276+
} else if (ofNullable(respondent1DQ).isPresent()) {
277+
log.warn("migrateRespondent1DQUnSpec: No condition fulfilled: {}", oldCaseData.getCcdCaseReference());
276278
}
277279
log.info("Migrate respondent 1 DQ end unpec end");
278280
}
@@ -315,24 +317,34 @@ && ofNullable(respondent2DQ.getRespondent2DQRequestedCourt().getResponseCourtCod
315317
.respondent2DQRequestedCourt(RequestedCourt.builder()
316318
.caseLocation(caseLocation)
317319
.build()).build());
318-
} else {
319-
log.warn("migrateRespondent2DQUnSpec: No if condition succeeded.");
320+
} else if (ofNullable(respondent2DQ).isPresent()) {
321+
log.warn("migrateRespondent2DQUnSpec: No condition fulfilled: {}", oldCaseData.getCcdCaseReference());
320322
}
321323
}
322324

323325
// Applicable for Respondent1 and Respondent2
324326
private void migrateApplicant1DQ(String authToken, CaseData oldCaseData,
325327
CaseData.CaseDataBuilder<?, ?> caseDataBuilder,
326328
CaseLocation caseLocation) {
329+
if (CaseCategory.SPEC_CLAIM.equals(oldCaseData.getCaseAccessCategory())) {
330+
migrateSpecApplicant1DQ(oldCaseData, authToken, caseDataBuilder, caseLocation);
331+
} else {
332+
migrateUnSpecApplicant1DQ(oldCaseData, authToken, caseDataBuilder);
333+
}
334+
}
327335

336+
private void migrateSpecApplicant1DQ(CaseData oldCaseData,
337+
String authToken,
338+
CaseData.CaseDataBuilder<?, ?> caseDataBuilder,
339+
CaseLocation caseLocation) {
328340
Applicant1DQ applicant1DQ = oldCaseData.getApplicant1DQ();
329-
341+
//if court location was selected in applicant DQ for spec claim
330342
if (ofNullable(applicant1DQ).isPresent()
331343
&& ofNullable(applicant1DQ.getApplicant1DQRequestedCourt()).isPresent()
332344
&& ofNullable(applicant1DQ.getApplicant1DQRequestedCourt().getResponseCourtCode()).isPresent()) {
333345
log.info("migrateApplicant1DQ Fetch data from LRD preferred code : {}, Ref : {} ",
334346
applicant1DQ.getApplicant1DQRequestedCourt()
335-
.getResponseCourtCode(), oldCaseData.getCcdCaseReference());
347+
.getResponseCourtCode(), oldCaseData.getCcdCaseReference());
336348
LocationRefData refdata = locationRefDataService.getCourtLocation(
337349
authToken,
338350
applicant1DQ.getApplicant1DQRequestedCourt()
@@ -353,22 +365,33 @@ && ofNullable(applicant1DQ.getApplicant1DQRequestedCourt().getResponseCourtCode(
353365
.caseLocation(location)
354366
.responseCourtCode(
355367
refdata.getCourtLocationCode())
356-
.build()).build());
368+
.build()).build());
369+
//if court was not selected in applicant DQ for spec claim then setting to a fixed location
357370
} else if (ofNullable(applicant1DQ).isPresent()
358-
&& CaseCategory.SPEC_CLAIM.equals(oldCaseData.getCaseAccessCategory())
359-
&& ofNullable(applicant1DQ.getExperts()).isPresent()) {
371+
&& (ofNullable(applicant1DQ.getExperts()).isPresent()
372+
|| ofNullable(applicant1DQ.getApplicant1DQStatementOfTruth()).isPresent())) {
360373

361374
caseDataBuilder.applicant1DQ(applicant1DQ.toBuilder()
362375
.applicant1DQRequestedCourt(RequestedCourt.builder()
363376
.caseLocation(caseLocation)
364377
.responseCourtCode("335")
365378
.build()).build());
366379

367-
} else if (ofNullable(applicant1DQ).isPresent() && ofNullable(oldCaseData.getCourtLocation()).isPresent()
368-
&& ofNullable(applicant1DQ.getExperts()).isPresent()) {
380+
}
381+
382+
}
383+
384+
private void migrateUnSpecApplicant1DQ(CaseData oldCaseData,
385+
String authToken,
386+
CaseData.CaseDataBuilder<?, ?> caseDataBuilder) {
387+
Applicant1DQ applicant1DQ = oldCaseData.getApplicant1DQ();
388+
//if applicant dq has been submitted for unspec then copying applicant preferred code to dq
389+
if (ofNullable(applicant1DQ).isPresent()
390+
&& (ofNullable(applicant1DQ.getExperts()).isPresent()
391+
|| ofNullable(applicant1DQ.getApplicant1DQStatementOfTruth()).isPresent())) {
369392
log.info("migrateApplicant1DQ Fetch data from LRD preferred code : {} , Ref : {}",
370393
oldCaseData.getCourtLocation()
371-
.getApplicantPreferredCourt(), oldCaseData.getCcdCaseReference());
394+
.getApplicantPreferredCourt(), oldCaseData.getCcdCaseReference());
372395
LocationRefData refData = locationRefDataService.getCourtLocation(
373396
authToken,
374397
oldCaseData.getCourtLocation().getApplicantPreferredCourt()
@@ -378,7 +401,7 @@ && ofNullable(applicant1DQ.getExperts()).isPresent()) {
378401
refData.getCourtLocationCode(),
379402
refData.getRegionId(), refData.getEpimmsId(), oldCaseData.getCcdCaseReference()
380403
);
381-
caseLocation = CaseLocation.builder().baseLocation(refData.getEpimmsId())
404+
CaseLocation caseLocation = CaseLocation.builder().baseLocation(refData.getEpimmsId())
382405
.region(refData.getRegionId()).build();
383406
caseDataBuilder.applicant1DQ(applicant1DQ.toBuilder()
384407
.applicant1DQRequestedCourt(
@@ -389,6 +412,7 @@ && ofNullable(applicant1DQ.getExperts()).isPresent()) {
389412
.build()).build());
390413

391414
}
415+
392416
}
393417

394418
// Applicable for Respondent1 and Respondent2

0 commit comments

Comments
 (0)