Search in sources :

Example 1 with SandboxPaymentProvider

use of uk.gov.pay.connector.gateway.sandbox.SandboxPaymentProvider in project pay-connector by alphagov.

the class EventFactoryTest method setUp.

@Before
public void setUp() {
    chargeService = mock(ChargeService.class);
    refundDao = mock(RefundDao.class);
    refundService = mock(RefundService.class);
    chargeEventDao = mock(ChargeEventDao.class);
    paymentProviders = mock(PaymentProviders.class);
    PaymentProvider paymentProvider = new SandboxPaymentProvider();
    when(paymentProviders.byName(any(PaymentGatewayName.class))).thenReturn(paymentProvider);
    eventFactory = new EventFactory(chargeService, refundDao, refundService, chargeEventDao, paymentProviders);
}
Also used : PaymentProvider(uk.gov.pay.connector.gateway.PaymentProvider) SandboxPaymentProvider(uk.gov.pay.connector.gateway.sandbox.SandboxPaymentProvider) EventFactory(uk.gov.pay.connector.events.model.EventFactory) RefundService(uk.gov.pay.connector.refund.service.RefundService) RefundDao(uk.gov.pay.connector.refund.dao.RefundDao) ChargeEventDao(uk.gov.pay.connector.chargeevent.dao.ChargeEventDao) PaymentProviders(uk.gov.pay.connector.gateway.PaymentProviders) PaymentGatewayName(uk.gov.pay.connector.gateway.PaymentGatewayName) ChargeService(uk.gov.pay.connector.charge.service.ChargeService) SandboxPaymentProvider(uk.gov.pay.connector.gateway.sandbox.SandboxPaymentProvider) Before(org.junit.Before)

Example 2 with SandboxPaymentProvider

use of uk.gov.pay.connector.gateway.sandbox.SandboxPaymentProvider in project pay-connector by alphagov.

the class ParityCheckServiceTest method setUp.

@Before
public void setUp() {
    ChargeEventEntity chargeEventCreated = createChargeEventEntity(CREATED, "2016-01-25T13:23:55Z");
    ChargeEventEntity chargeEventCaptured = createChargeEventEntity(CAPTURED, "2016-01-26T14:23:55Z");
    ChargeEventEntity chargeEventCaptureSubmitted = createChargeEventEntity(CAPTURE_SUBMITTED, "2016-01-26T13:23:55Z");
    chargeEntity = aValidChargeEntity().withStatus(CAPTURED).withCardDetails(defaultCardDetails()).withGatewayAccountEntity(defaultGatewayAccountEntity()).withMoto(true).withSource(CARD_PAYMENT_LINK).withFee(Fee.of(null, 10L)).withCorporateSurcharge(25L).withWalletType(APPLE_PAY).withDelayedCapture(true).withEvents(List.of(chargeEventCreated, chargeEventCaptured, chargeEventCaptureSubmitted)).build();
    refundEntity = RefundEntityFixture.aValidRefundEntity().withStatus(REFUNDED).build();
    when(mockRefundService.findRefunds(any())).thenReturn(refundEntities.stream().map(Refund::from).collect(Collectors.toList()));
    when(mockProviders.byName(any())).thenReturn(new SandboxPaymentProvider());
    parityCheckService = new ParityCheckService(mockLedgerService, mockChargeService, mockHistoricalEventEmitter, chargeParityChecker, refundParityChecker, mockRefundService);
}
Also used : Refund(uk.gov.pay.connector.refund.model.domain.Refund) ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) ChargeEventEntityFixture.aValidChargeEventEntity(uk.gov.pay.connector.pact.ChargeEventEntityFixture.aValidChargeEventEntity) ParityCheckService(uk.gov.pay.connector.tasks.service.ParityCheckService) SandboxPaymentProvider(uk.gov.pay.connector.gateway.sandbox.SandboxPaymentProvider) Before(org.junit.Before)

Example 3 with SandboxPaymentProvider

use of uk.gov.pay.connector.gateway.sandbox.SandboxPaymentProvider in project pay-connector by alphagov.

the class ChargeParityCheckerTest method setUp.

@Before
public void setUp() {
    ChargeEventEntity chargeEventCreated = createChargeEventEntity(CREATED, "2016-01-25T13:23:55Z");
    ChargeEventEntity chargeEventCaptured = createChargeEventEntity(CAPTURED, "2016-01-26T14:23:55Z");
    ChargeEventEntity chargeEventCaptureSubmitted = createChargeEventEntity(CAPTURE_SUBMITTED, "2016-01-26T13:23:55Z");
    Auth3dsRequiredEntity auth3dsRequiredEntity = anAuth3dsRequiredEntity().withThreeDsVersion("2.1.0").build();
    chargeEntity = aValidChargeEntity().withStatus(CAPTURED).withCardDetails(defaultCardDetails()).withGatewayAccountEntity(defaultGatewayAccountEntity()).withMoto(true).withSource(CARD_PAYMENT_LINK).withFee(Fee.of(null, 10L)).withCorporateSurcharge(25L).withWalletType(APPLE_PAY).withDelayedCapture(true).withEvents(List.of(chargeEventCreated, chargeEventCaptured, chargeEventCaptureSubmitted)).build();
    chargeEntityWith3ds = aValidChargeEntity().withStatus(CAPTURED).withEvents(List.of(chargeEventCreated, chargeEventCaptured, chargeEventCaptureSubmitted)).withAuth3dsDetailsEntity(auth3dsRequiredEntity).build();
    when(mockRefundService.findRefunds(any())).thenReturn(List.of());
    when(mockProviders.byName(any())).thenReturn(new SandboxPaymentProvider());
    Logger root = (Logger) LoggerFactory.getLogger(ChargeParityChecker.class);
    root.setLevel(Level.INFO);
    root.addAppender(mockAppender);
}
Also used : ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) ChargeEventEntityFixture.aValidChargeEventEntity(uk.gov.pay.connector.pact.ChargeEventEntityFixture.aValidChargeEventEntity) Auth3dsRequiredEntity(uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity) Auth3dsRequiredEntityFixture.anAuth3dsRequiredEntity(uk.gov.pay.connector.model.domain.Auth3dsRequiredEntityFixture.anAuth3dsRequiredEntity) Logger(ch.qos.logback.classic.Logger) SandboxPaymentProvider(uk.gov.pay.connector.gateway.sandbox.SandboxPaymentProvider) Before(org.junit.Before)

Example 4 with SandboxPaymentProvider

use of uk.gov.pay.connector.gateway.sandbox.SandboxPaymentProvider in project pay-connector by alphagov.

the class ParityCheckerServiceTest method setUp.

@Before
public void setUp() {
    when(mockProviders.byName(any())).thenReturn(new SandboxPaymentProvider());
    refundParityChecker = new RefundParityChecker(refundDao);
    parityCheckService = new ParityCheckService(ledgerService, chargeService, historicalEventEmitter, chargeParityChecker, refundParityChecker, refundService);
    parityCheckerService = new ParityCheckerService(chargeDao, chargeService, emittedEventDao, stateTransitionService, eventService, refundService, refundDao, parityCheckService);
    chargeEntity = aValidChargeEntity().withCardDetails(defaultCardDetails()).withGatewayAccountEntity(defaultGatewayAccountEntity()).withMoto(true).withSource(CARD_PAYMENT_LINK).withFee(Fee.of(null, 10L)).withCorporateSurcharge(25L).withWalletType(APPLE_PAY).withDelayedCapture(true).build();
    ChargeEventEntity chargeEventEntity = ChargeEventEntityFixture.aValidChargeEventEntity().withTimestamp(ZonedDateTime.ofInstant(chargeEntity.getCreatedDate(), ZoneOffset.UTC)).withCharge(chargeEntity).withChargeStatus(ChargeStatus.CREATED).build();
    chargeEntity.getEvents().add(chargeEventEntity);
    refundEntity = aValidRefundEntity().withChargeExternalId(chargeEntity.getExternalId()).build();
    RefundHistory refundHistory = aValidRefundHistoryEntity().withChargeExternalId(refundEntity.getChargeExternalId()).withStatus(CREATED.toString()).withHistoryStartDate(refundEntity.getCreatedDate()).build();
    refundHistoryList = new ArrayList<>();
    refundHistoryList.add(refundHistory);
}
Also used : RefundParityChecker(uk.gov.pay.connector.tasks.service.RefundParityChecker) ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) ParityCheckService(uk.gov.pay.connector.tasks.service.ParityCheckService) SandboxPaymentProvider(uk.gov.pay.connector.gateway.sandbox.SandboxPaymentProvider) RefundHistory(uk.gov.pay.connector.refund.model.domain.RefundHistory) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)4 SandboxPaymentProvider (uk.gov.pay.connector.gateway.sandbox.SandboxPaymentProvider)4 ChargeEventEntity (uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity)3 ChargeEventEntityFixture.aValidChargeEventEntity (uk.gov.pay.connector.pact.ChargeEventEntityFixture.aValidChargeEventEntity)2 ParityCheckService (uk.gov.pay.connector.tasks.service.ParityCheckService)2 Logger (ch.qos.logback.classic.Logger)1 Auth3dsRequiredEntity (uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity)1 ChargeService (uk.gov.pay.connector.charge.service.ChargeService)1 ChargeEventDao (uk.gov.pay.connector.chargeevent.dao.ChargeEventDao)1 EventFactory (uk.gov.pay.connector.events.model.EventFactory)1 PaymentGatewayName (uk.gov.pay.connector.gateway.PaymentGatewayName)1 PaymentProvider (uk.gov.pay.connector.gateway.PaymentProvider)1 PaymentProviders (uk.gov.pay.connector.gateway.PaymentProviders)1 Auth3dsRequiredEntityFixture.anAuth3dsRequiredEntity (uk.gov.pay.connector.model.domain.Auth3dsRequiredEntityFixture.anAuth3dsRequiredEntity)1 RefundDao (uk.gov.pay.connector.refund.dao.RefundDao)1 Refund (uk.gov.pay.connector.refund.model.domain.Refund)1 RefundHistory (uk.gov.pay.connector.refund.model.domain.RefundHistory)1 RefundService (uk.gov.pay.connector.refund.service.RefundService)1 RefundParityChecker (uk.gov.pay.connector.tasks.service.RefundParityChecker)1