use of uk.gov.pay.connector.events.eventdetails.charge.PaymentNotificationCreatedEventDetails in project pay-connector by alphagov.
the class EventFactoryTest method shouldCreatedCorrectEventForPaymentNotificationCreated.
@Test
public void shouldCreatedCorrectEventForPaymentNotificationCreated() throws Exception {
ChargeEntity charge = ChargeEntityFixture.aValidChargeEntity().withStatus(ChargeStatus.PAYMENT_NOTIFICATION_CREATED).build();
Long chargeEventEntityId = 100L;
ChargeEventEntity chargeEventEntity = ChargeEventEntityFixture.aValidChargeEventEntity().withCharge(charge).withId(chargeEventEntityId).build();
when(chargeEventDao.findById(ChargeEventEntity.class, chargeEventEntityId)).thenReturn(Optional.of(chargeEventEntity));
PaymentStateTransition paymentStateTransition = new PaymentStateTransition(chargeEventEntityId, PaymentNotificationCreated.class);
List<Event> events = eventFactory.createEvents(paymentStateTransition);
assertThat(events.size(), is(1));
PaymentNotificationCreated event = (PaymentNotificationCreated) events.get(0);
assertThat(event, is(instanceOf(PaymentNotificationCreated.class)));
assertThat(event.getEventDetails(), instanceOf(PaymentNotificationCreatedEventDetails.class));
assertThat(event.getResourceExternalId(), is(chargeEventEntity.getChargeEntity().getExternalId()));
PaymentNotificationCreatedEventDetails eventDetails = (PaymentNotificationCreatedEventDetails) event.getEventDetails();
assertThat(eventDetails.getGatewayTransactionId(), is(charge.getGatewayTransactionId()));
}
Aggregations