Search in sources :

Example 1 with UserEmailCollectedEventDetails

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

the class EventFactoryTest method shouldCreatedCorrectEventForBackfillRecreatedUserEmailCollectedEvent.

@Test
public void shouldCreatedCorrectEventForBackfillRecreatedUserEmailCollectedEvent() throws Exception {
    ChargeEntity charge = ChargeEntityFixture.aValidChargeEntity().withStatus(ChargeStatus.USER_CANCELLED).withEmail("test@example.org").build();
    Long chargeEventEntityId = 100L;
    ChargeEventEntity chargeEventEntity = ChargeEventEntityFixture.aValidChargeEventEntity().withCharge(charge).withChargeStatus(ENTERING_CARD_DETAILS).withId(chargeEventEntityId).build();
    charge.getEvents().add(chargeEventEntity);
    when(chargeEventDao.findById(ChargeEventEntity.class, chargeEventEntityId)).thenReturn(Optional.of(chargeEventEntity));
    PaymentStateTransition paymentStateTransition = new PaymentStateTransition(chargeEventEntityId, BackfillerRecreatedUserEmailCollected.class);
    List<Event> events = eventFactory.createEvents(paymentStateTransition);
    assertThat(events.size(), is(1));
    BackfillerRecreatedUserEmailCollected event = (BackfillerRecreatedUserEmailCollected) events.get(0);
    assertThat(event, is(instanceOf(BackfillerRecreatedUserEmailCollected.class)));
    assertThat(event.getEventDetails(), instanceOf(UserEmailCollectedEventDetails.class));
    assertThat(event.getResourceExternalId(), is(chargeEventEntity.getChargeEntity().getExternalId()));
    UserEmailCollectedEventDetails eventDetails = (UserEmailCollectedEventDetails) event.getEventDetails();
    assertThat(eventDetails.getEmail(), is(charge.getEmail()));
}
Also used : ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) BackfillerRecreatedUserEmailCollected(uk.gov.pay.connector.events.model.charge.BackfillerRecreatedUserEmailCollected) ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) UserEmailCollectedEventDetails(uk.gov.pay.connector.events.eventdetails.charge.UserEmailCollectedEventDetails) Event(uk.gov.pay.connector.events.model.Event) 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 UserEmailCollectedEventDetails (uk.gov.pay.connector.events.eventdetails.charge.UserEmailCollectedEventDetails)1 Event (uk.gov.pay.connector.events.model.Event)1 BackfillerRecreatedUserEmailCollected (uk.gov.pay.connector.events.model.charge.BackfillerRecreatedUserEmailCollected)1 PaymentStateTransition (uk.gov.pay.connector.queue.statetransition.PaymentStateTransition)1