From 699fdd48b81ca7892d70879beb1ff205ae919420 Mon Sep 17 00:00:00 2001 From: patelila Date: Thu, 13 Mar 2025 12:05:53 +0000 Subject: [PATCH 01/14] CCD-6185 UC : Set the supplementary data (new_case.organisationID) to false for a List of case references --- .../SupplementaryDataCasesUpdateRequest.java | 25 +++ ...pplementaryDataUpdateRequestValidator.java | 12 ++ src/main/java/uk/gov/hmcts/ccd/v2/V2.java | 3 + .../external/controller/CaseController.java | 102 ++++++++++- .../SupplementaryCaseFailDataResource.java | 23 +++ .../SupplementaryCaseSuccessDataResource.java | 26 +++ .../SupplementaryCasesDataResource.java | 26 +++ ...mentaryDataUpdateRequestValidatorTest.java | 7 +- .../controller/CaseControllerTest.java | 169 +++++++++++++++++- 9 files changed, 387 insertions(+), 6 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/ccd/domain/model/std/SupplementaryDataCasesUpdateRequest.java create mode 100644 src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCaseFailDataResource.java create mode 100644 src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCaseSuccessDataResource.java create mode 100644 src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCasesDataResource.java diff --git a/src/main/java/uk/gov/hmcts/ccd/domain/model/std/SupplementaryDataCasesUpdateRequest.java b/src/main/java/uk/gov/hmcts/ccd/domain/model/std/SupplementaryDataCasesUpdateRequest.java new file mode 100644 index 0000000000..4013d4662b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/ccd/domain/model/std/SupplementaryDataCasesUpdateRequest.java @@ -0,0 +1,25 @@ +package uk.gov.hmcts.ccd.domain.model.std; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import java.util.List; +import java.util.Map; + +@ToString +@AllArgsConstructor +@NoArgsConstructor +@Getter +public class SupplementaryDataCasesUpdateRequest { + + @JsonProperty("cases") + private List caseIds; + + @JsonProperty("supplementary_data_request") + private Map> supplementaryDataRequest; + +} + diff --git a/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java b/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java index d3158708b7..5fac9d701a 100644 --- a/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java +++ b/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java @@ -5,11 +5,13 @@ import javax.inject.Named; import javax.inject.Singleton; import uk.gov.hmcts.ccd.data.casedetails.supplementarydata.SupplementaryDataOperation; +import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataCasesUpdateRequest; import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataUpdateRequest; import uk.gov.hmcts.ccd.endpoint.exceptions.BadRequestException; import static uk.gov.hmcts.ccd.v2.V2.Error.MORE_THAN_ONE_NESTED_LEVEL; import static uk.gov.hmcts.ccd.v2.V2.Error.SUPPLEMENTARY_DATA_UPDATE_INVALID; +import static uk.gov.hmcts.ccd.v2.V2.Error.SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID; import static uk.gov.hmcts.ccd.v2.V2.Error.UNKNOWN_SUPPLEMENTARY_UPDATE_OPERATION; @Named @@ -25,6 +27,16 @@ public void validate(SupplementaryDataUpdateRequest supplementaryDataUpdateReque validateRequestOperations(supplementaryDataUpdateRequest); } + public void validate(SupplementaryDataCasesUpdateRequest caseSupplementaryDataUpdateRequest) { + if (caseSupplementaryDataUpdateRequest == null + || caseSupplementaryDataUpdateRequest.getCaseIds() == null + || caseSupplementaryDataUpdateRequest.getSupplementaryDataRequest() != null + || caseSupplementaryDataUpdateRequest.getSupplementaryDataRequest().isEmpty() + || caseSupplementaryDataUpdateRequest.getCaseIds().isEmpty()) { + throw new BadRequestException(SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID); + } + } + private void validateAtMostOneLevelOfNesting(SupplementaryDataUpdateRequest supplementaryDataUpdateRequest) { for (String name : supplementaryDataUpdateRequest.getPropertiesNames()) { String[] keys = name.split(Pattern.quote(".")); diff --git a/src/main/java/uk/gov/hmcts/ccd/v2/V2.java b/src/main/java/uk/gov/hmcts/ccd/v2/V2.java index 13931e5ac7..fc1e9855b4 100644 --- a/src/main/java/uk/gov/hmcts/ccd/v2/V2.java +++ b/src/main/java/uk/gov/hmcts/ccd/v2/V2.java @@ -106,9 +106,12 @@ private Error() { "Access to other user's case role assignments not granted"; public static final String NOT_AUTHORISED_UPDATE_SUPPLEMENTARY_DATA = "Not authorised to update case supplementary data"; + public static final String NOT_AUTHORISED_UPDATE_CASES_SUPPLEMENTARY_DATA = + "Not authorised to update supplementary data for case"; public static final String CLIENT_SERVICE_NOT_AUTHORISED_FOR_OPERATION = "Client service not authorised to perform operation"; public static final String SUPPLEMENTARY_DATA_UPDATE_INVALID = "Supplementary Data Update Invalid"; + public static final String SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID = "Supplementary Data Cases Update Invalid"; public static final String MORE_THAN_ONE_NESTED_LEVEL = "Supplementary data properties with more than one nested level are currently not supported"; public static final String UNKNOWN_SUPPLEMENTARY_UPDATE_OPERATION = diff --git a/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java b/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java index 4ec0f32055..6c8258a769 100644 --- a/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java +++ b/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java @@ -7,6 +7,7 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ExampleProperty; +import io.swagger.annotations.Example; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -29,6 +30,7 @@ import uk.gov.hmcts.ccd.domain.model.std.CaseDataContent; import uk.gov.hmcts.ccd.domain.model.std.SupplementaryData; import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataUpdateRequest; +import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataCasesUpdateRequest; import uk.gov.hmcts.ccd.domain.model.std.validator.SupplementaryDataUpdateRequestValidator; import uk.gov.hmcts.ccd.domain.service.caselinking.CaseLinkRetrievalResults; import uk.gov.hmcts.ccd.domain.service.caselinking.CaseLinkRetrievalService; @@ -47,6 +49,9 @@ import uk.gov.hmcts.ccd.v2.external.resource.CaseEventsResource; import uk.gov.hmcts.ccd.v2.external.resource.CaseResource; import uk.gov.hmcts.ccd.v2.external.resource.SupplementaryDataResource; +import uk.gov.hmcts.ccd.v2.external.resource.SupplementaryCasesDataResource; +import uk.gov.hmcts.ccd.v2.external.resource.SupplementaryCaseFailDataResource; +import uk.gov.hmcts.ccd.v2.external.resource.SupplementaryCaseSuccessDataResource; import uk.gov.hmcts.ccd.validator.annotation.ValidCaseTypeId; import java.util.ArrayList; @@ -417,7 +422,7 @@ public ResponseEntity getCaseEvents(@PathVariable("caseId") @ApiImplicitParam( name = "supplementaryDataUpdateRequest", dataTypeClass = SupplementaryDataUpdateRequest.class, - examples = @io.swagger.annotations.Example( + examples = @Example( value = { @ExampleProperty(value = "{\n" + "\t\"$inc\": {\n" @@ -445,6 +450,101 @@ public ResponseEntity updateCaseSupplementaryData(@Pa return status(HttpStatus.OK).body(new SupplementaryDataResource(supplementaryDataUpdated)); } + @PostMapping( + path = "/cases/supplementary-data" + ) + @ApiOperation( + value = "Update Cases Supplementary Data" + ) + @ApiResponses({ + @ApiResponse( + code = 200, + message = "Cases Updated", + response = SupplementaryDataResource.class + ), + @ApiResponse( + code = 400, + message = V2.Error.CASE_ID_INVALID + ), + @ApiResponse( + code = 400, + message = V2.Error.SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID + ), + @ApiResponse( + code = 400, + message = V2.Error.MORE_THAN_ONE_NESTED_LEVEL + ), + @ApiResponse( + code = 404, + message = V2.Error.CASE_NOT_FOUND + ), + @ApiResponse( + code = 403, + message = V2.Error.NOT_AUTHORISED_UPDATE_CASES_SUPPLEMENTARY_DATA + ) + }) + @ApiImplicitParams({ + @ApiImplicitParam( + name = "supplementaryDataCasesUpdateRequest", + dataTypeClass = SupplementaryDataCasesUpdateRequest.class, + examples = @Example( + value = { + @ExampleProperty(value = "{\n" + + "\t\"cases\": [\n" + + "\t\"caseId value 1\",\n" + + "\t\"caseId value 2\"\n" + + "\t\"],\n" + + "\"supplementary_data_request\": {\n" + + "\t\"$inc\": {\n" + + "\t\t\"orgs_assigned_users.OrgA\": 1,\n" + + "\t\t\"orgs_assigned_users.OrgB\": -1\n" + + "\t},\n" + + "\t\"$set\": {\n" + + "\t\t\"orgs_assigned_users.OrgZ\": 34,\n" + + "\t\t\"processed\": true\n" + + "\t}\n" + + "\t}\n" + + "}", mediaType = "application/json") + })) + }) + public ResponseEntity updateCasesSupplementaryData( + @RequestBody SupplementaryDataCasesUpdateRequest supplementaryDataCasesUpdateRequest) { + + if (supplementaryDataCasesUpdateRequest == null + || supplementaryDataCasesUpdateRequest.getCaseIds() == null) { + throw new BadRequestException(V2.Error.SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID); + } + + List caseIds = supplementaryDataCasesUpdateRequest.getCaseIds(); + List failures = new ArrayList<>(); + List successes = new ArrayList<>(); + + SupplementaryDataUpdateRequest supplementaryDataUpdateRequest = + new SupplementaryDataUpdateRequest(supplementaryDataCasesUpdateRequest.getSupplementaryDataRequest()); + + for (String caseId : caseIds) { + this.requestValidator.validate(supplementaryDataUpdateRequest); + if (!caseReferenceService.validateUID(caseId)) { + throw new BadRequestException(V2.Error.CASE_ID_INVALID); + } + SupplementaryData supplementaryDataUpdated = supplementaryDataUpdateOperation + .updateSupplementaryData(caseId, + supplementaryDataUpdateRequest); + if (supplementaryDataUpdated == null) { + SupplementaryCaseFailDataResource supplementaryCaseFailDataResource + = new SupplementaryCaseFailDataResource( + caseId, V2.Error.CASE_NOT_FOUND); + failures.add(supplementaryCaseFailDataResource); + } else { + SupplementaryCaseSuccessDataResource supplementaryCaseSuccessDataResource + = new SupplementaryCaseSuccessDataResource( + caseId, supplementaryDataUpdated); + successes.add(supplementaryCaseSuccessDataResource); + } + } + return status(HttpStatus.OK).body(new SupplementaryCasesDataResource(successes, failures)); + } + private ResponseEntity createCaseEvent(String caseId, CaseDataContent content) { if (!caseReferenceService.validateUID(caseId)) { throw new BadRequestException(V2.Error.CASE_ID_INVALID); diff --git a/src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCaseFailDataResource.java b/src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCaseFailDataResource.java new file mode 100644 index 0000000000..2e4c2fc810 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCaseFailDataResource.java @@ -0,0 +1,23 @@ +package uk.gov.hmcts.ccd.v2.external.resource; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@EqualsAndHashCode +@NoArgsConstructor +public class SupplementaryCaseFailDataResource { + + @JsonProperty("caseId") + private String caseId; + + @JsonProperty("failure_reason") + private String failureMessage; + + public SupplementaryCaseFailDataResource(final String caseId, final String reason) { + this.caseId = caseId; + this.failureMessage = reason; + } +} diff --git a/src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCaseSuccessDataResource.java b/src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCaseSuccessDataResource.java new file mode 100644 index 0000000000..2db2a88b90 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCaseSuccessDataResource.java @@ -0,0 +1,26 @@ +package uk.gov.hmcts.ccd.v2.external.resource; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.domain.model.std.SupplementaryData; + +import java.util.Map; + +@Data +@EqualsAndHashCode +@NoArgsConstructor +public class SupplementaryCaseSuccessDataResource { + + @JsonProperty("caseId") + private String caseId; + + @JsonProperty("supplementary_data") + private Map response; + + public SupplementaryCaseSuccessDataResource(final String caseId, final SupplementaryData supplementaryDataUpdated) { + this.caseId = caseId; + this.response = supplementaryDataUpdated.getResponse(); + } +} diff --git a/src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCasesDataResource.java b/src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCasesDataResource.java new file mode 100644 index 0000000000..dd6eedcae1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/ccd/v2/external/resource/SupplementaryCasesDataResource.java @@ -0,0 +1,26 @@ +package uk.gov.hmcts.ccd.v2.external.resource; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@EqualsAndHashCode +@NoArgsConstructor +public class SupplementaryCasesDataResource { + + @JsonProperty("successes") + private List successes; + + @JsonProperty("failures") + private List failures; + + public SupplementaryCasesDataResource(final List successes, + final List failures) { + this.successes = successes; + this.failures = failures; + } +} diff --git a/src/test/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidatorTest.java b/src/test/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidatorTest.java index c048208763..b7d16698fa 100644 --- a/src/test/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidatorTest.java +++ b/src/test/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidatorTest.java @@ -4,6 +4,7 @@ import java.util.Map; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataCasesUpdateRequest; import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataUpdateRequest; import uk.gov.hmcts.ccd.endpoint.exceptions.BadRequestException; @@ -18,7 +19,7 @@ class SupplementaryDataUpdateRequestValidatorTest { @DisplayName("should propagate BadRequestException when supplementary data is null") void validate() { assertThrows(BadRequestException.class, - () -> requestValidator.validate(null)); + () -> requestValidator.validate((SupplementaryDataUpdateRequest) null)); } @Test @@ -29,10 +30,10 @@ void invalidSupplementaryDataUpdateRequest() { } @Test - @DisplayName("should propagate BadRequestException when supplementary data null") + @DisplayName("should propagate BadRequestException when Case supplementary data null") void shouldThrowBadRequestExceptionWhenSupplementaryDataNull() { assertThrows(BadRequestException.class, - () -> requestValidator.validate(null)); + () -> requestValidator.validate((SupplementaryDataCasesUpdateRequest) null)); } @Test diff --git a/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java b/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java index 68571add37..c102c01bed 100644 --- a/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java +++ b/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.ccd.v2.external.controller; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; import org.junit.jupiter.api.BeforeEach; @@ -13,6 +14,8 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import uk.gov.hmcts.ccd.domain.model.caselinking.CaseLinkInfo; @@ -22,6 +25,7 @@ import uk.gov.hmcts.ccd.domain.model.std.CaseDataContent; import uk.gov.hmcts.ccd.domain.model.std.SupplementaryData; import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataUpdateRequest; +import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataCasesUpdateRequest; import uk.gov.hmcts.ccd.domain.model.std.validator.SupplementaryDataUpdateRequestValidator; import uk.gov.hmcts.ccd.domain.service.caselinking.CaseLinkRetrievalService; import uk.gov.hmcts.ccd.domain.service.caselinking.GetLinkedCasesResponseCreator; @@ -38,6 +42,8 @@ import uk.gov.hmcts.ccd.v2.external.resource.CaseEventsResource; import uk.gov.hmcts.ccd.v2.external.resource.CaseResource; import uk.gov.hmcts.ccd.v2.external.resource.SupplementaryDataResource; +import uk.gov.hmcts.ccd.v2.external.resource.SupplementaryCasesDataResource; +import uk.gov.hmcts.ccd.v2.external.resource.SupplementaryCaseSuccessDataResource; import java.time.LocalDateTime; import java.util.HashMap; @@ -81,6 +87,8 @@ class CaseControllerTest { private static final Boolean IGNORE_WARNING = true; private static final CaseDataContent CASE_DATA_CONTENT = newCaseDataContent().build(); + private static final Logger LOG = LoggerFactory.getLogger(CaseControllerTest.class); + @Mock private GetCaseOperation getCaseOperation; @Mock @@ -293,6 +301,7 @@ void shouldUpdateSupplementaryData() { assertAll( () -> assertThat(response.getStatusCode(), is(HttpStatus.OK)), + () -> assertThat(response.getBody().getResponse() != null, is(true)), () -> assertThat(response.getBody().getResponse().size(), equalTo(1)), () -> assertThat(response.getBody().getResponse(), is(data)) ); @@ -385,10 +394,10 @@ private SupplementaryDataUpdateRequest createRequestDataNested() { return new SupplementaryDataUpdateRequest(convertData(jsonRequest)); } - private Map> convertData(String jsonRquest) { + private Map> convertData(String jsonRequest) { Map> requestData; try { - requestData = mapper.readValue(jsonRquest, Map.class); + requestData = mapper.readValue(jsonRequest, Map.class); } catch (JsonProcessingException e) { requestData = new HashMap<>(); } @@ -617,4 +626,160 @@ private GetLinkedCasesResponse createGetLinkedCasesResponse(int numberRequired) } } + @Nested + @DisplayName("POST /cases/supplementary-data") + class UpdateCasesSupplementaryData { + + private final ObjectMapper mapper = new ObjectMapper(); + + @Test + @DisplayName("should return 200 when supplementary data updated") + void shouldUpdateSupplementaryData() { + when(caseReferenceService.validateUID(CASE_REFERENCE)).thenReturn(TRUE); + SupplementaryCasesDataResource supplementaryCasesDataResource = createResponseDataWithCases(); + when(supplementaryDataUpdateOperation.updateSupplementaryData(anyString(), anyObject())) + .thenReturn(new SupplementaryData(new HashMap<>())); + Map data = supplementaryCasesDataResource.getSuccesses().getFirst().getResponse(); + + SupplementaryData supplementaryData = new SupplementaryData(data); + when(supplementaryDataUpdateOperation.updateSupplementaryData(anyString(), anyObject())) + .thenReturn(supplementaryData); + + final ResponseEntity response = + caseController.updateCasesSupplementaryData(createCaseRequestDataOrgAWithCases()); + + assertAll( + () -> assertThat(response.getStatusCode(), is(HttpStatus.OK)), + () -> assertThat(response.getBody().getFailures().size(), equalTo(0)), + () -> assertThat(response.getBody().getSuccesses().size(), equalTo(1)), + () -> assertThat(response.getBody().getSuccesses().getFirst().getResponse(), is(data)) + ); + validateResponseData(response.getBody().getSuccesses(), "organisationA", FALSE); + } + + @Test + @DisplayName("should propagate BadRequestException when supplementary data not valid") + void invalidSupplementaryDataUpdateRequest() { + when(caseReferenceService.validateUID(CASE_REFERENCE)).thenReturn(FALSE); + SupplementaryDataCasesUpdateRequest request = new SupplementaryDataCasesUpdateRequest(); + + assertThrows(BadRequestException.class, + () -> caseController.updateCasesSupplementaryData(request)); + } + + @Test + @DisplayName("should propagate BadRequestException when supplementary data null") + void shouldThrowBadRequestExceptionWhenSupplementaryDataNull() { + when(caseReferenceService.validateUID(CASE_REFERENCE)).thenReturn(FALSE); + + assertThrows(BadRequestException.class, + () -> caseController.updateCasesSupplementaryData(null)); + } + + @Test + @DisplayName("should propagate BadRequestException when supplementary data has empty operation data") + void shouldThrowBadRequestExceptionWhenSupplementaryDataHasNoData() { + when(caseReferenceService.validateUID(CASE_REFERENCE)).thenReturn(FALSE); + SupplementaryDataCasesUpdateRequest request = new SupplementaryDataCasesUpdateRequest(); + + assertThrows(BadRequestException.class, + () -> caseController.updateCasesSupplementaryData(request)); + } + + @Test + @DisplayName("should propagate BadRequestException when supplementary data has more than one nested levels") + void shouldThrowBadRequestExceptionWhenSupplementaryDataHasNestedLevels() { + doCallRealMethod().when(requestValidator).validate(any(SupplementaryDataUpdateRequest.class)); + SupplementaryDataCasesUpdateRequest request = createRequestDataNestedWithCases(); + + assertThrows(BadRequestException.class, + () -> caseController.updateCasesSupplementaryData(request)); + } + + @Test + @DisplayName("should propagate BadRequestException when case reference not valid") + void caseReferenceNotValid() { + when(caseReferenceService.validateUID(CASE_REFERENCE)).thenReturn(FALSE); + SupplementaryDataCasesUpdateRequest request = new SupplementaryDataCasesUpdateRequest(); + + assertThrows(BadRequestException.class, + () -> caseController.updateCasesSupplementaryData(request)); + } + + private SupplementaryCasesDataResource createResponseDataWithCases() { + String jsonResponse = "{\n" + + "\t\"successes\": [{\n" + + "\t\"caseId\": " + + "\"" + CASE_REFERENCE + "\",\n" + + "\t\"supplementary_data\": {\n" + + "\t\t\"organisationA\": false\n" + + "\t}\n" + + "\t}]\n" + + "}"; + return convertResponseData(jsonResponse); + } + + private SupplementaryCasesDataResource convertResponseData(String jsonResponse) { + SupplementaryCasesDataResource responseData; + + try { + mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); + responseData = mapper.readValue(jsonResponse, SupplementaryCasesDataResource.class); + } catch (JsonProcessingException e) { + LOG.info(e.getStackTrace().toString()); + responseData = new SupplementaryCasesDataResource(); + } + return responseData; + } + + private SupplementaryDataCasesUpdateRequest createCaseRequestDataOrgAWithCases() { + String jsonRequest = "{\n" + + "\t\"cases\": [\n" + + "\t\t\"" + CASE_REFERENCE + "\"\n" + + "\t],\n" + + "\"supplementary_data_request\": {\n" + + "\t\"$set\": {\n" + + "\t\t\"new_case.organisationA\": false\n" + + "\t}\n" + + "\t}\n" + + "}"; + return convertData(jsonRequest); + } + + private SupplementaryDataCasesUpdateRequest createRequestDataNestedWithCases() { + String jsonRequest = "{\n" + + "\t\"cases\": [\n" + + "\t\t\"" + CASE_REFERENCE + "\n" + + "\t],\n" + + "\"supplementary_data_request\": {\n" + + "\t\"$set\": {\n" + + "\t\t\".organisationA.organisationB\": false\n" + + "\t}\n" + + "\t}\n" + + "}"; + return convertData(jsonRequest); + } + + private SupplementaryDataCasesUpdateRequest convertData(String jsonRequest) { + SupplementaryDataCasesUpdateRequest requestData; + try { + requestData = mapper.readValue(jsonRequest, SupplementaryDataCasesUpdateRequest.class); + } catch (JsonProcessingException e) { + LOG.info(e.getStackTrace().toString()); + requestData = new SupplementaryDataCasesUpdateRequest(); + } + return requestData; + } + + private void validateResponseData(List response, + String expectedKey, Object expectedValue) { + response.forEach(success -> { + Map childMap = (Map) success.getResponse(); + assertTrue(childMap.containsKey(expectedKey)); + assertEquals(expectedValue, childMap.get(expectedKey)); + }); + } + + } + } From da0b65969dd39c230382dc43ef7c485447bed985 Mon Sep 17 00:00:00 2001 From: patelila Date: Thu, 13 Mar 2025 12:14:13 +0000 Subject: [PATCH 02/14] use PR-2456 for data-store-api --- Jenkinsfile_CNP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_CNP b/Jenkinsfile_CNP index 22ca3e7e1f..58685eb49e 100644 --- a/Jenkinsfile_CNP +++ b/Jenkinsfile_CNP @@ -21,7 +21,7 @@ def branchesToSync = ['demo', 'ithc', 'perftest', 'develop'] // Variables to switch pipeline logic and wiring per type of build def definitionStoreDevelopPr = "PR-1529" // This doesn't change frequently, but when it does, only change this value. -def dataStoreApiDevelopPr = "PR-2520" // This doesn't change frequently, but when it does, only change this value. +def dataStoreApiDevelopPr = "PR-2546" // This doesn't change frequently, but when it does, only change this value. def prsToUseAat = "PR-1793,PR-1888" // Set this value to a PR number, or add it as a comma-separated value, if it's to follow CI/CD. def secrets = [ From 2472875e266ef10d33dd531e34cd6c1e9e25e467 Mon Sep 17 00:00:00 2001 From: patelila Date: Thu, 13 Mar 2025 13:04:39 +0000 Subject: [PATCH 03/14] empty commit to trigger build From cb1996867a646c2c9b6ec02d891d26d92f14ccf4 Mon Sep 17 00:00:00 2001 From: patelila Date: Thu, 13 Mar 2025 16:06:00 +0000 Subject: [PATCH 04/14] empty commit to trigger build From c66e809b8016fcd9297c917b393f64dbb30abbe7 Mon Sep 17 00:00:00 2001 From: patelila Date: Fri, 14 Mar 2025 09:07:13 +0000 Subject: [PATCH 05/14] use ccd-definition-store-api pr-1536 --- charts/ccd-data-store-api/values.preview.template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/ccd-data-store-api/values.preview.template.yaml b/charts/ccd-data-store-api/values.preview.template.yaml index 5058a88121..5190e604d1 100644 --- a/charts/ccd-data-store-api/values.preview.template.yaml +++ b/charts/ccd-data-store-api/values.preview.template.yaml @@ -27,7 +27,7 @@ java: DATA_STORE_DB_PASSWORD: "{{ .Values.postgresql.auth.password}}" DATA_STORE_DB_OPTIONS: "?stringtype=unspecified" DATA_STORE_DB_MAX_POOL_SIZE: 10 - DEFINITION_STORE_HOST: http://ccd-definition-store-api-pr-1534-java/ + DEFINITION_STORE_HOST: http://ccd-definition-store-api-pr-1536-java/ USER_PROFILE_HOST: http://ccd-user-profile-api-pr-399-java/ ELASTIC_SEARCH_ENABLED: true # enable whenever ES required on a particular PR ELASTIC_SEARCH_NODES_DISCOVERY_ENABLED: true From 81cc2c0ed26fa714ab6243540e2a018e3a40e909 Mon Sep 17 00:00:00 2001 From: patelila Date: Fri, 14 Mar 2025 09:27:15 +0000 Subject: [PATCH 06/14] use ccd-definition-store-api pr-1536 --- Jenkinsfile_CNP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_CNP b/Jenkinsfile_CNP index 86c307746b..a8911c144b 100644 --- a/Jenkinsfile_CNP +++ b/Jenkinsfile_CNP @@ -20,7 +20,7 @@ def branchesToSync = ['demo', 'ithc', 'perftest', 'develop'] // Variables to switch pipeline logic and wiring per type of build -def definitionStoreDevelopPr = "PR-1534" // This doesn't change frequently, but when it does, only change this value. +def definitionStoreDevelopPr = "PR-1536" // This doesn't change frequently, but when it does, only change this value. def dataStoreApiDevelopPr = "PR-2546" // This doesn't change frequently, but when it does, only change this value. def prsToUseAat = "PR-1793,PR-1888" // Set this value to a PR number, or add it as a comma-separated value, if it's to follow CI/CD. From 051f40ecab29ab27ae8da18758f71f9747e5b8d8 Mon Sep 17 00:00:00 2001 From: patelila Date: Fri, 14 Mar 2025 09:42:30 +0000 Subject: [PATCH 07/14] empty commit to trigger build From 25aaa70a668ba990e72d432b95c3c1532db5d9f9 Mon Sep 17 00:00:00 2001 From: patelila Date: Fri, 14 Mar 2025 10:25:31 +0000 Subject: [PATCH 08/14] empty commit to trigger build From 4f2d2707554750116809d3fc4800025bf5c98b24 Mon Sep 17 00:00:00 2001 From: patelila Date: Mon, 17 Mar 2025 09:32:08 +0000 Subject: [PATCH 09/14] FT Tests --- .../S-143.3.td.json | 2 +- .../S-143.4.td.json | 2 +- .../F-144.feature | 63 +++++++ .../F-144_Case_Data_Create.td.json | 12 ++ .../F-144_Case_Data_Create_C1.td.json | 12 ++ ...Case_Data_Create_C1_Token_Creation.td.json | 4 + ...eRequisiteCaseworker_Multiple_Orgs.td.json | 109 ++++++++++++ .../F-144_Set_Supplementary_Data_C1.td.json | 31 ++++ .../F-144_Test_Data_Base.td.json | 21 +++ ...date_Cases_Supplementary_Data_Base.td.json | 27 +++ ...Update_Cases_Supplementary_Data_C1.td.json | 33 ++++ .../S-144.1.td.json | 44 +++++ .../S-144.2.td.json | 35 ++++ .../S-144.3.td.json | 33 ++++ .../S-144.4.td.json | 160 +++++++++++++++++ .../S-144.5.td.json | 167 ++++++++++++++++++ .../S-144_GetCreateToken.td.json | 28 +++ .../SupplementaryDataCasesUpdateRequest.java | 4 +- ...pplementaryDataUpdateRequestValidator.java | 4 +- .../external/controller/CaseController.java | 4 +- .../controller/CaseControllerTest.java | 4 +- 21 files changed, 789 insertions(+), 10 deletions(-) create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C1.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C1_Token_Creation.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_CreateCasePreRequisiteCaseworker_Multiple_Orgs.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Set_Supplementary_Data_C1.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Test_Data_Base.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_Base.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_C1.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.1.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.2.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.3.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.5.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144_GetCreateToken.td.json diff --git a/src/aat/resources/features/F-143 - supplementary_data new case in ES Search API/S-143.3.td.json b/src/aat/resources/features/F-143 - supplementary_data new case in ES Search API/S-143.3.td.json index 044fd00259..7f93cbbfc6 100644 --- a/src/aat/resources/features/F-143 - supplementary_data new case in ES Search API/S-143.3.td.json +++ b/src/aat/resources/features/F-143 - supplementary_data new case in ES Search API/S-143.3.td.json @@ -59,7 +59,7 @@ "supplementary_data": { "new_case": { - "orgID1": "true" + "orgID1": true } }, "after_submit_callback_response": null, diff --git a/src/aat/resources/features/F-143 - supplementary_data new case in ES Search API/S-143.4.td.json b/src/aat/resources/features/F-143 - supplementary_data new case in ES Search API/S-143.4.td.json index 18be57c9b3..e92339d423 100644 --- a/src/aat/resources/features/F-143 - supplementary_data new case in ES Search API/S-143.4.td.json +++ b/src/aat/resources/features/F-143 - supplementary_data new case in ES Search API/S-143.4.td.json @@ -59,7 +59,7 @@ "supplementary_data": { "new_case": { - "orgID1": "true" + "orgID1": true } }, "after_submit_callback_response": null, diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature new file mode 100644 index 0000000000..eb234870fb --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature @@ -0,0 +1,63 @@ +@F-144 +Feature: F-144: Update Cases Supplementary Data + + Background: Load test data for the scenario + Given an appropriate test context as detailed in the test data source + + @S-144.1 + Scenario: Must return the updated supplementary data values from Data store + Given an appropriate test context as detailed in the test data source, + And a user [Dil - who can create a case], + And a case [C1, which has just been] created as in [F-144_Case_Data_Create_C1], + When a request is prepared with appropriate values, + And it is submitted to call the [Update Cases Supplementary Data] operation of [CCD Data Store api], + Then a positive response is received, + And the response has all the details as expected. + + @S-144.2 @Ignore + Scenario: Need to be able to update an existing property + Given an appropriate test context as detailed in the test data source, + And a user [Dil - who can create a case], + And a case [C1, which has just been] created as in [F-144_Case_Data_Create_C1], + And a successful call [by Dil to update supplementary_data] as in [F-144_Update_Cases_Supplementary_Data_C1], + When a request is prepared with appropriate values, + And the request [contains updates of a specified value to an existing Supplementary Data property], + And it is submitted to call the [Update Cases Supplementary Data] operation of [CCD Data Store api], + Then a positive response is received, + And the response has all the details as expected. + + @S-144.3 @Ignore + Scenario: Need to be able to replace an existing property + Given an appropriate test context as detailed in the test data source, + And a user [Dil - who can create a case], + And a case [C1, which has just been] created as in [F-144_Case_Data_Create_C1], + And a successful call [by Dil to update supplementary_data] as in [F-144_Update_Cases_Supplementary_Data_C1], + When a request is prepared with appropriate values, + And the request [replaces the value of an existing supplementary_data property with the provided value], + And it is submitted to call the [Update Cases Supplementary Data] operation of [CCD Data Store api], + Then a positive response is received, + And the response has all the details as expected. + + @S-144.4 @elasticsearch @Ignore + Scenario: Must return the updated supplementary data values from Data store and search through elastic search + Given a case [C1, which has just been] created as in [F-144_Case_Data_Create_C1], + And a successful call [by Dil to update supplementary_data] as in [F-144_Set_Supplementary_Data_C1], + And a wait time of [5] seconds [to allow for Logstash to index the case just created], + And a user with [a valid profile], + And the request [is configured to search for the previously created case by the updated supplementary data value], + And a request is prepared with appropriate values, + When it is submitted to call the [external search query] operation of [CCD Data Store Elastic Search API], + Then the response [contains the previously created case], + And the response has all other details as expected. + + @S-144.5 @elasticsearch @Ignore + Scenario: Need to be able to decrement an existing property and search through elastic search + Given a case [C1, which has just been] created as in [F-144_Case_Data_Create_C1], + And a successful call [by Dil to update supplementary_data] as in [F-144_Set_Supplementary_Data_C1], + And a wait time of [5] seconds [to allow for Logstash to index the case just created], + And a user with [a valid profile], + And the request [is configured to search for the previously created case by the updated supplementary data value], + And a request is prepared with appropriate values, + When it is submitted to call the [external search query] operation of [CCD Data Store Elastic Search API], + Then the response [contains the previously created case], + And the response has all other details as expected. diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create.td.json new file mode 100644 index 0000000000..b24e611763 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create.td.json @@ -0,0 +1,12 @@ +{ + "_guid_": "F-144_Case_Data_Create", + "_extends_": "F-144_CreateCasePreRequisiteCaseworker_Multiple_Orgs", + "specs": [ + "to create a full case" + ], + "users": { + "invokingUser": { + "_extends_": "BeftaMasterCaseworker" + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C1.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C1.td.json new file mode 100644 index 0000000000..842ccefbbb --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C1.td.json @@ -0,0 +1,12 @@ +{ + "_guid_": "F-144_Case_Data_Create_C1", + "_extends_": "F-144_Case_Data_Create", + "specs": [ + "C1, which has just been" + ], + "request": { + "body": { + "event_token": "${[scenarioContext][siblingContexts][F-144_Case_Data_Create_C1_Token_Creation][testData][actualResponse][body][token]}" + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C1_Token_Creation.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C1_Token_Creation.td.json new file mode 100644 index 0000000000..61a8e85215 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C1_Token_Creation.td.json @@ -0,0 +1,4 @@ +{ + "_guid_": "F-144_Case_Data_Create_C1_Token_Creation", + "_extends_": "S-144_GetCreateToken" +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_CreateCasePreRequisiteCaseworker_Multiple_Orgs.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_CreateCasePreRequisiteCaseworker_Multiple_Orgs.td.json new file mode 100644 index 0000000000..8b6080ee5e --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_CreateCasePreRequisiteCaseworker_Multiple_Orgs.td.json @@ -0,0 +1,109 @@ +{ + "_guid_": "F-144_CreateCasePreRequisiteCaseworker_Multiple_Orgs", + "_extends_": "Case_Creation_Data_Base", + "specs": [ + "to create a case", + "As a prerequisite" + ], + + "prerequisites" : [ { + "Token_Creation": "S-144_GetCreateToken" + } + ], + + "users": { + "invokingUser": { + "_extends_": "BeftaMasterCaseworker" + } + }, + "request": { + "pathVariables": { + "jid": "BEFTA_MASTER", + "ctid": "FT_NewCaseSupplementry" + }, + "body": { + "data": { + "OrganisationPolicyField": { + "newCase": "Yes", + "Organisation": { + "OrganisationID": "orgID1", + "OrganisationName": "orgName1" + } + }, + "OrganisationPolicyField3" : { + "newCase": "Yes", + "Organisation": { + "OrganisationID": "orgID3", + "OrganisationName": "orgName3" + } + }, + "OrganisationPolicyField5" : { + "newCase" : "no", + "Organisation" : { + "OrganisationID" : "orgID2a", + "OrganisationName" : "orgName2a" + } + }, + "OrganisationPolicyField4" : { + "Organisation" : { + "OrganisationID" : "orgID2", + "OrganisationName" : "orgName2" + } + } + }, + "event": { + "id": "createCase", + "summary": "", + "description": "" + }, + "event_token": "${[scenarioContext][childContexts][Token_Creation][testData][actualResponse][body][token]}" + } + }, + + "expectedResponse": { + "body": { + "id": "[[ANYTHING_PRESENT]]", + "jurisdiction": "BEFTA_MASTER", + "state" : "CaseCreated", + "case_type_id": "FT_NewCaseSupplementry", + "created_date": "[[ANYTHING_PRESENT]]", + "last_modified": "[[ANYTHING_PRESENT]]", + "last_state_modified_date": "[[ANYTHING_PRESENT]]", + "security_classification": "PUBLIC", + "case_data": { + "OrganisationPolicyField": { + "Organisation": { + "OrganisationID": "orgID1", + "OrganisationName": "orgName1" + } + }, + "OrganisationPolicyField3" : { + "Organisation": { + "OrganisationID": "orgID3", + "OrganisationName": "orgName3" + } + }, + "OrganisationPolicyField5" : { + "Organisation" : { + "OrganisationID" : "orgID2a", + "OrganisationName" : "orgName2a" + } + }, + "OrganisationPolicyField4" : { + "Organisation" : { + "OrganisationID" : "orgID2", + "OrganisationName" : "orgName2" + } + } + }, + "data_classification": { + }, + "supplementary_data" : { + "new_case" : { + "orgID1" : true, + "orgID3" : true + } + } + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Set_Supplementary_Data_C1.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Set_Supplementary_Data_C1.td.json new file mode 100644 index 0000000000..3e6a6e49a4 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Set_Supplementary_Data_C1.td.json @@ -0,0 +1,31 @@ +{ + "_guid_": "F-144_Set_Supplementary_Data_C1", + "_extends_": "F-144_Update_Cases_Supplementary_Data_Base", + "specs": [ + "by Dil to update supplementary_data" + ], + "request": { + "_extends_": "Common_Request", + "body": { + "cases": "[[${[scenarioContext][siblingContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}]]", + "supplementary_data_updates": { + "$set": { + "new_case.OrgZ": false + } + } + } + }, + "expectedResponse": { + "_extends_": "Common_200_Response", + "headers": { + "Content-Length": "[[ANYTHING_PRESENT]]", + "Content-Type": "[[ANYTHING_PRESENT]]", + "Content-Encoding": "gzip" + }, + "body": { + "supplementary_data": { + "new_case.OrgZ": false + } + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Test_Data_Base.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Test_Data_Base.td.json new file mode 100644 index 0000000000..f5fed33c23 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Test_Data_Base.td.json @@ -0,0 +1,21 @@ +{ + "_guid_": "F-144_Test_Data_Base", + "title": "External Elastic Search Endpoint", + "productName": "CCD Data Store Elastic Search API", + "operationName": "external search query", + "method": "POST", + "uri": "/searchCases", + "user" : { + "_extends_": "BeftaMasterCaseworker" + }, + "request": { + "_extends_": "Common_Request", + "queryParams": { + "ctid": "FT_NewCaseSupplementry" + } + }, + + "expectedResponse": { + "_extends_": "Common_200_Response" + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_Base.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_Base.td.json new file mode 100644 index 0000000000..5bd0c7886b --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_Base.td.json @@ -0,0 +1,27 @@ +{ + "_guid_": "F-144_Update_Cases_Supplementary_Data_Base", + "title": "Update Cases Supplementary Data Base", + "productName": "CCD Data Store", + "operationName": "Update Cases Supplementary Data", + "method": "POST", + "uri": "/cases/supplementary-data", + "users": { + "invokingUser": { + "_extends_": "BeftaCaseworkerCaa" + } + }, + "request": { + "_extends_": "Common_Request", + "body": { + "cases": ["${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}"] + } + }, + "expectedResponse": { + "headers": { + "_extends_": "Common_Response_Headers", + "Content-Length": "[[ANYTHING_PRESENT]]", + "Content-Type": "[[ANYTHING_PRESENT]]", + "Content-Encoding": "[[ANYTHING_PRESENT]]" + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_C1.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_C1.td.json new file mode 100644 index 0000000000..45c6cda921 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_C1.td.json @@ -0,0 +1,33 @@ +{ + "_guid_": "F-144_Update_Cases_Supplementary_Data_C1", + "_extends_": "F-144_Update_Cases_Supplementary_Data_Base", + "specs": [ + "by Dil to update supplementary_data" + ], + "request": { + "_extends_": "Common_Request", + "body": { + "cases": "[[${[scenarioContext][siblingContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}]]", + "supplementary_data_updates": { + "$set": { + "orgs_assigned_users.OrgA": 25, + "orgs_assigned_users.OrgB": 1 + } + } + } + }, + "expectedResponse": { + "_extends_": "Common_200_Response", + "headers": { + "Content-Length": "[[ANYTHING_PRESENT]]", + "Content-Type": "[[ANYTHING_PRESENT]]", + "Content-Encoding": "gzip" + }, + "body": { + "supplementary_data": { + "orgs_assigned_users.OrgA": 25, + "orgs_assigned_users.OrgB": 1 + } + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.1.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.1.td.json new file mode 100644 index 0000000000..da884e699c --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.1.td.json @@ -0,0 +1,44 @@ +{ + "title": "Must return the updated supplementary data values from Data store", + "_guid_": "S-144.1", + "productName": "CCD Data Store api", + "operationName": "Update Cases Supplementary Data", + "_extends_": "F-144_Update_Cases_Supplementary_Data_Base", + "specs": [ + "Dil - who can create a case" + ], + "users": { + "invokingUser": { + "_extends_": "BeftaMasterCaseworker" + } + }, + "request": { + "body": { + "supplementary_data_updates": { + "$set": { + "new_case.orgID1": false, + "new_case.orgID3": false + } + } + } + }, + "expectedResponse": { + "_extends_": "Common_200_Response", + "headers": { + "Content-Length": "[[ANYTHING_PRESENT]]", + "Content-Type": "[[ANYTHING_PRESENT]]", + "Content-Encoding": "gzip" + }, + "body": { + "successes" : [ + { + "caseId": "${[scenarioContext][customValues][caseIdAsStringFrom_F-144_Case_Data_Create_C1]}", + "supplementary_data": { + "new_case.orgID1": false, + "new_case.orgID3": false + } + }], + "failures" : [ ] + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.2.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.2.td.json new file mode 100644 index 0000000000..43d0094662 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.2.td.json @@ -0,0 +1,35 @@ +{ + "title": "Need to be able to increment an existing property", + "_guid_": "S-144.2", + "productName": "CCD Data Store api", + "operationName": "Update Cases Supplementary Data", + "_extends_": "F-144_Update_Cases_Supplementary_Data_Base", + "specs": [ + "Dil - who can create a case", + "contains updates of a specified value to an existing Supplementary Data property" + ], + "request": { + "body": { + "supplementary_data_updates": { + "$inc": { + "orgs_assigned_users.OrgA": 1, + "orgs_assigned_users.OrgB": -1 + } + } + } + }, + "expectedResponse": { + "_extends_": "Common_200_Response", + "headers": { + "Content-Length": "[[ANYTHING_PRESENT]]", + "Content-Type": "[[ANYTHING_PRESENT]]", + "Content-Encoding": "gzip" + }, + "body": { + "supplementary_data": { + "orgs_assigned_users.OrgA": 26, + "orgs_assigned_users.OrgB": 0 + } + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.3.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.3.td.json new file mode 100644 index 0000000000..36033a2dc5 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.3.td.json @@ -0,0 +1,33 @@ +{ + "title": "Need to be able to replace an existing property", + "_guid_": "S-144.3", + "productName": "CCD Data Store api", + "operationName": "Update Cases Supplementary Data", + "_extends_": "F-144_Update_Cases_Supplementary_Data_Base", + "specs": [ + "Dil - who can create a case", + "replaces the value of an existing supplementary_data property with the provided value" + ], + "request": { + "body": { + "supplementary_data_updates": { + "$set": { + "orgs_assigned_users.OrgA": 20 + } + } + } + }, + "expectedResponse": { + "_extends_": "Common_200_Response", + "headers": { + "Content-Length": "[[ANYTHING_PRESENT]]", + "Content-Type": "[[ANYTHING_PRESENT]]", + "Content-Encoding": "gzip" + }, + "body": { + "supplementary_data": { + "orgs_assigned_users.OrgA": 20 + } + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json new file mode 100644 index 0000000000..8f09b26b82 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json @@ -0,0 +1,160 @@ +{ + "title": "Must return the updated supplementary data values from Data store internal search elastic search call", + "_guid_": "S-144.4", + "_extends_": "F-144_Test_Data_Base", + "specs": [ + "is configured to search for the previously created case by the updated supplementary data value", + "a valid profile", + "contains the previously created case" + ], + "users": { + "invokingUser": { + "_extends_": "BeftaCaseworker2Solicitor2" + } + }, + "request": { + "queryParams": { + "usecase": "workbasket" + }, + "body": { + "query":{ + "bool":{ + "filter":[ + { "bool":{ + "should": [ + { "range": { "supplementary_data.orgs_assigned_users.OrgZ": { "gte": 2500 } } } + ] + } + } + ] + } + }, + "from":0, + "size":6, + "_source":true, + "sort":{ + "created_date":{ + "order":"desc" + } + } + } + }, + + "expectedResponse": { + "body": { + "total": 1, + "cases": [ + { + "id": "${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}", + "jurisdiction": "BEFTA_JURISDICTION_2", + "state": "[[ANY_STRING_NOT_NULLABLE]]", + "version": "[[ANY_NULLABLE]]", + "case_type_id": "BEFTA_CASETYPE_2_1", + "created_date": "[[ANY_DATE_NOT_NULLABLE]]", + "last_modified": "[[ANY_DATE_NOT_NULLABLE]]", + "last_state_modified_date": "[[ANY_DATE_NOT_NULLABLE]]", + "security_classification": "[[ANY_STRING_NOT_NULLABLE]]", + "case_data": { + "MoneyGBPField": "[[ANY_NULLABLE]]", + "FixedListField": "[[ANY_NULLABLE]]", + "DocumentField4": "[[ANY_NULLABLE]]", + "DocumentField7": "[[ANY_NULLABLE]]", + "AddressUKField": { + "PostCode": "[[ANY_NULLABLE]]", + "PostTown": "[[ANY_NULLABLE]]", + "County": "[[ANY_NULLABLE]]", + "Country": "[[ANY_NULLABLE]]", + "AddressLine2": "[[ANY_NULLABLE]]", + "AddressLine3": "[[ANY_NULLABLE]]", + "AddressLine1": "[[ANY_NULLABLE]]" + }, + "ComplexField": { + "ComplexFixedListField": "[[ANY_NULLABLE]]", + "ComplexNestedField": { + "NestedCollectionTextField": [], + "NestedNumberField": "[[ANY_NULLABLE]]" + }, + "ComplexTextField": "[[ANY_NULLABLE]]" + }, + "FixedRadioListField": "[[ANY_NULLABLE]]", + "DateTimeField": "[[ANY_NULLABLE]]", + "PhoneUKField": "[[ANY_NULLABLE]]", + "NumberField":"[[ANY_NULLABLE]]", + "MultiSelectListField": [ + "OPTION5", + "OPTION4", + "OPTION3" + ], + "YesOrNoField": "[[ANY_NULLABLE]]", + "EmailField": "[[ANY_NULLABLE]]", + "TextField": "[[ANY_NULLABLE]]", + "DateField": "[[ANY_NULLABLE]]", + "TextAreaField": "[[ANY_NULLABLE]]", + "CollectionField": [] + }, + "data_classification": { + "MoneyGBPField": "[[ANY_STRING_NOT_NULLABLE]]", + "FixedListField": "[[ANY_STRING_NOT_NULLABLE]]", + "DocumentField4": "[[ANY_NULLABLE]]", + "DocumentField7": "[[ANY_NULLABLE]]", + "AddressUKField": { + "value": { + "PostCode": "[[ANY_STRING_NOT_NULLABLE]]", + "PostTown": "[[ANY_STRING_NOT_NULLABLE]]", + "County": "[[ANY_STRING_NOT_NULLABLE]]", + "Country": "[[ANY_STRING_NOT_NULLABLE]]", + "AddressLine2": "[[ANY_STRING_NOT_NULLABLE]]", + "AddressLine3": "[[ANY_STRING_NOT_NULLABLE]]", + "AddressLine1": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "classification": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "ComplexField": { + "value": { + "ComplexFixedListField": "[[ANY_STRING_NOT_NULLABLE]]", + "ComplexNestedField": { + "value": { + "NestedCollectionTextField": { + "value": [], + "classification": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "NestedNumberField": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "classification": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "ComplexTextField": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "classification": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "FixedRadioListField": "[[ANY_STRING_NOT_NULLABLE]]", + "DateTimeField": "[[ANY_STRING_NOT_NULLABLE]]", + "PhoneUKField": "[[ANY_STRING_NOT_NULLABLE]]", + "NumberField": "[[ANY_STRING_NOT_NULLABLE]]", + "MultiSelectListField": "[[ANY_STRING_NOT_NULLABLE]]", + "YesOrNoField": "[[ANY_STRING_NOT_NULLABLE]]", + "EmailField": "[[ANY_STRING_NOT_NULLABLE]]", + "TextField": "[[ANY_STRING_NOT_NULLABLE]]", + "DateField": "[[ANY_STRING_NOT_NULLABLE]]", + "TextAreaField": "[[ANY_STRING_NOT_NULLABLE]]", + "CollectionField": { + "value": [], + "classification": "[[ANY_STRING_NOT_NULLABLE]]" + } + }, + "supplementary_data": null, + "after_submit_callback_response": "[[ANY_NULLABLE]]", + "callback_response_status_code": "[[ANY_NULLABLE]]", + "callback_response_status": "[[ANY_NULLABLE]]", + "delete_draft_response_status_code": "[[ANY_NULLABLE]]", + "delete_draft_response_status": "[[ANY_NULLABLE]]" + } + ], + "case_types_results": [ + { + "total": 1, + "case_type_id": "BEFTA_CASETYPE_2_1" + } + ] + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.5.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.5.td.json new file mode 100644 index 0000000000..f6e040053b --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.5.td.json @@ -0,0 +1,167 @@ +{ + "title": "Need to be able to decrement an existing property and search through elastic search external call", + "_guid_": "S-144.5", + "_extends_": "F-144_Test_Data_Base", + "specs": [ + "is configured to search for the previously created case by the updated supplementary data value", + "a valid profile", + "contains the previously created case" + ], + "users": { + "invokingUser": { + "_extends_": "BeftaCaseworker2Solicitor2" + } + }, + "request": { + "queryParams": { + "usecase": "workbasket" + }, + "body": { + "query": { + "bool": { + "filter": [ + { + "bool": { + "should": [ + { + "range": { + "supplementary_data.orgs_assigned_users.OrgZ": { + "lte": 2499, + "gte": 2498 + } + } + } + ] + } + } + ] + } + }, + "from": 0, + "size": 6, + "_source": true, + "sort": { + "created_date": { + "order": "desc" + } + } + } + }, + "expectedResponse": { + "body": { + "total": 1, + "cases": [ + { + "id": "${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}", + "jurisdiction": "BEFTA_JURISDICTION_2", + "state": "[[ANY_STRING_NOT_NULLABLE]]", + "version": "[[ANY_NULLABLE]]", + "case_type_id": "BEFTA_CASETYPE_2_1", + "created_date": "[[ANY_DATE_NOT_NULLABLE]]", + "last_modified": "[[ANY_DATE_NOT_NULLABLE]]", + "last_state_modified_date": "[[ANY_DATE_NOT_NULLABLE]]", + "security_classification": "[[ANY_STRING_NOT_NULLABLE]]", + "case_data": { + "MoneyGBPField": "[[ANY_NULLABLE]]", + "FixedListField": "[[ANY_NULLABLE]]", + "DocumentField4": "[[ANY_NULLABLE]]", + "DocumentField7": "[[ANY_NULLABLE]]", + "AddressUKField": { + "PostCode": "[[ANY_NULLABLE]]", + "PostTown": "[[ANY_NULLABLE]]", + "County": "[[ANY_NULLABLE]]", + "Country": "[[ANY_NULLABLE]]", + "AddressLine2": "[[ANY_NULLABLE]]", + "AddressLine3": "[[ANY_NULLABLE]]", + "AddressLine1": "[[ANY_NULLABLE]]" + }, + "ComplexField": { + "ComplexFixedListField": "[[ANY_NULLABLE]]", + "ComplexNestedField": { + "NestedCollectionTextField": [], + "NestedNumberField": "[[ANY_NULLABLE]]" + }, + "ComplexTextField": "[[ANY_NULLABLE]]" + }, + "FixedRadioListField": "[[ANY_NULLABLE]]", + "DateTimeField": "[[ANY_NULLABLE]]", + "PhoneUKField": "[[ANY_NULLABLE]]", + "NumberField":"[[ANY_NULLABLE]]", + "MultiSelectListField": [ + "OPTION5", + "OPTION4", + "OPTION3" + ], + "YesOrNoField": "[[ANY_NULLABLE]]", + "EmailField": "[[ANY_NULLABLE]]", + "TextField": "[[ANY_NULLABLE]]", + "DateField": "[[ANY_NULLABLE]]", + "TextAreaField": "[[ANY_NULLABLE]]", + "CollectionField": [] + }, + "data_classification": { + "MoneyGBPField": "[[ANY_STRING_NOT_NULLABLE]]", + "FixedListField": "[[ANY_STRING_NOT_NULLABLE]]", + "DocumentField4": "[[ANY_NULLABLE]]", + "DocumentField7": "[[ANY_NULLABLE]]", + "AddressUKField": { + "value": { + "PostCode": "[[ANY_STRING_NOT_NULLABLE]]", + "PostTown": "[[ANY_STRING_NOT_NULLABLE]]", + "County": "[[ANY_STRING_NOT_NULLABLE]]", + "Country": "[[ANY_STRING_NOT_NULLABLE]]", + "AddressLine2": "[[ANY_STRING_NOT_NULLABLE]]", + "AddressLine3": "[[ANY_STRING_NOT_NULLABLE]]", + "AddressLine1": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "classification": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "ComplexField": { + "value": { + "ComplexFixedListField": "[[ANY_STRING_NOT_NULLABLE]]", + "ComplexNestedField": { + "value": { + "NestedCollectionTextField": { + "value": [], + "classification": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "NestedNumberField": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "classification": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "ComplexTextField": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "classification": "[[ANY_STRING_NOT_NULLABLE]]" + }, + "FixedRadioListField": "[[ANY_STRING_NOT_NULLABLE]]", + "DateTimeField": "[[ANY_STRING_NOT_NULLABLE]]", + "PhoneUKField": "[[ANY_STRING_NOT_NULLABLE]]", + "NumberField": "[[ANY_STRING_NOT_NULLABLE]]", + "MultiSelectListField": "[[ANY_STRING_NOT_NULLABLE]]", + "YesOrNoField": "[[ANY_STRING_NOT_NULLABLE]]", + "EmailField": "[[ANY_STRING_NOT_NULLABLE]]", + "TextField": "[[ANY_STRING_NOT_NULLABLE]]", + "DateField": "[[ANY_STRING_NOT_NULLABLE]]", + "TextAreaField": "[[ANY_STRING_NOT_NULLABLE]]", + "CollectionField": { + "value": [], + "classification": "[[ANY_STRING_NOT_NULLABLE]]" + } + }, + "supplementary_data": null, + "after_submit_callback_response": "[[ANY_NULLABLE]]", + "callback_response_status_code": "[[ANY_NULLABLE]]", + "callback_response_status": "[[ANY_NULLABLE]]", + "delete_draft_response_status_code": "[[ANY_NULLABLE]]", + "delete_draft_response_status": "[[ANY_NULLABLE]]" + } + ], + "case_types_results": [ + { + "total": 1, + "case_type_id": "BEFTA_CASETYPE_2_1" + } + ] + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144_GetCreateToken.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144_GetCreateToken.td.json new file mode 100644 index 0000000000..235b362d6f --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144_GetCreateToken.td.json @@ -0,0 +1,28 @@ +{ + "_guid_": "S-144_GetCreateToken", + "_extends_": "Standard_Token_Creation_Data_For_Case_Creation", + + "specs": [ + "to create a token for case creation", + "As a prerequisite" + ], + + "users": { + "invokingUser": { + "_extends_": "BeftaMasterCaseworker" + } + }, + + "request": { + "pathVariables": { + "jid": "BEFTA_MASTER", + "ctid": "FT_NewCaseSupplementry", + "etid": "createCase" + } + }, + "expectedResponse": { + "body": { + "event_id": "createCase" + } + } +} diff --git a/src/main/java/uk/gov/hmcts/ccd/domain/model/std/SupplementaryDataCasesUpdateRequest.java b/src/main/java/uk/gov/hmcts/ccd/domain/model/std/SupplementaryDataCasesUpdateRequest.java index 4013d4662b..c97191b97d 100644 --- a/src/main/java/uk/gov/hmcts/ccd/domain/model/std/SupplementaryDataCasesUpdateRequest.java +++ b/src/main/java/uk/gov/hmcts/ccd/domain/model/std/SupplementaryDataCasesUpdateRequest.java @@ -18,8 +18,8 @@ public class SupplementaryDataCasesUpdateRequest { @JsonProperty("cases") private List caseIds; - @JsonProperty("supplementary_data_request") - private Map> supplementaryDataRequest; + @JsonProperty("supplementary_data_updates") + private Map> requestData; } diff --git a/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java b/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java index 5fac9d701a..08ee5264ef 100644 --- a/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java +++ b/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java @@ -30,8 +30,8 @@ public void validate(SupplementaryDataUpdateRequest supplementaryDataUpdateReque public void validate(SupplementaryDataCasesUpdateRequest caseSupplementaryDataUpdateRequest) { if (caseSupplementaryDataUpdateRequest == null || caseSupplementaryDataUpdateRequest.getCaseIds() == null - || caseSupplementaryDataUpdateRequest.getSupplementaryDataRequest() != null - || caseSupplementaryDataUpdateRequest.getSupplementaryDataRequest().isEmpty() + || caseSupplementaryDataUpdateRequest.getRequestData() != null + || caseSupplementaryDataUpdateRequest.getRequestData().isEmpty() || caseSupplementaryDataUpdateRequest.getCaseIds().isEmpty()) { throw new BadRequestException(SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID); } diff --git a/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java b/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java index 6c8258a769..2a613018f0 100644 --- a/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java +++ b/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java @@ -494,7 +494,7 @@ public ResponseEntity updateCaseSupplementaryData(@Pa + "\t\"caseId value 1\",\n" + "\t\"caseId value 2\"\n" + "\t\"],\n" - + "\"supplementary_data_request\": {\n" + + "\"supplementary_data_updates\": {\n" + "\t\"$inc\": {\n" + "\t\t\"orgs_assigned_users.OrgA\": 1,\n" + "\t\t\"orgs_assigned_users.OrgB\": -1\n" @@ -520,7 +520,7 @@ public ResponseEntity updateCasesSupplementaryDa List successes = new ArrayList<>(); SupplementaryDataUpdateRequest supplementaryDataUpdateRequest = - new SupplementaryDataUpdateRequest(supplementaryDataCasesUpdateRequest.getSupplementaryDataRequest()); + new SupplementaryDataUpdateRequest(supplementaryDataCasesUpdateRequest.getRequestData()); for (String caseId : caseIds) { this.requestValidator.validate(supplementaryDataUpdateRequest); diff --git a/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java b/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java index c102c01bed..7c29d86e5b 100644 --- a/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java +++ b/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java @@ -737,7 +737,7 @@ private SupplementaryDataCasesUpdateRequest createCaseRequestDataOrgAWithCases() + "\t\"cases\": [\n" + "\t\t\"" + CASE_REFERENCE + "\"\n" + "\t],\n" - + "\"supplementary_data_request\": {\n" + + "\"supplementary_data_updates\": {\n" + "\t\"$set\": {\n" + "\t\t\"new_case.organisationA\": false\n" + "\t}\n" @@ -751,7 +751,7 @@ private SupplementaryDataCasesUpdateRequest createRequestDataNestedWithCases() { + "\t\"cases\": [\n" + "\t\t\"" + CASE_REFERENCE + "\n" + "\t],\n" - + "\"supplementary_data_request\": {\n" + + "\"supplementary_data_updates\": {\n" + "\t\"$set\": {\n" + "\t\t\".organisationA.organisationB\": false\n" + "\t}\n" From 074056dbade19da1ba50428ed8a3b7f4053d6238 Mon Sep 17 00:00:00 2001 From: patelila Date: Mon, 17 Mar 2025 12:59:45 +0000 Subject: [PATCH 10/14] FT Test 2 --- .../F-144.feature | 6 +-- .../F-144_Case_Data_Create_C2.td.json | 12 +++++ ...Case_Data_Create_C2_Token_Creation.td.json | 4 ++ .../F-144_Set_Supplementary_Data_C1.td.json | 2 +- ...date_Cases_Supplementary_Data_Base.td.json | 2 +- ...Update_Cases_Supplementary_Data_C1.td.json | 11 +++-- .../S-144.1.td.json | 3 ++ .../S-144.2.td.json | 49 +++++++++++++------ 8 files changed, 63 insertions(+), 26 deletions(-) create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C2.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C2_Token_Creation.td.json diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature index eb234870fb..c70f12cc40 100644 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature @@ -14,12 +14,12 @@ Feature: F-144: Update Cases Supplementary Data Then a positive response is received, And the response has all the details as expected. - @S-144.2 @Ignore - Scenario: Need to be able to update an existing property + @S-144.2 + Scenario: Need to be able to update an existing property for multiple cases Given an appropriate test context as detailed in the test data source, And a user [Dil - who can create a case], And a case [C1, which has just been] created as in [F-144_Case_Data_Create_C1], - And a successful call [by Dil to update supplementary_data] as in [F-144_Update_Cases_Supplementary_Data_C1], + And a case [C2, which has just been] created as in [F-144_Case_Data_Create_C2], When a request is prepared with appropriate values, And the request [contains updates of a specified value to an existing Supplementary Data property], And it is submitted to call the [Update Cases Supplementary Data] operation of [CCD Data Store api], diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C2.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C2.td.json new file mode 100644 index 0000000000..b035048103 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C2.td.json @@ -0,0 +1,12 @@ +{ + "_guid_": "F-144_Case_Data_Create_C2", + "_extends_": "F-144_Case_Data_Create", + "specs": [ + "C2, which has just been" + ], + "request": { + "body": { + "event_token": "${[scenarioContext][siblingContexts][F-144_Case_Data_Create_C2_Token_Creation][testData][actualResponse][body][token]}" + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C2_Token_Creation.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C2_Token_Creation.td.json new file mode 100644 index 0000000000..a85d0d3b45 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C2_Token_Creation.td.json @@ -0,0 +1,4 @@ +{ + "_guid_": "F-144_Case_Data_Create_C2_Token_Creation", + "_extends_": "S-144_GetCreateToken" +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Set_Supplementary_Data_C1.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Set_Supplementary_Data_C1.td.json index 3e6a6e49a4..7ad4f0b10e 100644 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Set_Supplementary_Data_C1.td.json +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Set_Supplementary_Data_C1.td.json @@ -7,7 +7,7 @@ "request": { "_extends_": "Common_Request", "body": { - "cases": "[[${[scenarioContext][siblingContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}]]", + "cases": ["${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}"], "supplementary_data_updates": { "$set": { "new_case.OrgZ": false diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_Base.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_Base.td.json index 5bd0c7886b..39c536d1a6 100644 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_Base.td.json +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_Base.td.json @@ -13,7 +13,7 @@ "request": { "_extends_": "Common_Request", "body": { - "cases": ["${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}"] + } }, "expectedResponse": { diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_C1.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_C1.td.json index 45c6cda921..b16d0c7a20 100644 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_C1.td.json +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Update_Cases_Supplementary_Data_C1.td.json @@ -7,11 +7,13 @@ "request": { "_extends_": "Common_Request", "body": { - "cases": "[[${[scenarioContext][siblingContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}]]", + "cases": [ + + ], "supplementary_data_updates": { "$set": { - "orgs_assigned_users.OrgA": 25, - "orgs_assigned_users.OrgB": 1 + "new_case.orgID1": false, + "new_case.orgID4": false } } } @@ -25,8 +27,7 @@ }, "body": { "supplementary_data": { - "orgs_assigned_users.OrgA": 25, - "orgs_assigned_users.OrgB": 1 + "new_case.orgID1": false } } } diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.1.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.1.td.json index da884e699c..b9e5dc8f84 100644 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.1.td.json +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.1.td.json @@ -14,6 +14,9 @@ }, "request": { "body": { + "cases": [ + "${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}" + ], "supplementary_data_updates": { "$set": { "new_case.orgID1": false, diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.2.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.2.td.json index 43d0094662..c0b3f78140 100644 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.2.td.json +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.2.td.json @@ -1,5 +1,5 @@ { - "title": "Need to be able to increment an existing property", + "title": "Need to be able to update an existing property for multiple cases", "_guid_": "S-144.2", "productName": "CCD Data Store api", "operationName": "Update Cases Supplementary Data", @@ -10,26 +10,43 @@ ], "request": { "body": { + "cases": [ + "${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}", + "${[scenarioContext][childContexts][F-144_Case_Data_Create_C2][testData][actualResponse][body][id]}" + ], "supplementary_data_updates": { - "$inc": { - "orgs_assigned_users.OrgA": 1, - "orgs_assigned_users.OrgB": -1 + "$set": { + "new_case.orgID1": false, + "new_case.orgID4": false } } } }, - "expectedResponse": { - "_extends_": "Common_200_Response", - "headers": { - "Content-Length": "[[ANYTHING_PRESENT]]", - "Content-Type": "[[ANYTHING_PRESENT]]", - "Content-Encoding": "gzip" - }, + "expectedResponse": { + "_extends_": "Common_200_Response", + "headers": { + "Content-Length": "[[ANYTHING_PRESENT]]", + "Content-Type": "[[ANYTHING_PRESENT]]", + "Content-Encoding": "gzip" + }, "body": { - "supplementary_data": { - "orgs_assigned_users.OrgA": 26, - "orgs_assigned_users.OrgB": 0 - } + "successes" : [ + { + "caseId": "${[scenarioContext][customValues][caseIdAsStringFrom_F-144_Case_Data_Create_C1]}", + "supplementary_data": { + "new_case.orgID1": false, + "new_case.orgID4": false + } + }, + { + "caseId": "${[scenarioContext][customValues][caseIdAsStringFrom_F-144_Case_Data_Create_C2]}", + "supplementary_data": { + "new_case.orgID1": false, + "new_case.orgID4": false + } + } + ], + "failures" : [ ] } - } + } } From bb055a3b457e62ca56d60889a54662623b6f7b63 Mon Sep 17 00:00:00 2001 From: patelila Date: Mon, 17 Mar 2025 13:15:10 +0000 Subject: [PATCH 11/14] FT Test 3 --- .../F-144.feature | 3 +-- .../S-144.3.td.json | 13 +++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature index c70f12cc40..8ae484a64a 100644 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature @@ -26,12 +26,11 @@ Feature: F-144: Update Cases Supplementary Data Then a positive response is received, And the response has all the details as expected. - @S-144.3 @Ignore + @S-144.3 Scenario: Need to be able to replace an existing property Given an appropriate test context as detailed in the test data source, And a user [Dil - who can create a case], And a case [C1, which has just been] created as in [F-144_Case_Data_Create_C1], - And a successful call [by Dil to update supplementary_data] as in [F-144_Update_Cases_Supplementary_Data_C1], When a request is prepared with appropriate values, And the request [replaces the value of an existing supplementary_data property with the provided value], And it is submitted to call the [Update Cases Supplementary Data] operation of [CCD Data Store api], diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.3.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.3.td.json index 36033a2dc5..2dbf45decf 100644 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.3.td.json +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.3.td.json @@ -10,6 +10,9 @@ ], "request": { "body": { + "cases": [ + "${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}" + ], "supplementary_data_updates": { "$set": { "orgs_assigned_users.OrgA": 20 @@ -25,8 +28,14 @@ "Content-Encoding": "gzip" }, "body": { - "supplementary_data": { - "orgs_assigned_users.OrgA": 20 + "successes" : [ + { + "caseId": "${[scenarioContext][customValues][caseIdAsStringFrom_F-144_Case_Data_Create_C1]}", + "supplementary_data" : { + "orgs_assigned_users.OrgA" : 20 + } + }], + "failures" : [] } } } From 7c0b5ee45bc90acbe5abcc1f2335ca7219e2671b Mon Sep 17 00:00:00 2001 From: patelila Date: Mon, 17 Mar 2025 15:07:19 +0000 Subject: [PATCH 12/14] remove unnecessary test --- .../F-144.feature | 23 --- .../S-144.4.td.json | 160 ----------------- .../S-144.5.td.json | 167 ------------------ 3 files changed, 350 deletions(-) delete mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json delete mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.5.td.json diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature index 8ae484a64a..8ce5a0de61 100644 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature @@ -37,26 +37,3 @@ Feature: F-144: Update Cases Supplementary Data Then a positive response is received, And the response has all the details as expected. - @S-144.4 @elasticsearch @Ignore - Scenario: Must return the updated supplementary data values from Data store and search through elastic search - Given a case [C1, which has just been] created as in [F-144_Case_Data_Create_C1], - And a successful call [by Dil to update supplementary_data] as in [F-144_Set_Supplementary_Data_C1], - And a wait time of [5] seconds [to allow for Logstash to index the case just created], - And a user with [a valid profile], - And the request [is configured to search for the previously created case by the updated supplementary data value], - And a request is prepared with appropriate values, - When it is submitted to call the [external search query] operation of [CCD Data Store Elastic Search API], - Then the response [contains the previously created case], - And the response has all other details as expected. - - @S-144.5 @elasticsearch @Ignore - Scenario: Need to be able to decrement an existing property and search through elastic search - Given a case [C1, which has just been] created as in [F-144_Case_Data_Create_C1], - And a successful call [by Dil to update supplementary_data] as in [F-144_Set_Supplementary_Data_C1], - And a wait time of [5] seconds [to allow for Logstash to index the case just created], - And a user with [a valid profile], - And the request [is configured to search for the previously created case by the updated supplementary data value], - And a request is prepared with appropriate values, - When it is submitted to call the [external search query] operation of [CCD Data Store Elastic Search API], - Then the response [contains the previously created case], - And the response has all other details as expected. diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json deleted file mode 100644 index 8f09b26b82..0000000000 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json +++ /dev/null @@ -1,160 +0,0 @@ -{ - "title": "Must return the updated supplementary data values from Data store internal search elastic search call", - "_guid_": "S-144.4", - "_extends_": "F-144_Test_Data_Base", - "specs": [ - "is configured to search for the previously created case by the updated supplementary data value", - "a valid profile", - "contains the previously created case" - ], - "users": { - "invokingUser": { - "_extends_": "BeftaCaseworker2Solicitor2" - } - }, - "request": { - "queryParams": { - "usecase": "workbasket" - }, - "body": { - "query":{ - "bool":{ - "filter":[ - { "bool":{ - "should": [ - { "range": { "supplementary_data.orgs_assigned_users.OrgZ": { "gte": 2500 } } } - ] - } - } - ] - } - }, - "from":0, - "size":6, - "_source":true, - "sort":{ - "created_date":{ - "order":"desc" - } - } - } - }, - - "expectedResponse": { - "body": { - "total": 1, - "cases": [ - { - "id": "${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}", - "jurisdiction": "BEFTA_JURISDICTION_2", - "state": "[[ANY_STRING_NOT_NULLABLE]]", - "version": "[[ANY_NULLABLE]]", - "case_type_id": "BEFTA_CASETYPE_2_1", - "created_date": "[[ANY_DATE_NOT_NULLABLE]]", - "last_modified": "[[ANY_DATE_NOT_NULLABLE]]", - "last_state_modified_date": "[[ANY_DATE_NOT_NULLABLE]]", - "security_classification": "[[ANY_STRING_NOT_NULLABLE]]", - "case_data": { - "MoneyGBPField": "[[ANY_NULLABLE]]", - "FixedListField": "[[ANY_NULLABLE]]", - "DocumentField4": "[[ANY_NULLABLE]]", - "DocumentField7": "[[ANY_NULLABLE]]", - "AddressUKField": { - "PostCode": "[[ANY_NULLABLE]]", - "PostTown": "[[ANY_NULLABLE]]", - "County": "[[ANY_NULLABLE]]", - "Country": "[[ANY_NULLABLE]]", - "AddressLine2": "[[ANY_NULLABLE]]", - "AddressLine3": "[[ANY_NULLABLE]]", - "AddressLine1": "[[ANY_NULLABLE]]" - }, - "ComplexField": { - "ComplexFixedListField": "[[ANY_NULLABLE]]", - "ComplexNestedField": { - "NestedCollectionTextField": [], - "NestedNumberField": "[[ANY_NULLABLE]]" - }, - "ComplexTextField": "[[ANY_NULLABLE]]" - }, - "FixedRadioListField": "[[ANY_NULLABLE]]", - "DateTimeField": "[[ANY_NULLABLE]]", - "PhoneUKField": "[[ANY_NULLABLE]]", - "NumberField":"[[ANY_NULLABLE]]", - "MultiSelectListField": [ - "OPTION5", - "OPTION4", - "OPTION3" - ], - "YesOrNoField": "[[ANY_NULLABLE]]", - "EmailField": "[[ANY_NULLABLE]]", - "TextField": "[[ANY_NULLABLE]]", - "DateField": "[[ANY_NULLABLE]]", - "TextAreaField": "[[ANY_NULLABLE]]", - "CollectionField": [] - }, - "data_classification": { - "MoneyGBPField": "[[ANY_STRING_NOT_NULLABLE]]", - "FixedListField": "[[ANY_STRING_NOT_NULLABLE]]", - "DocumentField4": "[[ANY_NULLABLE]]", - "DocumentField7": "[[ANY_NULLABLE]]", - "AddressUKField": { - "value": { - "PostCode": "[[ANY_STRING_NOT_NULLABLE]]", - "PostTown": "[[ANY_STRING_NOT_NULLABLE]]", - "County": "[[ANY_STRING_NOT_NULLABLE]]", - "Country": "[[ANY_STRING_NOT_NULLABLE]]", - "AddressLine2": "[[ANY_STRING_NOT_NULLABLE]]", - "AddressLine3": "[[ANY_STRING_NOT_NULLABLE]]", - "AddressLine1": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "classification": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "ComplexField": { - "value": { - "ComplexFixedListField": "[[ANY_STRING_NOT_NULLABLE]]", - "ComplexNestedField": { - "value": { - "NestedCollectionTextField": { - "value": [], - "classification": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "NestedNumberField": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "classification": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "ComplexTextField": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "classification": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "FixedRadioListField": "[[ANY_STRING_NOT_NULLABLE]]", - "DateTimeField": "[[ANY_STRING_NOT_NULLABLE]]", - "PhoneUKField": "[[ANY_STRING_NOT_NULLABLE]]", - "NumberField": "[[ANY_STRING_NOT_NULLABLE]]", - "MultiSelectListField": "[[ANY_STRING_NOT_NULLABLE]]", - "YesOrNoField": "[[ANY_STRING_NOT_NULLABLE]]", - "EmailField": "[[ANY_STRING_NOT_NULLABLE]]", - "TextField": "[[ANY_STRING_NOT_NULLABLE]]", - "DateField": "[[ANY_STRING_NOT_NULLABLE]]", - "TextAreaField": "[[ANY_STRING_NOT_NULLABLE]]", - "CollectionField": { - "value": [], - "classification": "[[ANY_STRING_NOT_NULLABLE]]" - } - }, - "supplementary_data": null, - "after_submit_callback_response": "[[ANY_NULLABLE]]", - "callback_response_status_code": "[[ANY_NULLABLE]]", - "callback_response_status": "[[ANY_NULLABLE]]", - "delete_draft_response_status_code": "[[ANY_NULLABLE]]", - "delete_draft_response_status": "[[ANY_NULLABLE]]" - } - ], - "case_types_results": [ - { - "total": 1, - "case_type_id": "BEFTA_CASETYPE_2_1" - } - ] - } - } -} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.5.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.5.td.json deleted file mode 100644 index f6e040053b..0000000000 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.5.td.json +++ /dev/null @@ -1,167 +0,0 @@ -{ - "title": "Need to be able to decrement an existing property and search through elastic search external call", - "_guid_": "S-144.5", - "_extends_": "F-144_Test_Data_Base", - "specs": [ - "is configured to search for the previously created case by the updated supplementary data value", - "a valid profile", - "contains the previously created case" - ], - "users": { - "invokingUser": { - "_extends_": "BeftaCaseworker2Solicitor2" - } - }, - "request": { - "queryParams": { - "usecase": "workbasket" - }, - "body": { - "query": { - "bool": { - "filter": [ - { - "bool": { - "should": [ - { - "range": { - "supplementary_data.orgs_assigned_users.OrgZ": { - "lte": 2499, - "gte": 2498 - } - } - } - ] - } - } - ] - } - }, - "from": 0, - "size": 6, - "_source": true, - "sort": { - "created_date": { - "order": "desc" - } - } - } - }, - "expectedResponse": { - "body": { - "total": 1, - "cases": [ - { - "id": "${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}", - "jurisdiction": "BEFTA_JURISDICTION_2", - "state": "[[ANY_STRING_NOT_NULLABLE]]", - "version": "[[ANY_NULLABLE]]", - "case_type_id": "BEFTA_CASETYPE_2_1", - "created_date": "[[ANY_DATE_NOT_NULLABLE]]", - "last_modified": "[[ANY_DATE_NOT_NULLABLE]]", - "last_state_modified_date": "[[ANY_DATE_NOT_NULLABLE]]", - "security_classification": "[[ANY_STRING_NOT_NULLABLE]]", - "case_data": { - "MoneyGBPField": "[[ANY_NULLABLE]]", - "FixedListField": "[[ANY_NULLABLE]]", - "DocumentField4": "[[ANY_NULLABLE]]", - "DocumentField7": "[[ANY_NULLABLE]]", - "AddressUKField": { - "PostCode": "[[ANY_NULLABLE]]", - "PostTown": "[[ANY_NULLABLE]]", - "County": "[[ANY_NULLABLE]]", - "Country": "[[ANY_NULLABLE]]", - "AddressLine2": "[[ANY_NULLABLE]]", - "AddressLine3": "[[ANY_NULLABLE]]", - "AddressLine1": "[[ANY_NULLABLE]]" - }, - "ComplexField": { - "ComplexFixedListField": "[[ANY_NULLABLE]]", - "ComplexNestedField": { - "NestedCollectionTextField": [], - "NestedNumberField": "[[ANY_NULLABLE]]" - }, - "ComplexTextField": "[[ANY_NULLABLE]]" - }, - "FixedRadioListField": "[[ANY_NULLABLE]]", - "DateTimeField": "[[ANY_NULLABLE]]", - "PhoneUKField": "[[ANY_NULLABLE]]", - "NumberField":"[[ANY_NULLABLE]]", - "MultiSelectListField": [ - "OPTION5", - "OPTION4", - "OPTION3" - ], - "YesOrNoField": "[[ANY_NULLABLE]]", - "EmailField": "[[ANY_NULLABLE]]", - "TextField": "[[ANY_NULLABLE]]", - "DateField": "[[ANY_NULLABLE]]", - "TextAreaField": "[[ANY_NULLABLE]]", - "CollectionField": [] - }, - "data_classification": { - "MoneyGBPField": "[[ANY_STRING_NOT_NULLABLE]]", - "FixedListField": "[[ANY_STRING_NOT_NULLABLE]]", - "DocumentField4": "[[ANY_NULLABLE]]", - "DocumentField7": "[[ANY_NULLABLE]]", - "AddressUKField": { - "value": { - "PostCode": "[[ANY_STRING_NOT_NULLABLE]]", - "PostTown": "[[ANY_STRING_NOT_NULLABLE]]", - "County": "[[ANY_STRING_NOT_NULLABLE]]", - "Country": "[[ANY_STRING_NOT_NULLABLE]]", - "AddressLine2": "[[ANY_STRING_NOT_NULLABLE]]", - "AddressLine3": "[[ANY_STRING_NOT_NULLABLE]]", - "AddressLine1": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "classification": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "ComplexField": { - "value": { - "ComplexFixedListField": "[[ANY_STRING_NOT_NULLABLE]]", - "ComplexNestedField": { - "value": { - "NestedCollectionTextField": { - "value": [], - "classification": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "NestedNumberField": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "classification": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "ComplexTextField": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "classification": "[[ANY_STRING_NOT_NULLABLE]]" - }, - "FixedRadioListField": "[[ANY_STRING_NOT_NULLABLE]]", - "DateTimeField": "[[ANY_STRING_NOT_NULLABLE]]", - "PhoneUKField": "[[ANY_STRING_NOT_NULLABLE]]", - "NumberField": "[[ANY_STRING_NOT_NULLABLE]]", - "MultiSelectListField": "[[ANY_STRING_NOT_NULLABLE]]", - "YesOrNoField": "[[ANY_STRING_NOT_NULLABLE]]", - "EmailField": "[[ANY_STRING_NOT_NULLABLE]]", - "TextField": "[[ANY_STRING_NOT_NULLABLE]]", - "DateField": "[[ANY_STRING_NOT_NULLABLE]]", - "TextAreaField": "[[ANY_STRING_NOT_NULLABLE]]", - "CollectionField": { - "value": [], - "classification": "[[ANY_STRING_NOT_NULLABLE]]" - } - }, - "supplementary_data": null, - "after_submit_callback_response": "[[ANY_NULLABLE]]", - "callback_response_status_code": "[[ANY_NULLABLE]]", - "callback_response_status": "[[ANY_NULLABLE]]", - "delete_draft_response_status_code": "[[ANY_NULLABLE]]", - "delete_draft_response_status": "[[ANY_NULLABLE]]" - } - ], - "case_types_results": [ - { - "total": 1, - "case_type_id": "BEFTA_CASETYPE_2_1" - } - ] - } - } -} From ee8700823421bd8d1758169714ef60f17cb275aa Mon Sep 17 00:00:00 2001 From: patelila Date: Tue, 18 Mar 2025 13:45:18 +0000 Subject: [PATCH 13/14] changes to unit test --- ...pplementaryDataUpdateRequestValidator.java | 12 ----- .../external/controller/CaseController.java | 46 +++++++++++++------ ...mentaryDataUpdateRequestValidatorTest.java | 3 +- .../controller/CaseControllerTest.java | 42 +++++++++++++++++ 4 files changed, 76 insertions(+), 27 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java b/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java index 08ee5264ef..d3158708b7 100644 --- a/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java +++ b/src/main/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidator.java @@ -5,13 +5,11 @@ import javax.inject.Named; import javax.inject.Singleton; import uk.gov.hmcts.ccd.data.casedetails.supplementarydata.SupplementaryDataOperation; -import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataCasesUpdateRequest; import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataUpdateRequest; import uk.gov.hmcts.ccd.endpoint.exceptions.BadRequestException; import static uk.gov.hmcts.ccd.v2.V2.Error.MORE_THAN_ONE_NESTED_LEVEL; import static uk.gov.hmcts.ccd.v2.V2.Error.SUPPLEMENTARY_DATA_UPDATE_INVALID; -import static uk.gov.hmcts.ccd.v2.V2.Error.SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID; import static uk.gov.hmcts.ccd.v2.V2.Error.UNKNOWN_SUPPLEMENTARY_UPDATE_OPERATION; @Named @@ -27,16 +25,6 @@ public void validate(SupplementaryDataUpdateRequest supplementaryDataUpdateReque validateRequestOperations(supplementaryDataUpdateRequest); } - public void validate(SupplementaryDataCasesUpdateRequest caseSupplementaryDataUpdateRequest) { - if (caseSupplementaryDataUpdateRequest == null - || caseSupplementaryDataUpdateRequest.getCaseIds() == null - || caseSupplementaryDataUpdateRequest.getRequestData() != null - || caseSupplementaryDataUpdateRequest.getRequestData().isEmpty() - || caseSupplementaryDataUpdateRequest.getCaseIds().isEmpty()) { - throw new BadRequestException(SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID); - } - } - private void validateAtMostOneLevelOfNesting(SupplementaryDataUpdateRequest supplementaryDataUpdateRequest) { for (String name : supplementaryDataUpdateRequest.getPropertiesNames()) { String[] keys = name.split(Pattern.quote(".")); diff --git a/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java b/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java index 2a613018f0..ca27084ea1 100644 --- a/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java +++ b/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java @@ -65,6 +65,7 @@ import static uk.gov.hmcts.ccd.auditlog.AuditOperationType.UPDATE_CASE; import static uk.gov.hmcts.ccd.auditlog.aop.AuditContext.CASE_ID_SEPARATOR; import static uk.gov.hmcts.ccd.auditlog.aop.AuditContext.MAX_CASE_IDS_LIST; +import static uk.gov.hmcts.ccd.v2.V2.Error.SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID; @RestController @RequestMapping(path = "/") @@ -515,31 +516,39 @@ public ResponseEntity updateCasesSupplementaryDa throw new BadRequestException(V2.Error.SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID); } - List caseIds = supplementaryDataCasesUpdateRequest.getCaseIds(); List failures = new ArrayList<>(); List successes = new ArrayList<>(); + validate(supplementaryDataCasesUpdateRequest); + List caseIds = supplementaryDataCasesUpdateRequest.getCaseIds(); SupplementaryDataUpdateRequest supplementaryDataUpdateRequest = new SupplementaryDataUpdateRequest(supplementaryDataCasesUpdateRequest.getRequestData()); + this.requestValidator.validate(supplementaryDataUpdateRequest); + for (String caseId : caseIds) { - this.requestValidator.validate(supplementaryDataUpdateRequest); + if (!caseReferenceService.validateUID(caseId)) { - throw new BadRequestException(V2.Error.CASE_ID_INVALID); - } - SupplementaryData supplementaryDataUpdated = supplementaryDataUpdateOperation - .updateSupplementaryData(caseId, - supplementaryDataUpdateRequest); - if (supplementaryDataUpdated == null) { + SupplementaryCaseFailDataResource supplementaryCaseFailDataResource = new SupplementaryCaseFailDataResource( - caseId, V2.Error.CASE_NOT_FOUND); + caseId, V2.Error.CASE_ID_INVALID); failures.add(supplementaryCaseFailDataResource); } else { - SupplementaryCaseSuccessDataResource supplementaryCaseSuccessDataResource - = new SupplementaryCaseSuccessDataResource( - caseId, supplementaryDataUpdated); - successes.add(supplementaryCaseSuccessDataResource); + SupplementaryData supplementaryDataUpdated = supplementaryDataUpdateOperation + .updateSupplementaryData(caseId, + supplementaryDataUpdateRequest); + if (supplementaryDataUpdated == null) { + SupplementaryCaseFailDataResource supplementaryCaseFailDataResource + = new SupplementaryCaseFailDataResource( + caseId, V2.Error.CASE_NOT_FOUND); + failures.add(supplementaryCaseFailDataResource); + } else { + SupplementaryCaseSuccessDataResource supplementaryCaseSuccessDataResource + = new SupplementaryCaseSuccessDataResource( + caseId, supplementaryDataUpdated); + successes.add(supplementaryCaseSuccessDataResource); + } } } return status(HttpStatus.OK).body(new SupplementaryCasesDataResource(successes, failures)); @@ -640,4 +649,15 @@ public static String buildCaseIds(String caseReference, GetLinkedCasesResponse g } return String.join(CASE_ID_SEPARATOR, caseReferences); } + + public void validate(SupplementaryDataCasesUpdateRequest caseSupplementaryDataCasesUpdateRequest) { + if (caseSupplementaryDataCasesUpdateRequest == null + || caseSupplementaryDataCasesUpdateRequest.getCaseIds() == null + || caseSupplementaryDataCasesUpdateRequest.getCaseIds().isEmpty() + || caseSupplementaryDataCasesUpdateRequest.getRequestData() == null + || caseSupplementaryDataCasesUpdateRequest.getRequestData().isEmpty()) { + throw new BadRequestException(SUPPLEMENTARY_DATA_CASES_UPDATE_INVALID); + } + } + } diff --git a/src/test/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidatorTest.java b/src/test/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidatorTest.java index b7d16698fa..18e596e2fe 100644 --- a/src/test/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidatorTest.java +++ b/src/test/java/uk/gov/hmcts/ccd/domain/model/std/validator/SupplementaryDataUpdateRequestValidatorTest.java @@ -4,7 +4,6 @@ import java.util.Map; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataCasesUpdateRequest; import uk.gov.hmcts.ccd.domain.model.std.SupplementaryDataUpdateRequest; import uk.gov.hmcts.ccd.endpoint.exceptions.BadRequestException; @@ -33,7 +32,7 @@ void invalidSupplementaryDataUpdateRequest() { @DisplayName("should propagate BadRequestException when Case supplementary data null") void shouldThrowBadRequestExceptionWhenSupplementaryDataNull() { assertThrows(BadRequestException.class, - () -> requestValidator.validate((SupplementaryDataCasesUpdateRequest) null)); + () -> requestValidator.validate((SupplementaryDataUpdateRequest) null)); } @Test diff --git a/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java b/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java index 7c29d86e5b..6e47a1f7af 100644 --- a/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java +++ b/src/test/java/uk/gov/hmcts/ccd/v2/external/controller/CaseControllerTest.java @@ -87,6 +87,8 @@ class CaseControllerTest { private static final Boolean IGNORE_WARNING = true; private static final CaseDataContent CASE_DATA_CONTENT = newCaseDataContent().build(); + private static final String INVALID_CASE_REFERENCE = "1234123412341234"; + private static final Logger LOG = LoggerFactory.getLogger(CaseControllerTest.class); @Mock @@ -657,6 +659,31 @@ void shouldUpdateSupplementaryData() { validateResponseData(response.getBody().getSuccesses(), "organisationA", FALSE); } + @Test + @DisplayName("should return 200 when supplementary data updated with failures") + void shouldUpdateSupplementaryDataWithFails() { + when(caseReferenceService.validateUID(CASE_REFERENCE)).thenReturn(TRUE); + SupplementaryCasesDataResource supplementaryCasesDataResource = createResponseDataWithCases(); + when(supplementaryDataUpdateOperation.updateSupplementaryData(anyString(), anyObject())) + .thenReturn(new SupplementaryData(new HashMap<>())); + Map data = supplementaryCasesDataResource.getSuccesses().getFirst().getResponse(); + + SupplementaryData supplementaryData = new SupplementaryData(data); + when(supplementaryDataUpdateOperation.updateSupplementaryData(anyString(), anyObject())) + .thenReturn(supplementaryData); + + final ResponseEntity response = + caseController.updateCasesSupplementaryData(createCaseRequestDataOrgAWithCasesFail()); + + assertAll( + () -> assertThat(response.getStatusCode(), is(HttpStatus.OK)), + () -> assertThat(response.getBody().getFailures().size(), equalTo(1)), + () -> assertThat(response.getBody().getSuccesses().size(), equalTo(1)), + () -> assertThat(response.getBody().getSuccesses().getFirst().getResponse(), is(data)) + ); + validateResponseData(response.getBody().getSuccesses(), "organisationA", FALSE); + } + @Test @DisplayName("should propagate BadRequestException when supplementary data not valid") void invalidSupplementaryDataUpdateRequest() { @@ -746,6 +773,21 @@ private SupplementaryDataCasesUpdateRequest createCaseRequestDataOrgAWithCases() return convertData(jsonRequest); } + private SupplementaryDataCasesUpdateRequest createCaseRequestDataOrgAWithCasesFail() { + String jsonRequest = "{\n" + + "\t\"cases\": [\n" + + "\t\t\"" + CASE_REFERENCE + "\",\n" + + "\t\t\"" + INVALID_CASE_REFERENCE + "\"\n" + + "\t],\n" + + "\"supplementary_data_updates\": {\n" + + "\t\"$set\": {\n" + + "\t\t\"new_case.organisationA\": false\n" + + "\t}\n" + + "\t}\n" + + "}"; + return convertData(jsonRequest); + } + private SupplementaryDataCasesUpdateRequest createRequestDataNestedWithCases() { String jsonRequest = "{\n" + "\t\"cases\": [\n" From c1fcc5323ae430ea0f30d2e87df4f49380700212 Mon Sep 17 00:00:00 2001 From: patelila Date: Tue, 18 Mar 2025 16:18:19 +0000 Subject: [PATCH 14/14] added FT test for testing failures --- .../F-144.feature | 12 ++++ .../F-144_Case_Data_Create_C3.td.json | 12 ++++ ...Case_Data_Create_C3_Token_Creation.td.json | 4 ++ .../S-144.4.td.json | 56 +++++++++++++++++++ .../external/controller/CaseController.java | 27 +++++---- 5 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C3.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C3_Token_Creation.td.json create mode 100644 src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature index 8ce5a0de61..3432ecdfe9 100644 --- a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144.feature @@ -37,3 +37,15 @@ Feature: F-144: Update Cases Supplementary Data Then a positive response is received, And the response has all the details as expected. + @S-144.4 + Scenario: Need to be able to update an existing property for multiple cases with a failure + Given an appropriate test context as detailed in the test data source, + And a user [Dil - who can create a case], + And a case [C1, which has just been] created as in [F-144_Case_Data_Create_C1], + And a case [C3, which has just been] created as in [F-144_Case_Data_Create_C3], + When a request is prepared with appropriate values, + And the request [contains updates of a specified value to an existing Supplementary Data property], + And it is submitted to call the [Update Cases Supplementary Data] operation of [CCD Data Store api], + Then a positive response is received, + And the response has all the details as expected. + diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C3.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C3.td.json new file mode 100644 index 0000000000..e12532ac0e --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C3.td.json @@ -0,0 +1,12 @@ +{ + "_guid_": "F-144_Case_Data_Create_C3", + "_extends_": "F-144_Case_Data_Create", + "specs": [ + "C3, which has just been" + ], + "request": { + "body": { + "event_token": "${[scenarioContext][siblingContexts][F-144_Case_Data_Create_C3_Token_Creation][testData][actualResponse][body][token]}" + } + } +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C3_Token_Creation.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C3_Token_Creation.td.json new file mode 100644 index 0000000000..3de9963007 --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/F-144_Case_Data_Create_C3_Token_Creation.td.json @@ -0,0 +1,4 @@ +{ + "_guid_": "F-144_Case_Data_Create_C3_Token_Creation", + "_extends_": "S-144_GetCreateToken" +} diff --git a/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json new file mode 100644 index 0000000000..7274b83e7e --- /dev/null +++ b/src/aat/resources/features/F-144 - Update Cases Supplementary Data/S-144.4.td.json @@ -0,0 +1,56 @@ +{ + "title": "Need to be able to update an existing property for multiple cases", + "_guid_": "S-144.4", + "productName": "CCD Data Store api", + "operationName": "Update Cases Supplementary Data", + "_extends_": "F-144_Update_Cases_Supplementary_Data_Base", + "specs": [ + "Dil - who can create a case", + "contains updates of a specified value to an existing Supplementary Data property" + ], + "request": { + "body": { + "cases": [ + "${[scenarioContext][childContexts][F-144_Case_Data_Create_C1][testData][actualResponse][body][id]}", + "${[scenarioContext][childContexts][F-144_Case_Data_Create_C3][testData][actualResponse][body][id]}", + "0000000000000000" + ], + "supplementary_data_updates": { + "$set": { + "new_case.orgID1": false, + "new_case.orgID3": false + } + } + } + }, + "expectedResponse": { + "_extends_": "Common_200_Response", + "headers": { + "Content-Length": "[[ANYTHING_PRESENT]]", + "Content-Type": "[[ANYTHING_PRESENT]]", + "Content-Encoding": "gzip" + }, + "body": { + "successes" : [ + { + "caseId": "${[scenarioContext][customValues][caseIdAsStringFrom_F-144_Case_Data_Create_C1]}", + "supplementary_data": { + "new_case.orgID1": false, + "new_case.orgID3": false + } + }, + { + "caseId": "${[scenarioContext][customValues][caseIdAsStringFrom_F-144_Case_Data_Create_C3]}", + "supplementary_data": { + "new_case.orgID1": false, + "new_case.orgID3": false + } + } + ], + "failures" : [ { + "caseId" : "0000000000000000", + "failure_reason" : "No case found for reference: Case not found" + } ] + } + } +} diff --git a/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java b/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java index ca27084ea1..a63bd78c7d 100644 --- a/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java +++ b/src/main/java/uk/gov/hmcts/ccd/v2/external/controller/CaseController.java @@ -535,19 +535,26 @@ public ResponseEntity updateCasesSupplementaryDa caseId, V2.Error.CASE_ID_INVALID); failures.add(supplementaryCaseFailDataResource); } else { - SupplementaryData supplementaryDataUpdated = supplementaryDataUpdateOperation - .updateSupplementaryData(caseId, - supplementaryDataUpdateRequest); - if (supplementaryDataUpdated == null) { + try { + SupplementaryData supplementaryDataUpdated = supplementaryDataUpdateOperation + .updateSupplementaryData(caseId, + supplementaryDataUpdateRequest); + if (supplementaryDataUpdated == null) { + SupplementaryCaseFailDataResource supplementaryCaseFailDataResource + = new SupplementaryCaseFailDataResource( + caseId, V2.Error.CASE_NOT_FOUND); + failures.add(supplementaryCaseFailDataResource); + } else { + SupplementaryCaseSuccessDataResource supplementaryCaseSuccessDataResource + = new SupplementaryCaseSuccessDataResource( + caseId, supplementaryDataUpdated); + successes.add(supplementaryCaseSuccessDataResource); + } + } catch (Exception e) { SupplementaryCaseFailDataResource supplementaryCaseFailDataResource = new SupplementaryCaseFailDataResource( - caseId, V2.Error.CASE_NOT_FOUND); + caseId, e.getMessage()); failures.add(supplementaryCaseFailDataResource); - } else { - SupplementaryCaseSuccessDataResource supplementaryCaseSuccessDataResource - = new SupplementaryCaseSuccessDataResource( - caseId, supplementaryDataUpdated); - successes.add(supplementaryCaseSuccessDataResource); } } }