|
1 | 1 | package uk.gov.justice.digital.hmpps.hmppsintegrationapi.integration
|
2 | 2 |
|
| 3 | +import com.github.tomakehurst.wiremock.WireMockServer |
| 4 | +import com.github.tomakehurst.wiremock.core.Options |
| 5 | +import com.github.tomakehurst.wiremock.core.WireMockConfiguration.options |
3 | 6 | import org.junit.jupiter.api.AfterAll
|
4 | 7 | import org.junit.jupiter.api.BeforeAll
|
5 | 8 | import org.springframework.beans.factory.annotation.Autowired
|
| 9 | +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc |
6 | 10 | import org.springframework.boot.test.context.SpringBootTest
|
7 | 11 | import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT
|
| 12 | +import org.springframework.http.HttpHeaders |
8 | 13 | import org.springframework.test.context.ActiveProfiles
|
9 | 14 | import org.springframework.test.web.reactive.server.WebTestClient
|
| 15 | +import org.springframework.test.web.servlet.MockMvc |
| 16 | +import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.removeWhitespaceAndNewlines |
10 | 17 | import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.HmppsAuthMockServer
|
11 | 18 | import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.NomisApiMockServer
|
12 | 19 | import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.PrisonerOffenderSearchApiMockServer
|
| 20 | +import uk.gov.justice.digital.hmpps.hmppsintegrationapi.mockservers.ProbationOffenderSearchApiMockServer |
| 21 | +import java.io.File |
13 | 22 |
|
14 | 23 | @ActiveProfiles("test")
|
| 24 | +@AutoConfigureMockMvc |
15 | 25 | @SpringBootTest(webEnvironment = RANDOM_PORT)
|
16 | 26 | abstract class IntegrationTestBase {
|
17 |
| - @Suppress("SpringJavaInjectionPointsAutowiringInspection") |
18 | 27 | @Autowired
|
19 |
| - lateinit var webTestClient: WebTestClient |
| 28 | + lateinit var mockMvc: MockMvc |
20 | 29 |
|
21 | 30 | companion object {
|
22 |
| - private val nomisApiMockServer = NomisApiMockServer() |
23 | 31 | private val prisonerOffenderSearchApiMockServer = PrisonerOffenderSearchApiMockServer()
|
24 | 32 | private val hmppsAuthMockServer = HmppsAuthMockServer()
|
| 33 | +// private val probationOffenderSearchApiMockServer = ProbationOffenderSearchApiMockServer() |
| 34 | + |
| 35 | + private val wireMockServer = WireMockServer(options() |
| 36 | + .usingFilesUnderClasspath("simulations") |
| 37 | + .port(4002)) |
25 | 38 |
|
26 | 39 | @BeforeAll
|
27 | 40 | @JvmStatic
|
28 | 41 | fun startMockServers() {
|
29 |
| - nomisApiMockServer.start() |
30 | 42 | hmppsAuthMockServer.start()
|
31 | 43 | prisonerOffenderSearchApiMockServer.start()
|
| 44 | + wireMockServer.start() |
| 45 | +// probationOffenderSearchApiMockServer.start() |
32 | 46 |
|
33 | 47 | hmppsAuthMockServer.stubGetOAuthToken("client", "client-secret")
|
| 48 | + |
| 49 | + |
| 50 | +// probationOffenderSearchApiMockServer.stubPostOffenderSearch( |
| 51 | +// """ |
| 52 | +// { |
| 53 | +// "firstName": "Example_First_Name", |
| 54 | +// "surname": "Example_Last_Name", |
| 55 | +// "includeAliases": false |
| 56 | +// } |
| 57 | +// """.removeWhitespaceAndNewlines(), |
| 58 | +// File( |
| 59 | +// "src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/probationoffendersearch/fixtures/GetOffendersResponse.json", |
| 60 | +// ).readText(), |
| 61 | +// ) |
34 | 62 | }
|
35 | 63 |
|
36 | 64 | @AfterAll
|
37 | 65 | @JvmStatic
|
38 | 66 | fun stopMockServers() {
|
39 |
| - nomisApiMockServer.stop() |
40 | 67 | hmppsAuthMockServer.stop()
|
41 | 68 | prisonerOffenderSearchApiMockServer.stop()
|
| 69 | + wireMockServer.stop() |
| 70 | +// probationOffenderSearchApiMockServer.stop() |
42 | 71 | }
|
43 | 72 | }
|
| 73 | + |
| 74 | + fun getAuthHeader(): HttpHeaders { |
| 75 | + val headers = HttpHeaders() |
| 76 | + headers.set("subject-distinguished-name", "C=GB,ST=London,L=London,O=Home Office,CN=automated-test-client") |
| 77 | + return headers |
| 78 | + } |
44 | 79 | }
|
0 commit comments