Skip to content

Commit 8d5900c

Browse files
authored
CDPS-975: Allowing birth place to be set to null (#10)
1 parent d675191 commit 8d5900c

File tree

4 files changed

+54
-36
lines changed

4 files changed

+54
-36
lines changed

.github/workflows/pipeline.yml

+21-20
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,24 @@ jobs:
8787
environment: 'development'
8888
app_version: '${{ needs.build.outputs.app_version }}'
8989

90-
# deploy_preprod:
91-
# name: Deploy to pre-production environment
92-
# needs:
93-
# - build
94-
# - deploy_dev
95-
# uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
96-
# secrets: inherit
97-
# with:
98-
# environment: 'preprod'
99-
# app_version: '${{ needs.build.outputs.app_version }}'
100-
# deploy_prod:
101-
# name: Deploy to production environment
102-
# needs:
103-
# - build
104-
# - deploy_preprod
105-
# uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
106-
# secrets: inherit
107-
# with:
108-
# environment: 'prod'
109-
# app_version: '${{ needs.build.outputs.app_version }}'
90+
deploy_preprod:
91+
name: Deploy to pre-production environment
92+
needs:
93+
- build
94+
- deploy_dev
95+
uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
96+
secrets: inherit
97+
with:
98+
environment: 'preprod'
99+
app_version: '${{ needs.build.outputs.app_version }}'
100+
101+
deploy_prod:
102+
name: Deploy to production environment
103+
needs:
104+
- build
105+
- deploy_preprod
106+
uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
107+
secrets: inherit
108+
with:
109+
environment: 'prod'
110+
app_version: '${{ needs.build.outputs.app_version }}'

src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/common/client/dto/UpdateBirthPlace.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema
44

55
@Schema(description = "Update to prisoner birth place (city or town of birth)")
66
data class UpdateBirthPlace(
7-
@Schema(description = "Birth place (city or town of birth)", example = "SHEFFIELD")
8-
val birthPlace: String,
7+
@Schema(description = "Birth place (city or town of birth)", example = "SHEFFIELD", required = true, nullable = true)
8+
val birthPlace: String?,
99
)

src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/dto/request/CorePersonRecordV1UpdateRequestDto.kt

+7-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package uk.gov.justice.digital.hmpps.personintegrationapi.corepersonrecord.dto.v
33
import com.fasterxml.jackson.annotation.JsonSubTypes
44
import com.fasterxml.jackson.annotation.JsonTypeInfo
55
import io.swagger.v3.oas.annotations.media.Schema
6-
import jakarta.validation.constraints.NotNull
76
import org.springframework.format.annotation.DateTimeFormat
87
import java.time.LocalDate
98

@@ -33,13 +32,12 @@ sealed class CorePersonRecordV1UpdateRequestDto {
3332
@Schema(description = "Core Person Record V1 birthplace update request")
3433
data class BirthplaceUpdateDto(
3534
@Schema(
36-
description = "The new value for the Birthplace",
35+
description = "The new value for the birthplace",
3736
example = "London",
3837
required = true,
39-
nullable = false,
38+
nullable = true,
4039
)
41-
@field:NotNull()
42-
override val value: String,
40+
override val value: String?,
4341
) : CorePersonRecordV1UpdateRequestDto() {
4442
@Schema(
4543
type = "String",
@@ -57,11 +55,10 @@ data class DateOfBirthUpdateDto(
5755
description = "The new value for the date of birth field",
5856
example = "01/01/2000",
5957
required = true,
60-
nullable = false,
58+
nullable = true,
6159
)
62-
@field:NotNull()
6360
@field:DateTimeFormat(pattern = "dd/mm/yyyy")
64-
override val value: LocalDate,
61+
override val value: LocalDate?,
6562
) : CorePersonRecordV1UpdateRequestDto() {
6663
@Schema(
6764
type = "String",
@@ -79,10 +76,9 @@ data class CountryOfBirthUpdateDto(
7976
description = "The new value for the country of brith field",
8077
example = "UK",
8178
required = true,
82-
nullable = false,
79+
nullable = true,
8380
)
84-
@field:NotNull()
85-
override val value: String,
81+
override val value: String?,
8682
) : CorePersonRecordV1UpdateRequestDto() {
8783
@Schema(
8884
type = "String",

src/test/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/resource/CorePersonRecordV1ResourceIntTest.kt

+24-3
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,21 @@ class CorePersonRecordV1ResourceIntTest : IntegrationTestBase() {
5050
inner class HappyPath {
5151

5252
@Test
53-
fun `can patch core person record by prisoner number`() {
53+
fun `can patch core person record birthplace by prisoner number`() {
5454
webTestClient.patch().uri("/v1/core-person-record?prisonerNumber=$PRISONER_NUMBER")
5555
.contentType(MediaType.APPLICATION_JSON)
5656
.headers(setAuthorisation(roles = listOf(CorePersonRecordRoleConstants.CORE_PERSON_RECORD_READ_WRITE_ROLE)))
57-
.bodyValue(VALID_PATCH_REQUEST_BODY)
57+
.bodyValue(BIRTHPLACE_PATCH_REQUEST_BODY)
58+
.exchange()
59+
.expectStatus().isNoContent
60+
}
61+
62+
@Test
63+
fun `patch core person record birthplace accepts null value`() {
64+
webTestClient.patch().uri("/v1/core-person-record?prisonerNumber=$PRISONER_NUMBER")
65+
.contentType(MediaType.APPLICATION_JSON)
66+
.headers(setAuthorisation(roles = listOf(CorePersonRecordRoleConstants.CORE_PERSON_RECORD_READ_WRITE_ROLE)))
67+
.bodyValue(NULL_BIRTHPLACE_PATCH_REQUEST_BODY)
5868
.exchange()
5969
.expectStatus().isNoContent
6070
}
@@ -163,7 +173,7 @@ class CorePersonRecordV1ResourceIntTest : IntegrationTestBase() {
163173

164174
private companion object {
165175

166-
val VALID_PATCH_REQUEST_BODY =
176+
val BIRTHPLACE_PATCH_REQUEST_BODY =
167177
// language=json
168178
"""
169179
{
@@ -172,6 +182,17 @@ class CorePersonRecordV1ResourceIntTest : IntegrationTestBase() {
172182
}
173183
""".trimIndent()
174184

185+
val NULL_BIRTHPLACE_PATCH_REQUEST_BODY =
186+
// language=json
187+
"""
188+
{
189+
"fieldName": "BIRTHPLACE",
190+
"value": null
191+
}
192+
""".trimIndent()
193+
194+
val VALID_PATCH_REQUEST_BODY = BIRTHPLACE_PATCH_REQUEST_BODY
195+
175196
val MULTIPART_FILE: MultipartFile = MockMultipartFile(
176197
"file",
177198
"filename.jpg",

0 commit comments

Comments
 (0)