@@ -14,6 +14,7 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.ProbationOffend
14
14
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Identifiers
15
15
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.OffenderSearchResponse
16
16
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Person
17
+ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.PersonOnProbation
17
18
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
18
19
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
19
20
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
@@ -38,7 +39,7 @@ internal class GetPersonServiceTest(
38
39
Response (data = listOf(Person (firstName = "Qui -gon", lastName = "Jin ", identifiers = Identifiers (nomisNumber = "A1234AA ")))),
39
40
)
40
41
whenever(probationOffenderSearchGateway.getPerson(id = hmppsId)).thenReturn(
41
- Response (data = Person (firstName = "Qui -gon", lastName = "Jin ", identifiers = Identifiers (nomisNumber = "A1234AA "))),
42
+ Response (data = PersonOnProbation ( Person (firstName = "Qui -gon", lastName = "Jin ", identifiers = Identifiers (nomisNumber = "A1234AA ")), underActiveSupervision = true )),
42
43
)
43
44
whenever(prisonerOffenderSearchGateway.getPrisonOffender(nomsNumber = "A1234AA ")).thenReturn(
44
45
Response (data = POSPrisoner (firstName = "Sam ", lastName = "Mills ")),
@@ -52,17 +53,15 @@ internal class GetPersonServiceTest(
52
53
}
53
54
54
55
it("returns a person") {
55
- val personFromProbationOffenderSearch = Person ("Molly ", "Mob ")
56
+ val personFromProbationOffenderSearch = PersonOnProbation ( Person ("Molly ", "Mob "), underActiveSupervision = true )
56
57
57
58
whenever(probationOffenderSearchGateway.getPerson(hmppsId)).thenReturn(
58
59
Response (personFromProbationOffenderSearch),
59
60
)
60
61
61
62
val result = getPersonService.execute(hmppsId)
62
63
63
- val expectedResult = Person ("Molly ", "Mob ")
64
-
65
- result.data.shouldBe(expectedResult)
64
+ result.data.shouldBe(personFromProbationOffenderSearch)
66
65
}
67
66
68
67
it("returns null when a person isn't found in probation offender search") {
@@ -75,7 +74,7 @@ internal class GetPersonServiceTest(
75
74
}
76
75
77
76
it("returns a person with both probation and prison data when prison data exists") {
78
- val personFromProbationOffenderSearch = Person ("Paula ", "First ", identifiers = Identifiers (nomisNumber = "A1234AA "))
77
+ val personFromProbationOffenderSearch = PersonOnProbation ( Person ("Paula ", "First ", identifiers = Identifiers (nomisNumber = "A1234AA ")), underActiveSupervision = true )
79
78
val personFromPrisonOffenderSearch = POSPrisoner ("Sam ", "Mills ")
80
79
81
80
whenever(probationOffenderSearchGateway.getPerson(hmppsId)).thenReturn(
@@ -93,7 +92,7 @@ internal class GetPersonServiceTest(
93
92
}
94
93
95
94
it("returns errors when unable to retrieve prison data and data when probation data is available") {
96
- val personFromProbationOffenderSearch = Person ("Paula ", "First ", identifiers = Identifiers (nomisNumber = "A1234AA "))
95
+ val personFromProbationOffenderSearch = PersonOnProbation ( Person ("Paula ", "First ", identifiers = Identifiers (nomisNumber = "A1234AA ")), underActiveSupervision = true )
97
96
98
97
whenever(probationOffenderSearchGateway.getPerson(hmppsId)).thenReturn(Response (data = personFromProbationOffenderSearch))
99
98
whenever(prisonerOffenderSearchGateway.getPrisonOffender("A1234AA ")).thenReturn(Response (data = null, errors = listOf(UpstreamApiError (UpstreamApi .PRISONER_OFFENDER_SEARCH , UpstreamApiError .Type .ENTITY_NOT_FOUND , "MockError "))))
0 commit comments