Search in sources :

Example 1 with PaymentNotificationCreatedEventDetails

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()));
}
Also used : ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) Event(uk.gov.pay.connector.events.model.Event) PaymentNotificationCreated(uk.gov.pay.connector.events.model.charge.PaymentNotificationCreated) PaymentNotificationCreatedEventDetails(uk.gov.pay.connector.events.eventdetails.charge.PaymentNotificationCreatedEventDetails) PaymentStateTransition(uk.gov.pay.connector.queue.statetransition.PaymentStateTransition) Test(org.junit.Test)

Aggregations

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