Search in sources :

Example 1 with ConnectorConfiguration

use of uk.gov.pay.connector.app.ConnectorConfiguration in project pay-connector by alphagov.

the class SmartpayPaymentProviderTest method getSmartpayPaymentProvider.

private PaymentProvider getSmartpayPaymentProvider() {
    Client client = TestClientFactory.createJerseyClient();
    GatewayClient gatewayClient = new GatewayClient(client, mockMetricRegistry);
    GatewayClientFactory gatewayClientFactory = mock(GatewayClientFactory.class);
    when(gatewayClientFactory.createGatewayClient(any(PaymentGatewayName.class), any(MetricRegistry.class))).thenReturn(gatewayClient);
    GatewayConfig gatewayConfig = mock(GatewayConfig.class);
    when(gatewayConfig.getUrls()).thenReturn(Map.of(TEST.toString(), url));
    ConnectorConfiguration configuration = mock(ConnectorConfiguration.class);
    when(configuration.getGatewayConfigFor(SMARTPAY)).thenReturn(gatewayConfig);
    return new SmartpayPaymentProvider(configuration, gatewayClientFactory, mockEnvironment);
}
Also used : GatewayClient(uk.gov.pay.connector.gateway.GatewayClient) GatewayClientFactory(uk.gov.pay.connector.gateway.GatewayClientFactory) MetricRegistry(com.codahale.metrics.MetricRegistry) ConnectorConfiguration(uk.gov.pay.connector.app.ConnectorConfiguration) PaymentGatewayName(uk.gov.pay.connector.gateway.PaymentGatewayName) Client(javax.ws.rs.client.Client) GatewayClient(uk.gov.pay.connector.gateway.GatewayClient) GatewayConfig(uk.gov.pay.connector.app.GatewayConfig) SmartpayPaymentProvider(uk.gov.pay.connector.gateway.smartpay.SmartpayPaymentProvider)

Example 2 with ConnectorConfiguration

use of uk.gov.pay.connector.app.ConnectorConfiguration in project pay-connector by alphagov.

the class HistoricalEventEmitterServiceTest method setUp.

@Before
public void setUp() {
    connectorConfiguration = new ConnectorConfiguration();
    historicalEventEmitterService = new HistoricalEventEmitterService(chargeDao, refundDao, chargeEventDao, emittedEventDao, stateTransitionService, eventService, chargeService, connectorConfiguration);
    CardDetailsEntity cardDetails = mock(CardDetailsEntity.class);
    when(cardDetails.getLastDigitsCardNumber()).thenReturn(LastDigitsCardNumber.of("1234"));
    chargeEntity = ChargeEntityFixture.aValidChargeEntity().withCardDetails(cardDetails).build();
    ChargeEventEntity chargeEventEntity = ChargeEventEntityFixture.aValidChargeEventEntity().withTimestamp(ZonedDateTime.ofInstant(chargeEntity.getCreatedDate(), ZoneOffset.UTC)).withCharge(chargeEntity).withChargeStatus(ChargeStatus.CREATED).build();
    chargeEntity.getEvents().add(chargeEventEntity);
}
Also used : ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) ConnectorConfiguration(uk.gov.pay.connector.app.ConnectorConfiguration) CardDetailsEntity(uk.gov.pay.connector.charge.model.CardDetailsEntity) Before(org.junit.Before)

Example 3 with ConnectorConfiguration

use of uk.gov.pay.connector.app.ConnectorConfiguration in project pay-connector by alphagov.

the class LedgerServiceTest method setUp.

@Before
public void setUp() {
    Client mockClient = mock(Client.class);
    ConnectorConfiguration mockConnectorConfiguration = mock(ConnectorConfiguration.class);
    WebTarget mockWebTarget = mock(WebTarget.class);
    Invocation.Builder mockBuilder = mock(Invocation.Builder.class);
    mockResponse = mock(Response.class);
    when(mockConnectorConfiguration.getLedgerBaseUrl()).thenReturn("http://ledgerUrl");
    when(mockClient.target(any(UriBuilder.class))).thenReturn(mockWebTarget);
    when(mockWebTarget.request()).thenReturn(mockBuilder);
    when(mockBuilder.accept(APPLICATION_JSON)).thenReturn(mockBuilder);
    when(mockBuilder.get()).thenReturn(mockResponse);
    when(mockResponse.getStatus()).thenReturn(SC_OK);
    ledgerService = new LedgerService(mockClient, mockConnectorConfiguration);
}
Also used : Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) ConnectorConfiguration(uk.gov.pay.connector.app.ConnectorConfiguration) WebTarget(javax.ws.rs.client.WebTarget) Client(javax.ws.rs.client.Client) UriBuilder(javax.ws.rs.core.UriBuilder) Before(org.junit.Before)

Example 4 with ConnectorConfiguration

use of uk.gov.pay.connector.app.ConnectorConfiguration in project pay-connector by alphagov.

the class Card3dsResponseAuthServiceTest method setUpCardAuthorisationService.

@Before
public void setUpCardAuthorisationService() {
    Environment mockEnvironment = mock(Environment.class);
    Counter mockCounter = mock(Counter.class);
    when(mockEnvironment.metrics()).thenReturn(mockMetricRegistry);
    when(mockMetricRegistry.counter(anyString())).thenReturn(mockCounter);
    ConnectorConfiguration mockConfiguration = mock(ConnectorConfiguration.class);
    when(mockConfiguration.getAuthorisation3dsConfig()).thenReturn(mockAuthorisation3dsConfig);
    chargeService = new ChargeService(null, mockedChargeDao, mockedChargeEventDao, null, null, mockConfiguration, null, mockStateTransitionService, ledgerService, mockedRefundService, mockEventService, mockGatewayAccountCredentialsService, northAmericanRegionMapper, mockTaskQueueService);
    AuthorisationService authorisationService = new AuthorisationService(mockExecutorService, mockEnvironment);
    card3dsResponseAuthService = new Card3dsResponseAuthService(mockedProviders, chargeService, authorisationService, mockConfiguration);
}
Also used : Counter(com.codahale.metrics.Counter) Environment(io.dropwizard.setup.Environment) ConnectorConfiguration(uk.gov.pay.connector.app.ConnectorConfiguration) ChargeService(uk.gov.pay.connector.charge.service.ChargeService) Before(org.junit.Before)

Example 5 with ConnectorConfiguration

use of uk.gov.pay.connector.app.ConnectorConfiguration in project pay-connector by alphagov.

the class DropwizardTestApplications method getTestContextOf.

static TestContext getTestContextOf(Class<? extends Application<?>> appClass, String configClasspathLocation, WireMockServer wireMockServer) {
    Pair<Class<? extends Application>, String> appConfig = Pair.of(appClass, configClasspathLocation);
    DropwizardTestSupport application = apps.get(appConfig);
    return new TestContext(application.getLocalPort(), ((ConnectorConfiguration) application.getConfiguration()), InjectorLookup.getInjector(application.getApplication()).get(), wireMockServer);
}
Also used : ConnectorConfiguration(uk.gov.pay.connector.app.ConnectorConfiguration) Application(io.dropwizard.Application) DropwizardTestSupport(io.dropwizard.testing.DropwizardTestSupport)

Aggregations

ConnectorConfiguration (uk.gov.pay.connector.app.ConnectorConfiguration)7 Before (org.junit.Before)5 ChargeService (uk.gov.pay.connector.charge.service.ChargeService)3 Client (javax.ws.rs.client.Client)2 ChargeEventEntity (uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity)2 AuthorisationLogger (uk.gov.pay.connector.logging.AuthorisationLogger)2 Counter (com.codahale.metrics.Counter)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 Application (io.dropwizard.Application)1 Environment (io.dropwizard.setup.Environment)1 DropwizardTestSupport (io.dropwizard.testing.DropwizardTestSupport)1 Invocation (javax.ws.rs.client.Invocation)1 WebTarget (javax.ws.rs.client.WebTarget)1 Response (javax.ws.rs.core.Response)1 UriBuilder (javax.ws.rs.core.UriBuilder)1 GatewayConfig (uk.gov.pay.connector.app.GatewayConfig)1 CardDetailsEntity (uk.gov.pay.connector.charge.model.CardDetailsEntity)1 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)1 GatewayClient (uk.gov.pay.connector.gateway.GatewayClient)1 GatewayClientFactory (uk.gov.pay.connector.gateway.GatewayClientFactory)1