Search in sources :

Example 1 with GatewayRequires3dsAuthorisationEventDetails

use of uk.gov.pay.connector.events.eventdetails.charge.GatewayRequires3dsAuthorisationEventDetails in project pay-connector by alphagov.

the class EventFactoryTest method shouldCreatedCorrectEventForGatewayRequires3dsAuthorisationEvent.

@Test
public void shouldCreatedCorrectEventForGatewayRequires3dsAuthorisationEvent() throws Exception {
    Auth3dsRequiredEntity auth3dsRequiredEntity = new Auth3dsRequiredEntity();
    auth3dsRequiredEntity.setThreeDsVersion("2.1.0");
    ChargeEntity charge = ChargeEntityFixture.aValidChargeEntity().withStatus(ChargeStatus.USER_CANCELLED).withEmail("test@example.org").withAuth3dsDetailsEntity(auth3dsRequiredEntity).build();
    Long chargeEventEntityId = 100L;
    ChargeEventEntity chargeEventEntity = ChargeEventEntityFixture.aValidChargeEventEntity().withCharge(charge).withChargeStatus(AUTHORISATION_3DS_REQUIRED).withId(chargeEventEntityId).build();
    charge.getEvents().add(chargeEventEntity);
    when(chargeEventDao.findById(ChargeEventEntity.class, chargeEventEntityId)).thenReturn(Optional.of(chargeEventEntity));
    PaymentStateTransition paymentStateTransition = new PaymentStateTransition(chargeEventEntityId, GatewayRequires3dsAuthorisation.class);
    List<Event> events = eventFactory.createEvents(paymentStateTransition);
    assertThat(events.size(), is(1));
    GatewayRequires3dsAuthorisation event = (GatewayRequires3dsAuthorisation) events.get(0);
    assertThat(event, is(instanceOf(GatewayRequires3dsAuthorisation.class)));
    assertThat(event.getEventDetails(), instanceOf(GatewayRequires3dsAuthorisationEventDetails.class));
    assertThat(event.getResourceExternalId(), is(chargeEventEntity.getChargeEntity().getExternalId()));
    GatewayRequires3dsAuthorisationEventDetails eventDetails = (GatewayRequires3dsAuthorisationEventDetails) event.getEventDetails();
    assertThat(eventDetails.getVersion3DS(), is("2.1.0"));
    assertThat(eventDetails.isRequires3DS(), is(true));
}
Also used : ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) Auth3dsRequiredEntity(uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity) Event(uk.gov.pay.connector.events.model.Event) PaymentStateTransition(uk.gov.pay.connector.queue.statetransition.PaymentStateTransition) GatewayRequires3dsAuthorisationEventDetails(uk.gov.pay.connector.events.eventdetails.charge.GatewayRequires3dsAuthorisationEventDetails) GatewayRequires3dsAuthorisation(uk.gov.pay.connector.events.model.charge.GatewayRequires3dsAuthorisation) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Auth3dsRequiredEntity (uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity)1 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)1 ChargeEventEntity (uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity)1 GatewayRequires3dsAuthorisationEventDetails (uk.gov.pay.connector.events.eventdetails.charge.GatewayRequires3dsAuthorisationEventDetails)1 Event (uk.gov.pay.connector.events.model.Event)1 GatewayRequires3dsAuthorisation (uk.gov.pay.connector.events.model.charge.GatewayRequires3dsAuthorisation)1 PaymentStateTransition (uk.gov.pay.connector.queue.statetransition.PaymentStateTransition)1