@@ -8,8 +8,8 @@ import org.mockito.internal.verification.VerificationModeFactory
8
8
import org.mockito.kotlin.verify
9
9
import org.mockito.kotlin.whenever
10
10
import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer
11
- import org.springframework.boot.test.mock.mockito.MockBean
12
11
import org.springframework.test.context.ContextConfiguration
12
+ import org.springframework.test.context.bean.override.mockito.MockitoBean
13
13
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.PrisonerOffenderSearchGateway
14
14
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.CellLocation
15
15
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Identifiers
@@ -24,8 +24,8 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.prisoneroffenders
24
24
classes = [GetCellLocationForPersonService ::class ],
25
25
)
26
26
internal class GetCellLocationForPersonServiceTest (
27
- @MockBean val getPersonService : GetPersonService ,
28
- @MockBean val prisonerOffenderSearchGateway : PrisonerOffenderSearchGateway ,
27
+ @MockitoBean val getPersonService : GetPersonService ,
28
+ @MockitoBean val prisonerOffenderSearchGateway : PrisonerOffenderSearchGateway ,
29
29
private val getCellLocationForPersonService : GetCellLocationForPersonService ,
30
30
) : DescribeSpec(
31
31
{
@@ -76,5 +76,26 @@ internal class GetCellLocationForPersonServiceTest(
76
76
response.errors.first().causedBy.shouldBe(UpstreamApi .PROBATION_OFFENDER_SEARCH )
77
77
response.errors.first().type.shouldBe(UpstreamApiError .Type .ENTITY_NOT_FOUND )
78
78
}
79
+
80
+ it("returns the upstream error when nomis id is not found") {
81
+ whenever(prisonerOffenderSearchGateway.getPrisonOffender(nomisNumber)).thenReturn(
82
+ Response (
83
+ data = null,
84
+ errors =
85
+ listOf(
86
+ UpstreamApiError (
87
+ causedBy = UpstreamApi .PRISONER_OFFENDER_SEARCH ,
88
+ type = UpstreamApiError .Type .ENTITY_NOT_FOUND ,
89
+ ),
90
+ ),
91
+ ),
92
+ )
93
+
94
+ val response = getCellLocationForPersonService.execute(nomisNumber)
95
+
96
+ response.errors.shouldHaveSize(1)
97
+ response.errors.first().causedBy.shouldBe(UpstreamApi .PRISONER_OFFENDER_SEARCH )
98
+ response.errors.first().type.shouldBe(UpstreamApiError .Type .ENTITY_NOT_FOUND )
99
+ }
79
100
},
80
101
)
0 commit comments