Skip to content

Commit 66200be

Browse files
authored
Merge pull request #1322 from hmcts/DTSPB-4896_change_getCase_to-DB_call
DTSPB-4896 change getCase to getCaseByCaseId
2 parents f1e3589 + 5548c3e commit 66200be

File tree

4 files changed

+33
-34
lines changed

4 files changed

+33
-34
lines changed

src/main/java/uk/gov/hmcts/probate/core/service/BusinessServiceImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import uk.gov.hmcts.probate.core.service.mapper.ExecutorApplyingToInvitationMapper;
99
import uk.gov.hmcts.probate.service.BusinessService;
1010
import uk.gov.hmcts.reform.probate.model.PhonePin;
11-
import uk.gov.hmcts.reform.probate.model.ProbateType;
1211
import uk.gov.hmcts.reform.probate.model.cases.CaseType;
1312
import uk.gov.hmcts.reform.probate.model.cases.CollectionMember;
1413
import uk.gov.hmcts.reform.probate.model.cases.ProbateCaseDetails;
@@ -331,10 +330,10 @@ public String getPinNumber(PhonePin phonePin, String sessionId, Boolean isBiling
331330
}
332331

333332
private ProbateCaseDetails getProbateCaseDetails(String caseId) {
333+
log.info("BusinessServiceImpl.getProbateCaseDetails id: {}", caseId);
334334
String serviceAuthorisation = securityUtils.getServiceAuthorisation();
335335
String authorisation = securityUtils.getAuthorisation();
336-
return submitServiceApi.getCase(authorisation, serviceAuthorisation,
337-
caseId, ProbateType.PA.getCaseType().name());
336+
return submitServiceApi.getCaseById(authorisation, serviceAuthorisation, caseId);
338337
}
339338

340339
private void updateCaseData(ProbateCaseDetails probateCaseDetails, String formdataId) {

src/main/java/uk/gov/hmcts/probate/core/service/SubmitServiceImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ public Form submit(String identifier, Form form) {
182182
public Form update(String identifier, ProbateType probateType, PaymentDto paymentDto) {
183183
String authorisation = securityUtils.getAuthorisation();
184184
String serviceAuthorisation = securityUtils.getServiceAuthorisation();
185-
log.info("Get existing case from submit service");
186-
ProbateCaseDetails existingCase = submitServiceApi.getCase(authorisation,
187-
serviceAuthorisation, identifier, probateType.getCaseType().name());
185+
log.info("Get existing case from submit service identifier {} ", identifier);
186+
ProbateCaseDetails existingCase = submitServiceApi.getCaseById(authorisation,
187+
serviceAuthorisation, identifier);
188188

189189
log.info("Got existing case now set payment on this case");
190190
CasePayment casePayment = paymentDtoMapper.toCasePayment(paymentDto);
@@ -233,9 +233,9 @@ public Form updatePayments(String identifier, Form form) {
233233
"Cannot update case with no payments, there needs to be at least one payment");
234234
String authorisation = securityUtils.getAuthorisation();
235235
String serviceAuthorisation = securityUtils.getServiceAuthorisation();
236-
log.info("Get existing case from submit service");
237-
ProbateCaseDetails existingCase = submitServiceApi.getCase(authorisation,
238-
serviceAuthorisation, identifier, form.getType().getCaseType().name());
236+
log.info("Get existing case from submit service identifier {} ", identifier);
237+
ProbateCaseDetails existingCase = submitServiceApi.getCaseById(authorisation,
238+
serviceAuthorisation, identifier);
239239
log.info("Got existing case now set payment on this case");
240240
FormMapper formMapper = mappers.get(form.getType());
241241
CaseData caseData = formMapper.toCaseData(form);

src/test/java/uk/gov/hmcts/probate/core/service/BusinessServiceImplTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import uk.gov.hmcts.probate.client.submit.SubmitServiceApi;
1414
import uk.gov.hmcts.probate.core.service.mapper.ExecutorApplyingToInvitationMapper;
1515
import uk.gov.hmcts.reform.probate.model.PhonePin;
16-
import uk.gov.hmcts.reform.probate.model.ProbateType;
1716
import uk.gov.hmcts.reform.probate.model.cases.CaseInfo;
1817
import uk.gov.hmcts.reform.probate.model.cases.CaseType;
1918
import uk.gov.hmcts.reform.probate.model.cases.CollectionMember;
@@ -88,8 +87,8 @@ public void setUp() throws Exception {
8887
when(securityUtils.getAuthorisation()).thenReturn(AUTHORIZATION);
8988
when(securityUtils.getServiceAuthorisation()).thenReturn(SERVICE_AUTHORIZATION);
9089

91-
when(submitServiceApi.getCase(AUTHORIZATION, SERVICE_AUTHORIZATION,
92-
formdataId, ProbateType.PA.getCaseType().name())).thenReturn(mockProbateCaseDetails);
90+
when(submitServiceApi.getCaseById(AUTHORIZATION, SERVICE_AUTHORIZATION,
91+
formdataId)).thenReturn(mockProbateCaseDetails);
9392
when(mockProbateCaseDetails.getCaseData()).thenReturn(mockGrantOfRepresentationData);
9493
when(mockProbateCaseDetails.getCaseInfo()).thenReturn(mockCaseInfo);
9594
when(mockCaseInfo.getCaseId()).thenReturn("123456789101112");
@@ -594,8 +593,9 @@ public void shouldGetAllInviteData() {
594593
}
595594

596595
private void verifyGetCaseCalls() {
597-
verify(submitServiceApi).getCase(AUTHORIZATION, SERVICE_AUTHORIZATION,
598-
formdataId, ProbateType.PA.getCaseType().name());
596+
597+
verify(submitServiceApi).getCaseById(AUTHORIZATION, SERVICE_AUTHORIZATION,
598+
formdataId);
599599
verify(mockProbateCaseDetails).getCaseData();
600600
}
601601

src/test/java/uk/gov/hmcts/probate/core/service/SubmitServiceImplTest.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -295,22 +295,22 @@ public void shouldSubmitCaveatForm() {
295295

296296
@Test
297297
public void shouldUpdateForm() {
298-
when(submitServiceApi.getCase(AUTHORIZATION, SERVICE_AUTHORIZATION,
299-
EMAIL_ADDRESS, CaseType.GRANT_OF_REPRESENTATION.name())).thenReturn(intestacyCaseDetails);
298+
when(submitServiceApi.getCaseById(AUTHORIZATION, SERVICE_AUTHORIZATION,
299+
CASE_ID)).thenReturn(intestacyCaseDetails);
300300
when(submitServiceApi.createCase(eq(AUTHORIZATION), eq(SERVICE_AUTHORIZATION),
301-
eq(EMAIL_ADDRESS), any(ProbateCaseDetails.class))).thenReturn(intestacyCaseDetails);
301+
eq(CASE_ID), any(ProbateCaseDetails.class))).thenReturn(intestacyCaseDetails);
302302

303303
CasePayment casePayment = CasePayment.builder().build();
304304
when(paymentDtoMapper.toCasePayment(paymentDto)).thenReturn(casePayment);
305305

306-
Form formResponse = submitService.update(EMAIL_ADDRESS, ProbateType.INTESTACY, paymentDto);
306+
Form formResponse = submitService.update(CASE_ID, ProbateType.INTESTACY, paymentDto);
307307

308308
assertThat(formResponse, is(intestacyForm));
309-
verify(submitServiceApi, times(1)).getCase(AUTHORIZATION, SERVICE_AUTHORIZATION,
310-
EMAIL_ADDRESS, CaseType.GRANT_OF_REPRESENTATION.name());
309+
verify(submitServiceApi, times(1)).getCaseById(AUTHORIZATION, SERVICE_AUTHORIZATION,
310+
CASE_ID);
311311
verify(submitServiceApi, times(1)).createCase(eq(AUTHORIZATION),
312312
eq(SERVICE_AUTHORIZATION),
313-
eq(EMAIL_ADDRESS), any(ProbateCaseDetails.class));
313+
eq(CASE_ID), any(ProbateCaseDetails.class));
314314
verify(securityUtils, times(1)).getAuthorisation();
315315
verify(securityUtils, times(1)).getServiceAuthorisation();
316316
}
@@ -327,17 +327,17 @@ public void shouldThrowErrorOnSubmitIfEmailAddressDoesNotMatchForm() {
327327

328328
@Test
329329
public void shouldUpdateIntestacyPayments() {
330-
when(submitServiceApi.getCase(anyString(), anyString(),
331-
anyString(), anyString())).thenReturn(caveatCaseDetails);
330+
when(submitServiceApi.getCaseById(anyString(), anyString(),
331+
anyString())).thenReturn(caveatCaseDetails);
332332

333333
shouldUpdatePayments(intestacyForm, intestacyCaseDetails);
334334
verify(backOfficeService, never()).sendNotification(intestacyCaseDetails);
335335
}
336336

337337
@Test
338338
public void shouldUpdateCaveatPaymentsAndSendNotification() {
339-
when(submitServiceApi.getCase(anyString(), anyString(),
340-
anyString(), anyString())).thenReturn(caveatCaseDetails);
339+
when(submitServiceApi.getCaseById(anyString(), anyString(),
340+
anyString())).thenReturn(caveatCaseDetails);
341341

342342
caveatCaseDetails.getCaseInfo().setState(CaseState.CAVEAT_RAISED);
343343
shouldUpdatePayments(caveatForm, caveatCaseDetails);
@@ -346,8 +346,8 @@ public void shouldUpdateCaveatPaymentsAndSendNotification() {
346346

347347
@Test
348348
public void shouldUpdateCaveatPaymentsAndNotSendNotification() {
349-
when(submitServiceApi.getCase(anyString(), anyString(),
350-
anyString(), anyString())).thenReturn(caveatCaseDetails);
349+
when(submitServiceApi.getCaseById(anyString(), anyString(),
350+
anyString())).thenReturn(caveatCaseDetails);
351351

352352
caveatCaseDetails.getCaseData().getPayments().get(0).getValue().setStatus(PaymentStatus.FAILED);
353353
shouldUpdatePayments(caveatForm, caveatCaseDetails);
@@ -358,8 +358,8 @@ public void shouldUpdateCaveatPaymentsAndNotSendNotification() {
358358

359359
@Test
360360
public void shouldUpdateIntestacyPaymentsAndSendNotification() {
361-
when(submitServiceApi.getCase(anyString(), anyString(),
362-
anyString(), anyString())).thenReturn(intestacyCaseDetails);
361+
when(submitServiceApi.getCaseById(anyString(), anyString(),
362+
anyString())).thenReturn(intestacyCaseDetails);
363363

364364
intestacyCaseDetails.getCaseData().getPayments().get(0).getValue().setStatus(PaymentStatus.SUCCESS);
365365

@@ -370,8 +370,8 @@ public void shouldUpdateIntestacyPaymentsAndSendNotification() {
370370

371371
@Test
372372
public void shouldUpdateIntestacyPaymentsAndNotSendNotification() {
373-
when(submitServiceApi.getCase(anyString(), anyString(),
374-
anyString(), anyString())).thenReturn(intestacyCaseDetails);
373+
when(submitServiceApi.getCaseById(anyString(), anyString(),
374+
anyString())).thenReturn(intestacyCaseDetails);
375375

376376
intestacyCaseDetails.getCaseData().getPayments().get(0).getValue().setStatus(PaymentStatus.FAILED);
377377

@@ -382,14 +382,14 @@ public void shouldUpdateIntestacyPaymentsAndNotSendNotification() {
382382

383383
private void shouldUpdatePayments(Form form, ProbateCaseDetails caseDetails) {
384384
when(submitServiceApi.createCase(eq(AUTHORIZATION), eq(SERVICE_AUTHORIZATION),
385-
eq(EMAIL_ADDRESS), any(ProbateCaseDetails.class))).thenReturn(caseDetails);
385+
eq(CASE_ID), any(ProbateCaseDetails.class))).thenReturn(caseDetails);
386386

387-
Form formResponse = submitService.updatePayments(EMAIL_ADDRESS, form);
387+
Form formResponse = submitService.updatePayments(CASE_ID, form);
388388

389389
assertThat(formResponse, is(form));
390390
verify(submitServiceApi, times(1)).createCase(eq(AUTHORIZATION),
391391
eq(SERVICE_AUTHORIZATION),
392-
eq(EMAIL_ADDRESS), any(ProbateCaseDetails.class));
392+
eq(CASE_ID), any(ProbateCaseDetails.class));
393393
verify(securityUtils, times(1)).getAuthorisation();
394394
verify(securityUtils, times(1)).getServiceAuthorisation();
395395
}

0 commit comments

Comments
 (0)