Search in sources :

Example 1 with SMARTPAY

use of uk.gov.pay.connector.gateway.PaymentGatewayName.SMARTPAY in project pay-connector by alphagov.

the class ClientFactoryIT method shouldUseGatewaySpecificReadTimeoutOverrideForSmartpay_whenSpecified.

@Test
public void shouldUseGatewaySpecificReadTimeoutOverrideForSmartpay_whenSpecified() {
    app = startApp("config/client-factory-test-config-with-smartpay-timeout-override.yaml", false);
    when(mockMetricRegistry.register(any(), any())).thenReturn(null);
    String path = "/hello";
    wireMockRule.stubFor(get(urlPathEqualTo("/hello")).willReturn(aResponse().withBody("world").withStatus(200).withFixedDelay(2000)));
    Client client = new ClientFactory(app.getEnvironment(), app.getConfiguration()).createWithDropwizardClient(SMARTPAY, AUTHORISE, mockMetricRegistry);
    Invocation.Builder request = client.target(getServerUrl()).path(path).request();
    Long authOverriddenTimeout = app.getConfiguration().getSmartpayConfig().getJerseyClientOverrides().map(override -> override.getAuth().getReadTimeout().toMicroseconds()).orElse(0L);
    assertGatewayFailure(request, authOverriddenTimeout);
}
Also used : IsInstanceOf.instanceOf(org.hamcrest.core.IsInstanceOf.instanceOf) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) Client(javax.ws.rs.client.Client) AUTHORISE(uk.gov.pay.connector.gateway.GatewayOperation.AUTHORISE) SMARTPAY(uk.gov.pay.connector.gateway.PaymentGatewayName.SMARTPAY) Assert.assertThat(org.junit.Assert.assertThat) After(org.junit.After) ClientFactory(uk.gov.pay.connector.gateway.ClientFactory) SocketTimeoutException(java.net.SocketTimeoutException) Matchers.lessThan(org.hamcrest.Matchers.lessThan) PortFactory(uk.gov.service.payments.commons.testing.port.PortFactory) Assert.fail(org.junit.Assert.fail) ClassRule(org.junit.ClassRule) ResourceHelpers(io.dropwizard.testing.ResourceHelpers) Before(org.junit.Before) WireMock.get(com.github.tomakehurst.wiremock.client.WireMock.get) WireMock.urlPathEqualTo(com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo) MetricRegistry(com.codahale.metrics.MetricRegistry) DropwizardTestSupport(io.dropwizard.testing.DropwizardTestSupport) WireMock.aResponse(com.github.tomakehurst.wiremock.client.WireMock.aResponse) Test(org.junit.Test) ClientProperties(org.glassfish.jersey.client.ClientProperties) Invocation(javax.ws.rs.client.Invocation) Mockito.when(org.mockito.Mockito.when) ConnectorConfiguration(uk.gov.pay.connector.app.ConnectorConfiguration) String.format(java.lang.String.format) ConnectorApp(uk.gov.pay.connector.app.ConnectorApp) WireMockClassRule(com.github.tomakehurst.wiremock.junit.WireMockClassRule) WORLDPAY(uk.gov.pay.connector.gateway.PaymentGatewayName.WORLDPAY) WireMock.getRequestedFor(com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor) WireMock.urlEqualTo(com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo) Mockito.any(org.mockito.Mockito.any) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) Invocation(javax.ws.rs.client.Invocation) ClientFactory(uk.gov.pay.connector.gateway.ClientFactory) Client(javax.ws.rs.client.Client) Test(org.junit.Test)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 WireMock.aResponse (com.github.tomakehurst.wiremock.client.WireMock.aResponse)1 WireMock.get (com.github.tomakehurst.wiremock.client.WireMock.get)1 WireMock.getRequestedFor (com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor)1 WireMock.urlEqualTo (com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo)1 WireMock.urlPathEqualTo (com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo)1 WireMockClassRule (com.github.tomakehurst.wiremock.junit.WireMockClassRule)1 DropwizardTestSupport (io.dropwizard.testing.DropwizardTestSupport)1 ResourceHelpers (io.dropwizard.testing.ResourceHelpers)1 String.format (java.lang.String.format)1 SocketTimeoutException (java.net.SocketTimeoutException)1 Client (javax.ws.rs.client.Client)1 Invocation (javax.ws.rs.client.Invocation)1 ClientProperties (org.glassfish.jersey.client.ClientProperties)1 Matchers.lessThan (org.hamcrest.Matchers.lessThan)1 IsInstanceOf.instanceOf (org.hamcrest.core.IsInstanceOf.instanceOf)1 After (org.junit.After)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertThat (org.junit.Assert.assertThat)1 Assert.fail (org.junit.Assert.fail)1