@@ -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.Person
16
16
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
17
+ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.prisoneroffendersearch.POSPrisoner
17
18
18
19
@ContextConfiguration(
19
20
initializers = [ConfigDataApplicationContextInitializer ::class ],
@@ -36,6 +37,9 @@ internal class GetPersonServiceTest(
36
37
whenever(probationOffenderSearchGateway.getPerson(id = hmppsId)).thenReturn(
37
38
Response (data = Person (firstName = "Qui -gon", lastName = "Jin ", identifiers = Identifiers (nomisNumber = "A1234AA "))),
38
39
)
40
+ whenever(prisonerOffenderSearchGateway.getPrisonOffender(nomsNumber = "A1234AA ")).thenReturn(
41
+ Response (data = POSPrisoner (firstName = "Sam ", lastName = "Mills ")),
42
+ )
39
43
}
40
44
41
45
it("gets a person from Probation Offender Search ") {
@@ -66,4 +70,22 @@ internal class GetPersonServiceTest(
66
70
67
71
result.data.shouldBe(expectedResult)
68
72
}
73
+
74
+ it("returns a person with both probation and prison data when prison data exists") {
75
+ val personFromProbationOffenderSearch = Person ("Paula ", "First ", identifiers = Identifiers (nomisNumber = "A1234AA "))
76
+ val personFromPrisonOffenderSearch = POSPrisoner ("Sam ", "Mills ")
77
+
78
+ whenever(probationOffenderSearchGateway.getPerson(hmppsId)).thenReturn(
79
+ Response (data = personFromProbationOffenderSearch),
80
+ )
81
+ whenever(prisonerOffenderSearchGateway.getPrisonOffender("A1234AA ")).thenReturn(
82
+ Response (data = personFromPrisonOffenderSearch),
83
+ )
84
+
85
+ val result = getPersonService.getCombinedDataForPerson(hmppsId)
86
+ val expectedResult = result.data
87
+
88
+ result.data.shouldBe(expectedResult)
89
+ result.errors shouldBe emptyList()
90
+ }
69
91
})
0 commit comments