Skip to content

Commit d26579a

Browse files
authored
Create ApiMockServer - a generic mock server to de-duplicate creation of mock servers (#719)
* add ApiMockServer as a generic mock server and use on incentives gateway tests * switch prison visits gateway to use generic ApiMockServer * remove unused mock servers * add create function to ApiMockServer and update Visits gateway and incentives gateway to use it * remove adjudications and assessRisksAndNeeds mock servers * remove caseNotes mock server * remove personal relationships mock server * remove CVL mock server * remove managePOM mock server * remove ndelius mock server * remove nomis mock server * remove non associations mock server * remove prisonerOffenderSearch mock server * remove probationOffenderSearch mock server * remove riskManagement mock server * remove EPF mock server; add EFFECTIVE_PROPOSAL_FRAMEWORK to Upstream API model * rename genericMockServer as it is only used for webclientwrapper tests * add comment to explain where ports come from on mock server
1 parent 4260135 commit d26579a

File tree

63 files changed

+594
-1043
lines changed

Some content is hidden

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

63 files changed

+594
-1043
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ProbationIntegrationEPFGateway(
2929
HttpMethod.GET,
3030
"/case-details/$id/$eventNumber",
3131
authenticationHeader(),
32-
UpstreamApi.NDELIUS,
32+
UpstreamApi.EFFECTIVE_PROPOSAL_FRAMEWORK,
3333
)
3434

3535
return when (result) {

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

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ enum class UpstreamApi {
66
PROBATION_OFFENDER_SEARCH,
77
NDELIUS,
88
ASSESS_RISKS_AND_NEEDS,
9+
EFFECTIVE_PROPOSAL_FRAMEWORK,
910
ADJUDICATIONS,
1011
CVL,
1112
CASE_NOTES,

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/extensions/WebClientWrapperTest.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.springframework.http.HttpMethod
88
import org.springframework.http.HttpStatus
99
import org.springframework.web.reactive.function.client.WebClientResponseException
1010
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.WebClientWrapper.WebClientWrapperResponse
11-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.GenericApiMockServer
11+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.TestApiMockServer
1212
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
1313
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
1414
import java.io.File
@@ -35,7 +35,7 @@ data class TestDomainModel(
3535

3636
class WebClientWrapperTest :
3737
DescribeSpec({
38-
val mockServer = GenericApiMockServer()
38+
val mockServer = TestApiMockServer()
3939
val id = "ABC1234"
4040
val headers = mapOf("foo" to "bar")
4141

@@ -125,7 +125,7 @@ class WebClientWrapperTest :
125125
{
126126
"sourceName": "Paul"
127127
},
128-
{
128+
{
129129
"sourceName": "Paul"
130130
}
131131
]
@@ -154,7 +154,7 @@ class WebClientWrapperTest :
154154
{
155155
"sourceName": "Paul"
156156
},
157-
{
157+
{
158158
"sourceName": "Paul"
159159
}
160160
]

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/adjudications/AdjudicationsGatewayTest.kt

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import org.springframework.test.context.bean.override.mockito.MockitoBean
1515
import org.springframework.web.reactive.function.client.WebClientResponseException
1616
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.AdjudicationsGateway
1717
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.HmppsAuthGateway
18-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.AdjudicationsApiMockServer
18+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.ApiMockServer
1919
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.HmppsAuthMockServer
20+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
2021

2122
@ActiveProfiles("test")
2223
@ContextConfiguration(
@@ -28,7 +29,9 @@ class AdjudicationsGatewayTest(
2829
val adjudicationsGateway: AdjudicationsGateway,
2930
) : DescribeSpec(
3031
{
31-
val adjudicationsApiMockServer = AdjudicationsApiMockServer()
32+
val id = "123"
33+
val path = "/reported-adjudications/prisoner/$id"
34+
val adjudicationsApiMockServer = ApiMockServer.create(UpstreamApi.ADJUDICATIONS)
3235
beforeEach {
3336
adjudicationsApiMockServer.start()
3437

@@ -48,7 +51,7 @@ class AdjudicationsGatewayTest(
4851
}
4952

5053
it("upstream API returns an error, throw exception") {
51-
adjudicationsApiMockServer.stubGetReportedAdjudicationsForPerson("123", "", HttpStatus.BAD_REQUEST)
54+
adjudicationsApiMockServer.stubForGet(path, "", HttpStatus.BAD_REQUEST)
5255
val response =
5356
shouldThrow<WebClientResponseException> {
5457
adjudicationsGateway.getReportedAdjudicationsForPerson(id = "123")
@@ -57,8 +60,8 @@ class AdjudicationsGatewayTest(
5760
}
5861

5962
it("returns adjudicationResponse") {
60-
adjudicationsApiMockServer.stubGetReportedAdjudicationsForPerson(
61-
"123",
63+
adjudicationsApiMockServer.stubForGet(
64+
path,
6265
"""
6366
[
6467
{

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/assessrisksandneeds/GetNeedsForPersonTest.kt

+9-7
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import org.springframework.test.context.ContextConfiguration
1414
import org.springframework.test.context.bean.override.mockito.MockitoBean
1515
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.AssessRisksAndNeedsGateway
1616
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.HmppsAuthGateway
17-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.AssessRisksAndNeedsApiMockServer
17+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.ApiMockServer
1818
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.HmppsAuthMockServer
1919
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Need
2020
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Needs
21+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
2122
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
2223
import java.time.LocalDateTime
2324

@@ -31,14 +32,15 @@ class GetNeedsForPersonTest(
3132
val assessRisksAndNeedsGateway: AssessRisksAndNeedsGateway,
3233
) : DescribeSpec(
3334
{
34-
val assessRisksAndNeedsApiMockServer = AssessRisksAndNeedsApiMockServer()
3535
val deliusCrn = "X777776"
36+
val path = "/needs/crn/$deliusCrn"
37+
val assessRisksAndNeedsApiMockServer = ApiMockServer.create(UpstreamApi.ASSESS_RISKS_AND_NEEDS)
3638

3739
beforeEach {
3840
assessRisksAndNeedsApiMockServer.start()
3941
Mockito.reset(hmppsAuthGateway)
40-
assessRisksAndNeedsApiMockServer.stubGetNeedsForPerson(
41-
deliusCrn,
42+
assessRisksAndNeedsApiMockServer.stubForGet(
43+
path,
4244
"""
4345
{
4446
"assessedOn": "2023-02-13T12:43:38",
@@ -110,8 +112,8 @@ class GetNeedsForPersonTest(
110112
}
111113

112114
it("returns an empty list when a needs section has no data") {
113-
assessRisksAndNeedsApiMockServer.stubGetNeedsForPerson(
114-
deliusCrn,
115+
assessRisksAndNeedsApiMockServer.stubForGet(
116+
path,
115117
"""
116118
{
117119
"assessedOn": "2023-02-13T12:43:38",
@@ -146,7 +148,7 @@ class GetNeedsForPersonTest(
146148
}
147149

148150
it("returns an error when 404 NOT FOUND is returned because no person is found") {
149-
assessRisksAndNeedsApiMockServer.stubGetNeedsForPerson(deliusCrn, "", HttpStatus.NOT_FOUND)
151+
assessRisksAndNeedsApiMockServer.stubForGet(path, "", HttpStatus.NOT_FOUND)
150152

151153
val response = assessRisksAndNeedsGateway.getNeedsForPerson(deliusCrn)
152154

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/assessrisksandneeds/GetRiskPredictorScoresForPersonTest.kt

+9-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ import org.springframework.test.context.ContextConfiguration
1414
import org.springframework.test.context.bean.override.mockito.MockitoBean
1515
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.AssessRisksAndNeedsGateway
1616
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.HmppsAuthGateway
17-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.AssessRisksAndNeedsApiMockServer
17+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.ApiMockServer
1818
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.HmppsAuthMockServer
1919
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.GeneralPredictor
2020
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.GroupReconviction
2121
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.RiskOfSeriousRecidivism
2222
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.RiskPredictorScore
2323
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SexualPredictor
24+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
2425
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
2526
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.ViolencePredictor
2627
import java.time.LocalDateTime
@@ -35,14 +36,15 @@ class GetRiskPredictorScoresForPersonTest(
3536
val assessRisksAndNeedsGateway: AssessRisksAndNeedsGateway,
3637
) : DescribeSpec(
3738
{
38-
val assessRisksAndNeedsApiMockServer = AssessRisksAndNeedsApiMockServer()
3939
val deliusCrn = "X777776"
40+
val path = "/risks/crn/$deliusCrn/predictors/all"
41+
val assessRisksAndNeedsApiMockServer = ApiMockServer.create(UpstreamApi.ASSESS_RISKS_AND_NEEDS)
4042

4143
beforeEach {
4244
assessRisksAndNeedsApiMockServer.start()
4345
Mockito.reset(hmppsAuthGateway)
44-
assessRisksAndNeedsApiMockServer.stubGetRiskPredictorScoresForPerson(
45-
deliusCrn,
46+
assessRisksAndNeedsApiMockServer.stubForGet(
47+
path,
4648
"""
4749
[
4850
{
@@ -101,23 +103,23 @@ class GetRiskPredictorScoresForPersonTest(
101103
}
102104

103105
it("returns an empty list when no risk predictor scores are found") {
104-
assessRisksAndNeedsApiMockServer.stubGetRiskPredictorScoresForPerson(deliusCrn, "[]")
106+
assessRisksAndNeedsApiMockServer.stubForGet(path, "[]")
105107

106108
val response = assessRisksAndNeedsGateway.getRiskPredictorScoresForPerson(deliusCrn)
107109

108110
response.data.shouldBe(emptyList())
109111
}
110112

111113
it("returns a 404 NOT FOUND status code when no person is found") {
112-
assessRisksAndNeedsApiMockServer.stubGetRiskPredictorScoresForPerson(deliusCrn, "", HttpStatus.NOT_FOUND)
114+
assessRisksAndNeedsApiMockServer.stubForGet(path, "", HttpStatus.NOT_FOUND)
113115

114116
val response = assessRisksAndNeedsGateway.getRiskPredictorScoresForPerson(deliusCrn)
115117

116118
response.hasError(UpstreamApiError.Type.ENTITY_NOT_FOUND).shouldBeTrue()
117119
}
118120

119121
it("returns a 403 FORBIDDEN status code when forbidden") {
120-
assessRisksAndNeedsApiMockServer.stubGetRiskPredictorScoresForPerson(deliusCrn, "", HttpStatus.FORBIDDEN)
122+
assessRisksAndNeedsApiMockServer.stubForGet(path, "", HttpStatus.FORBIDDEN)
121123

122124
val response = assessRisksAndNeedsGateway.getRiskPredictorScoresForPerson(deliusCrn)
123125

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/assessrisksandneeds/GetRisksForPersonTest.kt

+7-5
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ import org.springframework.test.context.ContextConfiguration
1414
import org.springframework.test.context.bean.override.mockito.MockitoBean
1515
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.AssessRisksAndNeedsGateway
1616
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.HmppsAuthGateway
17-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.AssessRisksAndNeedsApiMockServer
17+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.ApiMockServer
1818
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.HmppsAuthMockServer
1919
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.OtherRisks
2020
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Risk
2121
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.RiskSummary
2222
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.RiskToSelf
2323
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Risks
24+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
2425
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
2526
import java.io.File
2627
import java.time.LocalDateTime
@@ -35,14 +36,15 @@ class GetRisksForPersonTest(
3536
val assessRisksAndNeedsGateway: AssessRisksAndNeedsGateway,
3637
) : DescribeSpec(
3738
{
38-
val assessRisksAndNeedsApiMockServer = AssessRisksAndNeedsApiMockServer()
3939
val deliusCrn = "X777776"
40+
val path = "/risks/crn/$deliusCrn"
41+
val assessRisksAndNeedsApiMockServer = ApiMockServer.create(UpstreamApi.ASSESS_RISKS_AND_NEEDS)
4042

4143
beforeEach {
4244
assessRisksAndNeedsApiMockServer.start()
4345
Mockito.reset(hmppsAuthGateway)
44-
assessRisksAndNeedsApiMockServer.stubGetRisksForPerson(
45-
deliusCrn,
46+
assessRisksAndNeedsApiMockServer.stubForGet(
47+
path,
4648
File(
4749
"src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/assessrisksandneeds/fixtures/GetRisksResponse.json",
4850
).readText(),
@@ -148,7 +150,7 @@ class GetRisksForPersonTest(
148150
}
149151

150152
it("returns a 404 NOT FOUND status code when no person is found") {
151-
assessRisksAndNeedsApiMockServer.stubGetRisksForPerson(deliusCrn, "", HttpStatus.NOT_FOUND)
153+
assessRisksAndNeedsApiMockServer.stubForGet(path, "", HttpStatus.NOT_FOUND)
152154

153155
val response = assessRisksAndNeedsGateway.getRiskSeriousHarmForPerson(deliusCrn)
154156

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/caseNotes/CaseNotesGatewayTest.kt

+9-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import org.springframework.test.context.bean.override.mockito.MockitoBean
1717
import org.springframework.web.reactive.function.client.WebClientResponseException
1818
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.CaseNotesGateway
1919
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.HmppsAuthGateway
20-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.CaseNotesApiMockServer
20+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.ApiMockServer
2121
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.HmppsAuthMockServer
2222
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.filters.CaseNoteFilter
2323
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
@@ -34,8 +34,10 @@ class CaseNotesGatewayTest(
3434
private val caseNotesGateway: CaseNotesGateway,
3535
) : DescribeSpec(
3636
{
37+
val id = "123"
38+
val pathNoParams = "/case-notes/$id"
39+
val caseNotesApiMockServer = ApiMockServer.create(UpstreamApi.CASE_NOTES)
3740

38-
val caseNotesApiMockServer = CaseNotesApiMockServer()
3941
beforeEach {
4042
caseNotesApiMockServer.start()
4143

@@ -57,7 +59,7 @@ class CaseNotesGatewayTest(
5759
}
5860

5961
it("upstream API returns an error, throw exception") {
60-
caseNotesApiMockServer.stubGetCaseNotes("123", "", "", HttpStatus.BAD_REQUEST)
62+
caseNotesApiMockServer.stubForGet(pathNoParams, "", HttpStatus.BAD_REQUEST)
6163
val response =
6264
shouldThrow<WebClientResponseException> {
6365
caseNotesGateway.getCaseNotesForPerson(id = "123", CaseNoteFilter(hmppsId = ""))
@@ -66,7 +68,7 @@ class CaseNotesGatewayTest(
6668
}
6769

6870
it("upstream API returns an forbidden error, throw forbidden exception") {
69-
caseNotesApiMockServer.stubGetCaseNotes("123", "", "", HttpStatus.FORBIDDEN)
71+
caseNotesApiMockServer.stubForGet(pathNoParams, "", HttpStatus.FORBIDDEN)
7072
val response = caseNotesGateway.getCaseNotesForPerson(id = "123", CaseNoteFilter(hmppsId = ""))
7173
response.errors.shouldHaveSize(1)
7274
response.errors
@@ -144,7 +146,7 @@ class CaseNotesGatewayTest(
144146
"empty": false
145147
}
146148
"""
147-
caseNotesApiMockServer.stubGetCaseNotes("123", "", responseJson, HttpStatus.OK)
149+
caseNotesApiMockServer.stubForGet(pathNoParams, responseJson, HttpStatus.OK)
148150
val response = caseNotesGateway.getCaseNotesForPerson(id = "123", CaseNoteFilter(hmppsId = ""))
149151
response.data.count().shouldBe(2)
150152
response.data.shouldExist { it -> it.caseNoteId == "131231" }
@@ -217,8 +219,8 @@ class CaseNotesGatewayTest(
217219
"empty": false
218220
}
219221
"""
220-
val params = "?locationId=mockLocation&startDate=2024-01-02&endDate=2024-01-03"
221-
caseNotesApiMockServer.stubGetCaseNotes("123", params, responseJson, HttpStatus.OK)
222+
val pathWithParams = "/case-notes/$id?locationId=mockLocation&startDate=2024-01-02&endDate=2024-01-03"
223+
caseNotesApiMockServer.stubForGet(pathWithParams, responseJson, HttpStatus.OK)
222224
val response = caseNotesGateway.getCaseNotesForPerson(id = "123", filter)
223225
response.data.count().shouldBe(2)
224226
response.data.shouldExist { it -> it.caseNoteId == "131231" }

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/contacts/GetContactsGatewayTest.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import org.springframework.test.context.ContextConfiguration
1515
import org.springframework.test.context.bean.override.mockito.MockitoBean
1616
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.HmppsAuthGateway
1717
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.PersonalRelationshipsGateway
18+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.ApiMockServer
1819
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.HmppsAuthMockServer
19-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.PersonalRelationshipsApiMockServer
2020
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
2121
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
2222

@@ -35,7 +35,7 @@ class GetContactsGatewayTest(
3535
val page = 1
3636
val size = 10
3737
val pathWithQueryParams = "$getContactsPath?page=$page&size=$size"
38-
val personalRelationshipsApiMockServer = PersonalRelationshipsApiMockServer()
38+
val personalRelationshipsApiMockServer = ApiMockServer.create(UpstreamApi.PERSONAL_RELATIONSHIPS)
3939

4040
beforeEach {
4141
personalRelationshipsApiMockServer.start()
@@ -124,7 +124,7 @@ class GetContactsGatewayTest(
124124
}
125125
""".trimIndent()
126126

127-
personalRelationshipsApiMockServer.stubPersonalRelationshipsApiResponse(pathWithQueryParams, body = exampleData, HttpStatus.OK)
127+
personalRelationshipsApiMockServer.stubForGet(pathWithQueryParams, body = exampleData, HttpStatus.OK)
128128

129129
val response = personalRelationshipsGateway.getContacts(prisonerId, page, size)
130130
response.data.shouldNotBeNull()
@@ -137,7 +137,7 @@ class GetContactsGatewayTest(
137137
}
138138

139139
it("returns a 404 when visit is not found") {
140-
personalRelationshipsApiMockServer.stubPersonalRelationshipsApiResponse(pathWithQueryParams, body = "", HttpStatus.NOT_FOUND)
140+
personalRelationshipsApiMockServer.stubForGet(pathWithQueryParams, body = "", HttpStatus.NOT_FOUND)
141141

142142
val response = personalRelationshipsGateway.getContacts(prisonerId, page, size)
143143
response.errors.shouldHaveSize(1)

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/createAndVaryLicence/GetLicenceConditionsTests.kt

+8-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ import org.springframework.test.context.ContextConfiguration
1414
import org.springframework.test.context.bean.override.mockito.MockitoBean
1515
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.CreateAndVaryLicenceGateway
1616
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.HmppsAuthGateway
17-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.CreateAndVaryLicenceApiMockServer
17+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.ApiMockServer
1818
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.HmppsAuthMockServer
19+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
1920
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
2021

2122
@ActiveProfiles("test")
@@ -28,13 +29,14 @@ class GetLicenceConditionsTests(
2829
private val createAndVaryLicenceGateway: CreateAndVaryLicenceGateway,
2930
) : DescribeSpec(
3031
{
31-
val createAndVaryLicenceApiMockServer = CreateAndVaryLicenceApiMockServer()
3232
val conditionId = 12345
33+
val path = "/public/licences/id/$conditionId"
34+
val createAndVaryLicenceApiMockServer = ApiMockServer.create(UpstreamApi.CVL)
3335

3436
beforeEach {
3537
createAndVaryLicenceApiMockServer.start()
36-
createAndVaryLicenceApiMockServer.stubGetLicenceConditions(
37-
conditionId,
38+
createAndVaryLicenceApiMockServer.stubForGet(
39+
path,
3840
"""
3941
{
4042
"conditions":
@@ -77,8 +79,8 @@ class GetLicenceConditionsTests(
7779
}
7880

7981
it("returns an error when 404 NOT FOUND is returned") {
80-
createAndVaryLicenceApiMockServer.stubGetLicenceConditions(
81-
conditionId,
82+
createAndVaryLicenceApiMockServer.stubForGet(
83+
path,
8284
"""
8385
[{
8486
"developerMessage": "cannot find person"

0 commit comments

Comments
 (0)