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));
}
Aggregations