Skip to content

Commit

Permalink
CDPS-975: Allowing birth place to be set to null
Browse files Browse the repository at this point in the history
  • Loading branch information
brightonsbox committed Dec 6, 2024
1 parent d675191 commit 772f8cf
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 35 deletions.
41 changes: 21 additions & 20 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
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 }}'
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -163,7 +173,7 @@ class CorePersonRecordV1ResourceIntTest : IntegrationTestBase() {

private companion object {

val VALID_PATCH_REQUEST_BODY =
val BIRTHPLACE_PATCH_REQUEST_BODY =
// language=json
"""
{
Expand All @@ -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",
Expand Down

0 comments on commit 772f8cf

Please sign in to comment.