From 772f8cf0bb116bd33175fb21ff153df461b1832d Mon Sep 17 00:00:00 2001 From: Jon Brighton Date: Fri, 6 Dec 2024 13:12:54 +0000 Subject: [PATCH] CDPS-975: Allowing birth place to be set to null --- .github/workflows/pipeline.yml | 41 ++++++++++--------- .../common/client/dto/UpdateBirthPlace.kt | 4 +- .../CorePersonRecordV1UpdateRequestDto.kt | 17 ++++---- .../CorePersonRecordV1ResourceIntTest.kt | 27 ++++++++++-- 4 files changed, 54 insertions(+), 35 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index dea89eb..5805999 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -87,23 +87,24 @@ jobs: environment: 'development' app_version: '${{ needs.build.outputs.app_version }}' - # deploy_preprod: - # name: Deploy to pre-production environment - # needs: - # - build - # - deploy_dev - # uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION - # secrets: inherit - # with: - # environment: 'preprod' - # app_version: '${{ needs.build.outputs.app_version }}' - # deploy_prod: - # name: Deploy to production environment - # needs: - # - build - # - deploy_preprod - # uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION - # secrets: inherit - # with: - # environment: 'prod' - # app_version: '${{ needs.build.outputs.app_version }}' \ No newline at end of file + deploy_preprod: + name: Deploy to pre-production environment + needs: + - build + - deploy_dev + uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION + secrets: inherit + with: + environment: 'preprod' + app_version: '${{ needs.build.outputs.app_version }}' + + deploy_prod: + name: Deploy to production environment + needs: + - build + - deploy_preprod + uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION + secrets: inherit + with: + environment: 'prod' + app_version: '${{ needs.build.outputs.app_version }}' \ No newline at end of file diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/common/client/dto/UpdateBirthPlace.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/common/client/dto/UpdateBirthPlace.kt index fefc7b0..0d17796 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/common/client/dto/UpdateBirthPlace.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/common/client/dto/UpdateBirthPlace.kt @@ -4,6 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema @Schema(description = "Update to prisoner birth place (city or town of birth)") data class UpdateBirthPlace( - @Schema(description = "Birth place (city or town of birth)", example = "SHEFFIELD") - val birthPlace: String, + @Schema(description = "Birth place (city or town of birth)", example = "SHEFFIELD", required = true, nullable = true) + val birthPlace: String?, ) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/dto/request/CorePersonRecordV1UpdateRequestDto.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/dto/request/CorePersonRecordV1UpdateRequestDto.kt index 79feec5..bfda132 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/dto/request/CorePersonRecordV1UpdateRequestDto.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/dto/request/CorePersonRecordV1UpdateRequestDto.kt @@ -33,13 +33,12 @@ sealed class CorePersonRecordV1UpdateRequestDto { @Schema(description = "Core Person Record V1 birthplace update request") data class BirthplaceUpdateDto( @Schema( - description = "The new value for the Birthplace", + description = "The new value for the birthplace", example = "London", required = true, - nullable = false, + nullable = true , ) - @field:NotNull() - override val value: String, + override val value: String?, ) : CorePersonRecordV1UpdateRequestDto() { @Schema( type = "String", @@ -57,11 +56,10 @@ data class DateOfBirthUpdateDto( description = "The new value for the date of birth field", example = "01/01/2000", required = true, - nullable = false, + nullable = true, ) - @field:NotNull() @field:DateTimeFormat(pattern = "dd/mm/yyyy") - override val value: LocalDate, + override val value: LocalDate?, ) : CorePersonRecordV1UpdateRequestDto() { @Schema( type = "String", @@ -79,10 +77,9 @@ data class CountryOfBirthUpdateDto( description = "The new value for the country of brith field", example = "UK", required = true, - nullable = false, + nullable = true, ) - @field:NotNull() - override val value: String, + override val value: String?, ) : CorePersonRecordV1UpdateRequestDto() { @Schema( type = "String", diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/resource/CorePersonRecordV1ResourceIntTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/resource/CorePersonRecordV1ResourceIntTest.kt index a4be5f7..13bf570 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/resource/CorePersonRecordV1ResourceIntTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/resource/CorePersonRecordV1ResourceIntTest.kt @@ -50,11 +50,21 @@ class CorePersonRecordV1ResourceIntTest : IntegrationTestBase() { inner class HappyPath { @Test - fun `can patch core person record by prisoner number`() { + fun `can patch core person record birthplace by prisoner number`() { webTestClient.patch().uri("/v1/core-person-record?prisonerNumber=$PRISONER_NUMBER") .contentType(MediaType.APPLICATION_JSON) .headers(setAuthorisation(roles = listOf(CorePersonRecordRoleConstants.CORE_PERSON_RECORD_READ_WRITE_ROLE))) - .bodyValue(VALID_PATCH_REQUEST_BODY) + .bodyValue(BIRTHPLACE_PATCH_REQUEST_BODY) + .exchange() + .expectStatus().isNoContent + } + + @Test + fun `patch core person record birthplace accepts null value`() { + webTestClient.patch().uri("/v1/core-person-record?prisonerNumber=$PRISONER_NUMBER") + .contentType(MediaType.APPLICATION_JSON) + .headers(setAuthorisation(roles = listOf(CorePersonRecordRoleConstants.CORE_PERSON_RECORD_READ_WRITE_ROLE))) + .bodyValue(NULL_BIRTHPLACE_PATCH_REQUEST_BODY) .exchange() .expectStatus().isNoContent } @@ -163,7 +173,7 @@ class CorePersonRecordV1ResourceIntTest : IntegrationTestBase() { private companion object { - val VALID_PATCH_REQUEST_BODY = + val BIRTHPLACE_PATCH_REQUEST_BODY = // language=json """ { @@ -172,6 +182,17 @@ class CorePersonRecordV1ResourceIntTest : IntegrationTestBase() { } """.trimIndent() + val NULL_BIRTHPLACE_PATCH_REQUEST_BODY = + // language=json + """ + { + "fieldName": "BIRTHPLACE", + "value": null + } + """.trimIndent() + + val VALID_PATCH_REQUEST_BODY = BIRTHPLACE_PATCH_REQUEST_BODY + val MULTIPART_FILE: MultipartFile = MockMultipartFile( "file", "filename.jpg",