Skip to content

Commit 3c382b7

Browse files
authored
Upgraded hmpps gradle springboot from 5.1.0 to 5.1.2 (#90)
* Upgraded hmpps gradle springboot from 5.1.0 to 5.1.2 * Linting now adds trailing commas as recommended practice
1 parent b9f8d43 commit 3c382b7

File tree

52 files changed

+195
-185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+195
-185
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id("uk.gov.justice.hmpps.gradle-spring-boot") version "5.1.0"
2+
id("uk.gov.justice.hmpps.gradle-spring-boot") version "5.1.2"
33
kotlin("plugin.spring") version "1.8.0"
44
}
55

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/config/HmppsIntegrationApiExceptionHandler.kt

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class HmppsIntegrationApiExceptionHandler {
2323
ErrorResponse(
2424
status = BAD_REQUEST,
2525
userMessage = "Validation failure: ${e.message}",
26-
developerMessage = e.message
27-
)
26+
developerMessage = e.message,
27+
),
2828
)
2929
}
3030

@@ -37,8 +37,8 @@ class HmppsIntegrationApiExceptionHandler {
3737
ErrorResponse(
3838
status = NOT_FOUND,
3939
userMessage = "404 Not found error: ${e.message}",
40-
developerMessage = e.message
41-
)
40+
developerMessage = e.message,
41+
),
4242
)
4343
}
4444

@@ -51,8 +51,8 @@ class HmppsIntegrationApiExceptionHandler {
5151
ErrorResponse(
5252
status = INTERNAL_SERVER_ERROR,
5353
userMessage = "Authentication error: ${e.message}",
54-
developerMessage = e.message
55-
)
54+
developerMessage = e.message,
55+
),
5656
)
5757
}
5858

@@ -65,8 +65,8 @@ class HmppsIntegrationApiExceptionHandler {
6565
ErrorResponse(
6666
status = INTERNAL_SERVER_ERROR,
6767
userMessage = "Unexpected error: ${e.message}",
68-
developerMessage = e.message
69-
)
68+
developerMessage = e.message,
69+
),
7070
)
7171
}
7272

@@ -80,14 +80,14 @@ data class ErrorResponse(
8080
val errorCode: Int? = null,
8181
val userMessage: String? = null,
8282
val developerMessage: String? = null,
83-
val moreInfo: String? = null
83+
val moreInfo: String? = null,
8484
) {
8585
constructor(
8686
status: HttpStatus,
8787
errorCode: Int? = null,
8888
userMessage: String? = null,
8989
developerMessage: String? = null,
90-
moreInfo: String? = null
90+
moreInfo: String? = null,
9191
) :
9292
this(status.value(), errorCode, userMessage, developerMessage, moreInfo)
9393
}

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/config/RequestLogger.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ class RequestLogger() : HandlerInterceptor {
1414

1515
override fun preHandle(request: HttpServletRequest, response: HttpServletResponse, handler: Any): Boolean {
1616
// log. allows us ot log at different levels
17-
if (log.isDebugEnabled)
17+
if (log.isDebugEnabled) {
1818
log.debug(RetrieveRequestData(request))
19+
}
1920

2021
// Informs the super to continue processing this request
2122
return true

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/config/TomcatConfig.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TomcatConfig {
1616
factory.addConnectorCustomizers(
1717
TomcatConnectorCustomizer { connector: Connector ->
1818
connector.encodedSolidusHandling = EncodedSolidusHandling.PASS_THROUGH.value
19-
}
19+
},
2020
)
2121
}
2222
}

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/ImageController.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetImageService
1111
@RestController
1212
@RequestMapping("/images")
1313
class ImageController(
14-
@Autowired val getImageService: GetImageService
14+
@Autowired val getImageService: GetImageService,
1515
) {
1616
@GetMapping("{id}")
1717
fun getImage(@PathVariable id: Int): ResponseEntity<ByteArray> {

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/PersonController.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class PersonController(
2424
@Autowired val getPersonService: GetPersonService,
2525
@Autowired val getPersonsService: GetPersonsService,
2626
@Autowired val getImageMetadataForPersonService: GetImageMetadataForPersonService,
27-
@Autowired val getAddressesForPersonService: GetAddressesForPersonService
27+
@Autowired val getAddressesForPersonService: GetAddressesForPersonService,
2828
) {
2929

3030
@GetMapping
3131
fun getPersons(
3232
@RequestParam(required = false, name = "first_name") firstName: String?,
33-
@RequestParam(required = false, name = "last_name") lastName: String?
33+
@RequestParam(required = false, name = "last_name") lastName: String?,
3434
): Map<String, List<Person?>> {
3535
if (firstName == null && lastName == null) {
3636
throw ValidationException("No query parameters specified.")

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/extensions/WebClientWrapper.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.springframework.web.reactive.function.BodyInserters
55
import org.springframework.web.reactive.function.client.WebClient
66

77
class WebClientWrapper(
8-
val baseUrl: String
8+
val baseUrl: String,
99
) {
1010
val client: WebClient = WebClient
1111
.builder()
@@ -17,8 +17,9 @@ class WebClientWrapper(
1717
.uri(uri)
1818
.header("Authorization", "Bearer $token")
1919

20-
if (method == HttpMethod.POST && requestBody != null)
20+
if (method == HttpMethod.POST && requestBody != null) {
2121
responseBodySpec.body(BodyInserters.fromValue(requestBody))
22+
}
2223

2324
return responseBodySpec.retrieve()
2425
.bodyToMono(T::class.java)
@@ -30,8 +31,9 @@ class WebClientWrapper(
3031
.uri(uri)
3132
.header("Authorization", "Bearer $token")
3233

33-
if (method == HttpMethod.POST && requestBody != null)
34+
if (method == HttpMethod.POST && requestBody != null) {
3435
responseBodySpec.body(BodyInserters.fromValue(requestBody))
36+
}
3537

3638
return responseBodySpec.retrieve()
3739
.bodyToFlux(T::class.java)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/ProbationOffenderSearchGateway.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ProbationOffenderSearchGateway(@Value("\${services.probation-offender-sear
2929
HttpMethod.POST,
3030
"/search",
3131
token,
32-
mapOf("pncNumber" to pncId, "valid" to true)
32+
mapOf("pncNumber" to pncId, "valid" to true),
3333
)
3434

3535
if (offenders.isNotEmpty()) offenders.first().toPerson() else null
@@ -58,9 +58,10 @@ class ProbationOffenderSearchGateway(@Value("\${services.probation-offender-sear
5858

5959
if (offender.isEmpty()) return null
6060

61-
return if (offender.first().contactDetails.addresses.isNotEmpty())
61+
return if (offender.first().contactDetails.addresses.isNotEmpty()) {
6262
offender.first().contactDetails.addresses.map { it.toAddress() }
63-
else
63+
} else {
6464
listOf()
65+
}
6566
}
6667
}

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/health/ExternalHealthIndicator.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ open class ExternalHealthIndicator(url: String) : HealthIndicator {
3434
.build()
3535
}
3636

37-
if (response.statusCode() != 200)
37+
if (response.statusCode() != 200) {
3838
return healthStatus.up()
3939
.withDetail("httpStatusCode", response.statusCode())
4040
.build()
41+
}
4142

4243
return healthStatus.build()
4344
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models
22

33
data class Address(
4-
val postcode: String?
4+
val postcode: String?,
55
)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/Alias.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ data class Alias(
1010
@JsonAlias("middleNames")
1111
val middleName: String? = null,
1212
@JsonAlias("dob")
13-
var dateOfBirth: LocalDate? = null
13+
var dateOfBirth: LocalDate? = null,
1414
)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/ImageMetadata.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ data class ImageMetadata(
77
val captureDate: LocalDate,
88
val view: String,
99
val orientation: String,
10-
val type: String
10+
val type: String,
1111
)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/Person.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ data class Person(
1212
val dateOfBirth: LocalDate? = null,
1313
@JsonAlias("offenderAliases")
1414
val aliases: List<Alias> = listOf(),
15-
val prisonerId: String? = null
15+
val prisonerId: String? = null,
1616
)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/nomis/Address.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.nomis
33
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.Address as IntegrationAPIAddress
44

55
data class Address(
6-
val postalCode: String
6+
val postalCode: String,
77
) {
88
fun toAddress() = IntegrationAPIAddress(postcode = this.postalCode)
99
}

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/nomis/Alias.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ data class Alias(
66
val firstName: String,
77
val lastName: String,
88
val middleName: String? = null,
9-
var dob: LocalDate? = null
9+
var dob: LocalDate? = null,
1010
)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/nomis/ImageDetail.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ class ImageDetail(
88
val captureDate: LocalDate,
99
val imageView: String,
1010
val imageOrientation: String,
11-
val imageType: String
11+
val imageType: String,
1212
) {
1313
fun toImageMetadata(): ImageMetadata = ImageMetadata(
1414
id = this.imageId,
1515
captureDate = this.captureDate,
1616
view = this.imageView,
1717
orientation = this.imageOrientation,
18-
type = this.imageType
18+
type = this.imageType,
1919
)
2020
}

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/nomis/Offender.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data class Offender(
1010
val lastName: String,
1111
val middleName: String? = null,
1212
val dateOfBirth: LocalDate? = null,
13-
val aliases: List<nomisAlias> = listOf()
13+
val aliases: List<nomisAlias> = listOf(),
1414
) {
1515
fun toPerson(): Person = Person(
1616
firstName = this.firstName,
@@ -22,8 +22,8 @@ data class Offender(
2222
it.firstName,
2323
it.lastName,
2424
it.middleName,
25-
it.dob
25+
it.dob,
2626
)
27-
}
27+
},
2828
)
2929
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.prisoneroffendersearch
22

33
class GlobalSearch(
4-
val content: List<Prisoner>
4+
val content: List<Prisoner>,
55
)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/Prisoner.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data class Prisoner(
1010
val middleNames: String? = null,
1111
val dateOfBirth: LocalDate? = null,
1212
val aliases: List<PrisonerAlias> = listOf(),
13-
val prisonerNumber: String? = null
13+
val prisonerNumber: String? = null,
1414
) {
1515
fun toPerson(): Person = Person(
1616
firstName = this.firstName,
@@ -22,9 +22,9 @@ data class Prisoner(
2222
it.firstName,
2323
it.lastName,
2424
it.middleNames,
25-
it.dateOfBirth
25+
it.dateOfBirth,
2626
)
2727
},
28-
prisonerId = this.prisonerNumber
28+
prisonerId = this.prisonerNumber,
2929
)
3030
}

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/prisoneroffendersearch/PrisonerAlias.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ data class PrisonerAlias(
66
val firstName: String,
77
val lastName: String,
88
val middleNames: String? = null,
9-
var dateOfBirth: LocalDate? = null
9+
var dateOfBirth: LocalDate? = null,
1010
)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/Address.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.probationoffende
33
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.Address as IntegrationAPIAddress
44

55
data class Address(
6-
val postcode: String?
6+
val postcode: String?,
77
) {
88
fun toAddress() = IntegrationAPIAddress(postcode = this.postcode)
99
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.probationoffendersearch
22

33
data class ContactDetails(
4-
val addresses: List<Address> = listOf()
4+
val addresses: List<Address> = listOf(),
55
)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/Offender.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data class Offender(
1010
val middleNames: List<String> = listOf(),
1111
val dateOfBirth: LocalDate? = null,
1212
val offenderAliases: List<OffenderAlias> = listOf(),
13-
val contactDetails: ContactDetails = ContactDetails()
13+
val contactDetails: ContactDetails = ContactDetails(),
1414
) {
1515
fun toPerson(): Person = Person(
1616
firstName = this.firstName,
@@ -22,8 +22,8 @@ data class Offender(
2222
it.firstName,
2323
it.surname,
2424
it.middleNames.joinToString(" "),
25-
it.dateOfBirth
25+
it.dateOfBirth,
2626
)
27-
}
27+
},
2828
)
2929
}

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/probationoffendersearch/OffenderAlias.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ data class OffenderAlias(
66
val firstName: String,
77
val surname: String,
88
val middleNames: List<String> = listOf(),
9-
var dateOfBirth: LocalDate? = null
9+
var dateOfBirth: LocalDate? = null,
1010
)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetAddressesForPersonService.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.Address
1111
class GetAddressesForPersonService(
1212
@Autowired val probationOffenderSearchGateway: ProbationOffenderSearchGateway,
1313
@Autowired val prisonerOffenderSearchGateway: PrisonerOffenderSearchGateway,
14-
@Autowired val nomisGateway: NomisGateway
14+
@Autowired val nomisGateway: NomisGateway,
1515
) {
1616
fun execute(pncId: String): List<Address>? {
1717
val personFromPrisonerOffenderSearch = prisonerOffenderSearchGateway.getPersons(pncId = pncId)
1818

1919
val addressesFromNomis = nomisGateway.getAddressesForPerson(personFromPrisonerOffenderSearch.first().prisonerId!!)
2020
val addressesFromProbationOffenderSearch = probationOffenderSearchGateway.getAddressesForPerson(pncId)
2121

22-
if (addressesFromNomis == null && addressesFromProbationOffenderSearch == null)
22+
if (addressesFromNomis == null && addressesFromProbationOffenderSearch == null) {
2323
return null
24+
}
2425

2526
return addressesFromProbationOffenderSearch?.plus(addressesFromNomis.orEmpty())
2627
}

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetImageMetadataForPersonService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.ImageMetadata
99
@Service
1010
class GetImageMetadataForPersonService(
1111
@Autowired val nomisGateway: NomisGateway,
12-
@Autowired val prisonerOffenderSearchGateway: PrisonerOffenderSearchGateway
12+
@Autowired val prisonerOffenderSearchGateway: PrisonerOffenderSearchGateway,
1313
) {
1414
fun execute(pncId: String): List<ImageMetadata> {
1515
val personFromPrisonerOffenderSearch = prisonerOffenderSearchGateway.getPersons(pncId = pncId)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetPersonService.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.Person
99
@Service
1010
class GetPersonService(
1111
@Autowired val prisonerOffenderSearchGateway: PrisonerOffenderSearchGateway,
12-
@Autowired val probationOffenderSearchGateway: ProbationOffenderSearchGateway
12+
@Autowired val probationOffenderSearchGateway: ProbationOffenderSearchGateway,
1313
) {
1414
fun execute(pncId: String): Map<String, Person?>? {
1515
val personFromPrisonerOffenderSearch = prisonerOffenderSearchGateway.getPersons(pncId = pncId)
@@ -21,7 +21,7 @@ class GetPersonService(
2121

2222
return mapOf(
2323
"prisonerOffenderSearch" to personFromPrisonerOffenderSearch.first(),
24-
"probationOffenderSearch" to personFromProbationOffenderSearch
24+
"probationOffenderSearch" to personFromProbationOffenderSearch,
2525
)
2626
}
2727
}

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetPersonsService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.Person
99
@Service
1010
class GetPersonsService(
1111
@Autowired val prisonerOffenderSearchGateway: PrisonerOffenderSearchGateway,
12-
@Autowired val probationOffenderSearchGateway: ProbationOffenderSearchGateway
12+
@Autowired val probationOffenderSearchGateway: ProbationOffenderSearchGateway,
1313
) {
1414

1515
fun execute(firstName: String?, lastName: String?): List<Person?> {

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/ImageControllerTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ internal class ImageControllerTest(
4646
result.response.contentAsByteArray.shouldBe(image)
4747
}
4848
}
49-
})
49+
},)

0 commit comments

Comments
 (0)