Skip to content

Commit

Permalink
Remove example mapping for external api call property causing failure (
Browse files Browse the repository at this point in the history
…#2)

* Remove example mapping for external api call property causing failure

* Remove example api code and fix tests
  • Loading branch information
awhodgson256 authored Oct 31, 2024
1 parent 2867a84 commit 045065d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package uk.gov.justice.digital.hmpps.findandreferanintervention.config
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager
import org.springframework.web.reactive.function.client.WebClient
import uk.gov.justice.hmpps.kotlin.auth.authorisedWebClient
import uk.gov.justice.hmpps.kotlin.auth.healthWebClient
import java.time.Duration

@Configuration
class WebClientConfiguration(
@Value("\${example-api.url}") val exampleApiBaseUri: String,
// @Value("\${example-api.url}") val exampleApiBaseUri: String,
@Value("\${hmpps-auth.url}") val hmppsAuthBaseUri: String,
@Value("\${api.health-timeout:2s}") val healthTimeout: Duration,
@Value("\${api.timeout:20s}") val timeout: Duration,
Expand All @@ -22,11 +20,11 @@ class WebClientConfiguration(
fun hmppsAuthHealthWebClient(builder: WebClient.Builder): WebClient = builder.healthWebClient(hmppsAuthBaseUri, healthTimeout)

// TODO: This is an example health bean for checking other services and should be removed / replaced
@Bean
fun exampleApiHealthWebClient(builder: WebClient.Builder): WebClient = builder.healthWebClient(exampleApiBaseUri, healthTimeout)
// @Bean
// fun exampleApiHealthWebClient(builder: WebClient.Builder): WebClient = builder.healthWebClient(exampleApiBaseUri, healthTimeout)

// TODO: This is an example bean for calling other services and should be removed / replaced
@Bean
fun exampleApiWebClient(authorizedClientManager: OAuth2AuthorizedClientManager, builder: WebClient.Builder): WebClient =
builder.authorisedWebClient(authorizedClientManager, registrationId = "example-api", url = exampleApiBaseUri, timeout)
// @Bean
// fun exampleApiWebClient(authorizedClientManager: OAuth2AuthorizedClientManager, builder: WebClient.Builder): WebClient =
// builder.authorisedWebClient(authorizedClientManager, registrationId = "example-api", url = exampleApiBaseUri, timeout)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ import uk.gov.justice.hmpps.kotlin.health.HealthPingCheck
class HmppsAuthHealthPing(@Qualifier("hmppsAuthHealthWebClient") webClient: WebClient) : HealthPingCheck(webClient)

// TODO: Example ping health check calling out to other services
@Component("exampleApi")
class ExampleApiHealthPing(@Qualifier("exampleApiHealthWebClient") webClient: WebClient) : HealthPingCheck(webClient)
// @Component("exampleApi")
// class ExampleApiHealthPing(@Qualifier("exampleApiHealthWebClient") webClient: WebClient) : HealthPingCheck(webClient)

class Dummy()
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
package uk.gov.justice.digital.hmpps.findandreferanintervention.integration

import com.github.tomakehurst.wiremock.client.WireMock
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import uk.gov.justice.digital.hmpps.findandreferanintervention.integration.wiremock.ExampleApiExtension.Companion.exampleApi
import uk.gov.justice.digital.hmpps.findandreferanintervention.integration.wiremock.HmppsAuthApiExtension.Companion.hmppsAuth
import java.time.LocalDate

class ExampleResourceIntTest : IntegrationTestBase() {
class ExampleResourceIntTest
/*: IntegrationTestBase() {
@Nested
@DisplayName("GET /example/time")
Expand Down Expand Up @@ -127,3 +119,4 @@ class ExampleResourceIntTest : IntegrationTestBase() {
}
}
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDO
import org.springframework.http.HttpHeaders
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.web.reactive.server.WebTestClient
import uk.gov.justice.digital.hmpps.findandreferanintervention.integration.wiremock.ExampleApiExtension
import uk.gov.justice.digital.hmpps.findandreferanintervention.integration.wiremock.ExampleApiExtension.Companion.exampleApi
import uk.gov.justice.digital.hmpps.findandreferanintervention.integration.wiremock.HmppsAuthApiExtension
import uk.gov.justice.digital.hmpps.findandreferanintervention.integration.wiremock.HmppsAuthApiExtension.Companion.hmppsAuth
import uk.gov.justice.hmpps.test.kotlin.auth.JwtAuthorisationHelper

@ExtendWith(HmppsAuthApiExtension::class, ExampleApiExtension::class)
@ExtendWith(HmppsAuthApiExtension::class) // , ExampleApiExtension::class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ActiveProfiles("test")
abstract class IntegrationTestBase {
Expand All @@ -32,6 +30,6 @@ abstract class IntegrationTestBase {

protected fun stubPingWithResponse(status: Int) {
hmppsAuth.stubHealthPing(status)
exampleApi.stubHealthPing(status)
// exampleApi.stubHealthPing(status)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HealthCheckTest : IntegrationTestBase() {
.expectBody()
.jsonPath("status").isEqualTo("DOWN")
.jsonPath("components.hmppsAuth.status").isEqualTo("DOWN")
.jsonPath("components.exampleApi.status").isEqualTo("DOWN")
// .jsonPath("components.exampleApi.status").isEqualTo("DOWN")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package uk.gov.justice.digital.hmpps.findandreferanintervention.integration.wiremock

import com.github.tomakehurst.wiremock.WireMockServer
import com.github.tomakehurst.wiremock.client.WireMock.aResponse
import com.github.tomakehurst.wiremock.client.WireMock.get
import com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching
import org.junit.jupiter.api.extension.AfterAllCallback
import org.junit.jupiter.api.extension.BeforeAllCallback
import org.junit.jupiter.api.extension.BeforeEachCallback
import org.junit.jupiter.api.extension.ExtensionContext

// TODO: Remove / replace this mock server as it currently calls the Example API (itself)
class ExampleApiMockServer : WireMockServer(8091) {
class ExampleApiMockServer
/*: WireMockServer(8091) {
fun stubHealthPing(status: Int) {
stubFor(
get("/health/ping").willReturn(
Expand Down Expand Up @@ -55,4 +49,4 @@ class ExampleApiExtension : BeforeAllCallback, AfterAllCallback, BeforeEachCallb
override fun beforeAll(context: ExtensionContext): Unit = exampleApi.start()
override fun beforeEach(context: ExtensionContext): Unit = exampleApi.resetAll()
override fun afterAll(context: ExtensionContext): Unit = exampleApi.stop()
}
}*/

0 comments on commit 045065d

Please sign in to comment.