Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4168386
DTSPB-4663 fix CCD Concurrency in SS
MarcusHMCTS Apr 14, 2025
423ca88
DTSPB-4663 fix Integration Tests
MarcusHMCTS Apr 14, 2025
56f20ce
DTSPB-4663 fix SubmitServiceImplTest
MarcusHMCTS Apr 14, 2025
43513a3
DTSPB-4663 fix SubmitServiceImplTest
MarcusHMCTS Apr 14, 2025
52103f9
DTSPB-4663 fix SubmitServiceImplTest typo style
MarcusHMCTS Apr 14, 2025
07ff449
DTSPB-4663 fix FormsFunctionalTests.java shouldSaveFormSuccessfully
MarcusHMCTS Apr 14, 2025
4b2bfc6
Merge branch 'master' into DTSPB-4663_Fix-CCD-concurrency-issue-in-Su…
MarcusHMCTS Apr 15, 2025
072c3e7
DTSPB-4663 add debug log
MarcusHMCTS Apr 15, 2025
728d493
DTSPB-4663 add debug log
MarcusHMCTS Apr 15, 2025
ab803fe
DTSPB-4663 pointing to ss pr-1092
MarcusHMCTS Apr 15, 2025
b931519
Bumping chart version/ fixing aliases
hmcts-jenkins-j-to-z[bot] Apr 15, 2025
f794b87
DTSPB-4663 fix history typo error for /cases/initiate
MarcusHMCTS Apr 16, 2025
32e007c
Merge remote-tracking branch 'origin/DTSPB-4663_Fix-CCD-concurrency-i…
MarcusHMCTS Apr 16, 2025
eb979d0
Merge branch 'master' into DTSPB-4663_Fix-CCD-concurrency-issue-in-Su…
MarcusHMCTS Apr 17, 2025
8633e98
DTSPB-4663 fix history typo error for /cases/initiate
MarcusHMCTS Apr 17, 2025
9764d4d
fix typo
FeliTam Apr 22, 2025
8675c83
Merge branch 'master' into DTSPB-4663_Fix-CCD-concurrency-issue-in-Su…
MarcusHMCTS May 7, 2025
c8c93ce
DTSPB-4663 update probate commons to 2.1.2
MarcusHMCTS May 7, 2025
1cb9e80
DTSPB-4663 update probate commons to 2.1.3
MarcusHMCTS May 9, 2025
11a5e10
DTSPB-4663 add lastModifiedDateTime to InvitationResult
MarcusHMCTS May 14, 2025
9f089cc
DTSPB-4663 fix IT Test
MarcusHMCTS May 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def versions = [
lombok : '1.18.38',
mapStruct : '1.3.0.Final',
pact_version : '4.1.34',
piTest : '1.19.1',
probateCommonsVersion : '2.0.56',
piTest : '1.19.0',
probateCommonsVersion : '2.0.58',
restAssured : '5.5.1',
serenity : '4.2.17',
serviceAuthProviderClient : '5.3.0',
Expand Down Expand Up @@ -247,7 +247,7 @@ dependencies {
implementation group: 'org.sonarsource.api.plugin', name: 'sonar-plugin-api', version: '11.3.0.2824'
implementation group: 'org.mapstruct', name: 'mapstruct-processor', version: versions.mapStruct
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jacksonDatabind
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '8.1'
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '8.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

downgrade? (& piTest at l173?)

annotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
annotationProcessor group: 'org.mapstruct', name: 'mapstruct-processor', version: versions.mapStruct

Expand Down
2 changes: 1 addition & 1 deletion charts/probate-orchestrator-service/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: probate-orchestrator-service
home: https://github.com/hmcts/probate-orchestrator-service
version: 1.0.49
version: 1.0.50
description: HMCTS Probate Orchestrator Service
maintainers:
- name: HMCTS Probate Team
Expand Down
2 changes: 1 addition & 1 deletion charts/probate-orchestrator-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ java:
SERVICES_CORECASEDATA_BASEURL: "http://ccd-data-store-api-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal"
SERVICES_AUTH_PROVIDER_BASEURL: "http://rpe-service-auth-provider-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal"
AUTH_IDAM_CLIENT_BASEURL: "https://idam-api.{{ .Values.global.environment }}.platform.hmcts.net"
SUBMIT_SERVICE_API_URL: "http://probate-submit-service-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal"
SUBMIT_SERVICE_API_URL: "http://probate-submit-service-pr-1092-java"
BUSINESS_SERVICE_API_URL: "http://probate-business-service-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal"
BACK_OFFICE_API_URL: "http://probate-back-office-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal"
MAIL_JAVAMAILPROPERTIES_MAIL_SMTP_SSL_ENABLE: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void shouldSaveFormSuccessfully() {
.headers(utils.getCitizenHeaders())
.body(draftJsonStr)
.when()
.post(FORMS_CASES + caseId)
.post(FORMS_CASES + caseId + "/" + "2099-01-01T12:12:12.123")
.then()
.assertThat()
.statusCode(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import uk.gov.hmcts.reform.probate.model.payments.PaymentDto;

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

import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
Expand All @@ -40,6 +41,9 @@
public class FormsControllerIT {

private static final String EMAIL_ADDRESS = "1570130475566595";
private static final LocalDateTime LAST_MODIFIED_DATE_TIME = LocalDateTime.of(2018, 1, 1,
12, 12, 12).withNano(123 * 1_000_000);
private static final String LAST_MODIFIED_DATE_TIME_STRING = "2018-01-01T12:12:12.123";

private static final String FORMS_ENDPOINT = "/forms";
private static final String FORMS_CASE_ENDPOINT = "/forms/case";
Expand Down Expand Up @@ -105,27 +109,33 @@ public void setUp() throws Exception {

@Test
public void shouldSaveCaveatForm() throws Exception {
when(submitService.saveCase(eq(EMAIL_ADDRESS), eq(caveatForm))).thenReturn(caveatForm);
when(submitService.saveCase(eq(EMAIL_ADDRESS), eq(LAST_MODIFIED_DATE_TIME),
eq(caveatForm))).thenReturn(caveatForm);

mockMvc.perform(post(FORMS_CASE_ENDPOINT + "/" + EMAIL_ADDRESS)
mockMvc.perform(post(FORMS_CASE_ENDPOINT + "/" + EMAIL_ADDRESS
+ "/" + LAST_MODIFIED_DATE_TIME_STRING)
.content(caveatFormJsonStr)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().json(caveatFormJsonStr, true));
verify(submitService, times(1)).saveCase(eq(EMAIL_ADDRESS), eq(caveatForm));
verify(submitService, times(1)).saveCase(eq(EMAIL_ADDRESS),
eq(LAST_MODIFIED_DATE_TIME), eq(caveatForm));
}

@Test
public void shouldSaveIntestacyForm() throws Exception {
when(submitService.saveCase(eq(EMAIL_ADDRESS), eq(intestacyForm))).thenReturn(intestacyForm);
when(submitService.saveCase(eq(EMAIL_ADDRESS), eq(LAST_MODIFIED_DATE_TIME),
eq(intestacyForm))).thenReturn(intestacyForm);

mockMvc.perform(post(FORMS_CASE_ENDPOINT + "/" + EMAIL_ADDRESS)
mockMvc.perform(post(FORMS_CASE_ENDPOINT + "/" + EMAIL_ADDRESS
+ "/" + LAST_MODIFIED_DATE_TIME_STRING)
.content(intestacyFormJsonStr)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().json(intestacyFormJsonStr, true));

verify(submitService, times(1)).saveCase(eq(EMAIL_ADDRESS), eq(intestacyForm));
verify(submitService, times(1)).saveCase(eq(EMAIL_ADDRESS),
eq(LAST_MODIFIED_DATE_TIME), eq(intestacyForm));
}

@Test
Expand Down Expand Up @@ -154,7 +164,8 @@ public void shouldSubmitPaFormWithPayment() throws Exception {
.andExpect(status().isOk())
.andExpect(content().json(paFormJsonStr, true));

verify(submitService, times(1)).update(eq(EMAIL_ADDRESS), eq(ProbateType.PA), eq(paymentDto));
verify(submitService, times(1)).update(eq(EMAIL_ADDRESS),
eq(ProbateType.PA), eq(paymentDto));
}


Expand All @@ -172,7 +183,8 @@ public void shouldSubmitIntestacyFormWithPayment() throws Exception {
.andExpect(status().isOk())
.andExpect(content().json(paFormJsonStr, true));

verify(submitService, times(1)).update(eq("123456"), eq(ProbateType.INTESTACY), eq(paymentDto));
verify(submitService, times(1)).update(eq("123456"),
eq(ProbateType.INTESTACY), eq(paymentDto));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ProbateCaseDetails saveCase(
);

@PostMapping(
value = "/cases/initate",
value = "/cases/initiate",
headers = CONTENT_TYPE + "=" + APPLICATION_JSON_VALUE
)
ProbateCaseDetails initiateCase(
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/uk/gov/hmcts/probate/controller/FormsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,25 @@
import uk.gov.hmcts.reform.probate.model.forms.Form;
import uk.gov.hmcts.reform.probate.model.payments.PaymentDto;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Tag(name = "FormsController", description = "Forms API")
@RestController
@Slf4j
@RequiredArgsConstructor
public class FormsController {

private static final String FORMS_CASE_ENDPOINT = "/forms/case/{identifier}";
private static final String FORMS_SAVE_CASE_ENDPOINT = "/forms/case/{identifier}/{lastModifiedDateTime}";
private static final String FORMS_CASES_ENDPOINT = "/forms/cases";
private static final String FORMS_NEW_CASE_ENDPOINT = "/forms/newcase";
private static final String SUBMISSIONS_ENDPOINT = "/submissions";
private static final String FORMS_SUBMISSIONS_ENDPOINT = "/forms/{identifier}";
private static final String VALIDATIONS_ENDPOINT = "/validations";
private static final String PAYMENTS_ENDPOINT = "/payments";
private static final String MIGRATE_DATA_ENDPOINT = "/migrateData";

private static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS");
private final SubmitService submitService;


Expand All @@ -61,13 +65,15 @@ public ResponseEntity<CaseSummaryHolder> initiateForm(@RequestParam("probateType
@ApiResponse(responseCode = "400", description = "Saving form failed"),
@ApiResponse(responseCode = "422", description = "Invalid or missing attribute")
})
@PostMapping(path = FORMS_CASE_ENDPOINT, consumes = MediaType.APPLICATION_JSON_VALUE,
@PostMapping(path = FORMS_SAVE_CASE_ENDPOINT, consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<Form> saveForm(@RequestBody Form form,
@PathVariable("identifier") String identifier) {
log.info("Save form called");
return new ResponseEntity<>(submitService.saveCase(identifier, form), HttpStatus.OK);
@PathVariable("identifier") String identifier,
@PathVariable("lastModifiedDateTime") String lastModifiedDateTime) {
log.info("Save form called with identifier {} lastModifiedDateTime {}", identifier, lastModifiedDateTime);
LocalDateTime lastModifiedDateTimeParsed = LocalDateTime.parse(lastModifiedDateTime, DATE_TIME_FORMAT);
return new ResponseEntity<>(submitService.saveCase(identifier,lastModifiedDateTimeParsed, form), HttpStatus.OK);
}

@Operation(summary = "Get form data", description = "Get form data")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import uk.gov.hmcts.reform.probate.model.PaymentStatus;
import uk.gov.hmcts.reform.probate.model.ProbateType;
import uk.gov.hmcts.reform.probate.model.cases.CaseData;
import uk.gov.hmcts.reform.probate.model.cases.CaseInfo;
import uk.gov.hmcts.reform.probate.model.cases.CasePayment;
import uk.gov.hmcts.reform.probate.model.cases.CaseType;
import uk.gov.hmcts.reform.probate.model.cases.CollectionMember;
Expand All @@ -30,6 +31,7 @@
import uk.gov.hmcts.reform.probate.model.forms.pa.PaForm;
import uk.gov.hmcts.reform.probate.model.payments.PaymentDto;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -149,16 +151,19 @@ private Form initiateForm(ProbateType probateType) {


@Override
public Form saveCase(String identifier, Form form) {
log.info("Save case called");
public Form saveCase(String identifier, LocalDateTime lastModefiedDateTime, Form form) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public Form saveCase(String identifier, LocalDateTime lastModefiedDateTime, Form form) {
public Form saveCase(String identifier, LocalDateTime lastModifiedDateTime, Form form) {

log.info("Save case called lastModefiedDateTime {} :", lastModefiedDateTime);
assertIdentifier(identifier, form);
FormMapper formMapper = mappers.get(form.getType());
CaseInfo caseInfo = new CaseInfo();
caseInfo.setLastModifiedDateTime(lastModefiedDateTime);
log.info("Save case called submitServiceApi.saveCase");
ProbateCaseDetails probateCaseDetails = submitServiceApi.saveCase(
securityUtils.getAuthorisation(),
securityUtils.getServiceAuthorisation(),
identifier,
form.getEventDescription(),
ProbateCaseDetails.builder().caseData(mapToCase(form, formMapper)).build()
ProbateCaseDetails.builder().caseData(mapToCase(form, formMapper)).caseInfo(caseInfo).build()
);
return mapFromCase(formMapper, probateCaseDetails);
}
Expand Down Expand Up @@ -223,6 +228,7 @@ private void updateCcdCase(ProbateCaseDetails probateCaseDetails, Form formRespo
.id(Long.valueOf(probateCaseDetails.getCaseInfo().getCaseId()))
.state(probateCaseDetails.getCaseInfo().getState().getName())
.lastModifiedDate(probateCaseDetails.getCaseInfo().getLastModifiedDate())
.lastModifiedDateTime(probateCaseDetails.getCaseInfo().getLastModifiedDateTime())
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import uk.gov.hmcts.reform.probate.model.forms.Form;
import uk.gov.hmcts.reform.probate.model.payments.PaymentDto;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

Expand All @@ -20,7 +21,7 @@ public interface SubmitService {

CaseSummaryHolder getAllCases();

Form saveCase(String identifier, Form form);
Form saveCase(String identifier, LocalDateTime lastModefidDateTime, Form form);

Form submit(String identifier, Form form);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package uk.gov.hmcts.probate.core.service;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -40,6 +43,7 @@

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -71,6 +75,7 @@ public class SubmitServiceImplTest {
private static final CaseState STATE = CaseState.DRAFT;
private static final String CAVEAT_IDENTIFIER = "Id";
private static final String CAVEAT_EXPIRY_DATE = "2020-12-31";
private static final LocalDateTime LAST_MODIFIED_DATE_TIME = LocalDateTime.of(2019, 1, 1, 0, 0, 0);
private Map<ProbateType, FormMapper> mappers;

@Mock
Expand Down Expand Up @@ -132,6 +137,9 @@ public void setUp() throws Exception {
when(securityUtils.getServiceAuthorisation()).thenReturn(SERVICE_AUTHORIZATION);
caseInfo = CaseInfo.builder().state(STATE).caseId(CASE_ID).build();

objectMapper.registerModule(new Jdk8Module());
objectMapper.registerModule(new JavaTimeModule());
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
// Intestacy setup
String intestacyFormStr = TestUtils.getJsonFromFile("intestacyFormTest.json");
intestacyForm = objectMapper.readValue(intestacyFormStr, IntestacyForm.class);
Expand Down Expand Up @@ -253,7 +261,7 @@ private void shouldSaveDraftForm(Form form, ProbateCaseDetails caseDetails, Stri
when(submitServiceApi.saveCase(eq(AUTHORIZATION), eq(SERVICE_AUTHORIZATION),
eq(identifier),eq("event description"), any(ProbateCaseDetails.class))).thenReturn(caseDetails);

Form formResponse = submitService.saveCase(identifier, form);
Form formResponse = submitService.saveCase(identifier, LAST_MODIFIED_DATE_TIME, form);

assertThat(formResponse, is(form));
verify(submitServiceApi, times(1)).saveCase(eq(AUTHORIZATION), eq(SERVICE_AUTHORIZATION),
Expand All @@ -272,7 +280,7 @@ public void shouldThrowErrorOnSaveDraftIfEmailAddressDoesNotMatchForm() {
((CaveatForm) caveatForm).setApplicationId("[email protected]");

Assertions.assertThrows(IllegalArgumentException.class, () -> {
submitService.saveCase(EMAIL_ADDRESS, caveatForm);
submitService.saveCase(EMAIL_ADDRESS, LAST_MODIFIED_DATE_TIME, caveatForm);
});
}

Expand Down
6 changes: 4 additions & 2 deletions src/test/resources/caseSummary.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"ccdCase": {
"id": 1234567890123456,
"state": "Draft",
"lastModifiedDate": "2018-01-01"
"lastModifiedDate": "2018-01-01",
"lastModifiedDateTime": "2018-01-01T12:12:12.123"
}
},
{
Expand All @@ -17,7 +18,8 @@
"ccdCase": {
"id": 1535574519543819,
"state": "CaseCreated",
"lastModifiedDate": "2018-01-01"
"lastModifiedDate": "2018-01-01",
"lastModifiedDateTime": "2018-01-01T12:12:12.123"
}
}
]
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/caveatForm.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"ccdCase": {
"id": 1535574519543819,
"state": "CaseCreated",
"lastModifiedDate": "2018-01-01"
"lastModifiedDate": "2018-01-01",
"lastModifiedDateTime": "2018-01-01T12:12:12.123"
},
"registry": {
"name": "Birmingham"
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/intestacyFormTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"ccdCase": {
"id": 1535574519543818,
"state": "CaseCreated",
"lastModifiedDate": "2018-01-01"
"lastModifiedDate": "2018-01-01",
"lastModifiedDateTime": "2018-01-01T12:12:12.123"
},
"registry": {
"name": "Birmingham",
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/paForm.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"ccdCase": {
"id": 1551365512754035,
"state": "CaseCreated",
"lastModifiedDate": "2018-01-01"
"lastModifiedDate": "2018-01-01",
"lastModifiedDateTime": "2018-01-01T12:12:12.123"
},
"payments": [
{
Expand Down