Skip to content

Commit

Permalink
Return Cas1SpaceCharacteristic in space search
Browse files Browse the repository at this point in the history
This commit changes the space search result to use the `Cas1SpaceCharacteristic` enum to provide characteristics for matching properties, allowing us to also list room-level characteristics (these will be added in a subsequent commit)
  • Loading branch information
davidatkinsuk committed Jan 2, 2025
1 parent 83cf95e commit de6172e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package uk.gov.justice.digital.hmpps.approvedpremisesapi.transformer.cas1

import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.Cas1PremiseCharacteristic
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.Cas1PremisesSearchResultSummary
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.Cas1SpaceCharacteristic
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.Cas1SpaceSearchParameters
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.Cas1SpaceSearchResults
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.NamedId
Expand Down Expand Up @@ -39,9 +39,9 @@ class Cas1SpaceSearchResultsTransformer {
premisesCharacteristics = emptyList(),
characteristics = candidatePremises.characteristics.mapNotNull {
try {
Cas1PremiseCharacteristic.valueOf(it)
Cas1SpaceCharacteristic.valueOf(it)
} catch (e: IllegalArgumentException) {
log.warn("Couldn't find an enum entry for propertyName $it")
log.warn("Couldn't find a Cas1SpaceCharacteristic enum entry for propertyName $it")
null
}
},
Expand Down
27 changes: 2 additions & 25 deletions src/main/resources/static/cas1-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ components:
$ref: '_shared.yml#/components/schemas/CharacteristicPair'
characteristics:
type: array
description: "Room and premise characteristics"
items:
$ref: '#/components/schemas/Cas1PremiseCharacteristic'
$ref: '#/components/schemas/Cas1SpaceCharacteristic'
required:
- id
- apType
Expand Down Expand Up @@ -140,30 +141,6 @@ components:
required:
- startInclusive
- endInclusive
Cas1PremiseCharacteristic:
type: string
description: All premise characteristics
enum:
- acceptsChildSexOffenders
- acceptsHateCrimeOffenders
- acceptsNonSexualChildOffenders
- acceptsSexOffenders
- additionalRestrictions
- hasBrailleSignage
- hasHearingLoop
- hasLift
- hasStepFreeAccessToCommunalAreas
- hasTactileFlooring
- hasWheelChairAccessibleBathrooms
- hasWideAccessToCommunalAreas
- hasWideStepFreeAccess
- isCatered
- isESAP
- isIAP
- isPIPE
- isRecoveryFocussed
- isSuitableForVulnerable
- isSemiSpecialistMentalHealth
Cas1SpaceCharacteristic:
type: string
description: All of the characteristics of both premises and rooms
Expand Down
27 changes: 2 additions & 25 deletions src/main/resources/static/codegen/built-cas1-api-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6117,8 +6117,9 @@ components:
$ref: '#/components/schemas/CharacteristicPair'
characteristics:
type: array
description: "Room and premise characteristics"
items:
$ref: '#/components/schemas/Cas1PremiseCharacteristic'
$ref: '#/components/schemas/Cas1SpaceCharacteristic'
required:
- id
- apType
Expand Down Expand Up @@ -6190,30 +6191,6 @@ components:
required:
- startInclusive
- endInclusive
Cas1PremiseCharacteristic:
type: string
description: All premise characteristics
enum:
- acceptsChildSexOffenders
- acceptsHateCrimeOffenders
- acceptsNonSexualChildOffenders
- acceptsSexOffenders
- additionalRestrictions
- hasBrailleSignage
- hasHearingLoop
- hasLift
- hasStepFreeAccessToCommunalAreas
- hasTactileFlooring
- hasWheelChairAccessibleBathrooms
- hasWideAccessToCommunalAreas
- hasWideStepFreeAccess
- isCatered
- isESAP
- isIAP
- isPIPE
- isRecoveryFocussed
- isSuitableForVulnerable
- isSemiSpecialistMentalHealth
Cas1SpaceCharacteristic:
type: string
description: All of the characteristics of both premises and rooms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.EnumSource
import org.springframework.beans.factory.annotation.Autowired
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.ApType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.Cas1PremiseCharacteristic
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.Cas1SpaceCharacteristic
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.Cas1SpaceSearchParameters
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.Cas1SpaceSearchRequirements
Expand Down Expand Up @@ -109,9 +108,9 @@ class Cas1SpaceSearchTest : InitialiseDatabasePerClassTestBase() {
assertThat(results.searchCriteria).isEqualTo(searchParameters)

val expectedCharacteristics = listOf(
Cas1PremiseCharacteristic.hasWideAccessToCommunalAreas,
Cas1PremiseCharacteristic.hasWideStepFreeAccess,
Cas1PremiseCharacteristic.hasLift,
Cas1SpaceCharacteristic.hasWideAccessToCommunalAreas,
Cas1SpaceCharacteristic.hasWideStepFreeAccess,
Cas1SpaceCharacteristic.hasLift,
)

assertThatResultMatches(results.results[0], premises[0], expectedCharacteristics = expectedCharacteristics)
Expand Down Expand Up @@ -341,7 +340,7 @@ class Cas1SpaceSearchTest : InitialiseDatabasePerClassTestBase() {
actual: Cas1SpaceSearchResult,
expected: ApprovedPremisesEntity,
expectedApType: ApType = ApType.normal,
expectedCharacteristics: List<Cas1PremiseCharacteristic>? = null,
expectedCharacteristics: List<Cas1SpaceCharacteristic>? = null,
) {
assertThat(actual.spacesAvailable).isEmpty()
assertThat(actual.distanceInMiles).isGreaterThan(0f.toBigDecimal())
Expand Down

0 comments on commit de6172e

Please sign in to comment.