use of uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity in project pay-connector by alphagov.
the class HistoricalEventEmitterServiceTest method executeShouldIgnoreEventIfStateTransitionIsNotFound.
@Test
public void executeShouldIgnoreEventIfStateTransitionIsNotFound() {
ChargeEventEntity secondChargeEventEntity = ChargeEventEntityFixture.aValidChargeEventEntity().withTimestamp(ZonedDateTime.now().plusMinutes(1)).withCharge(chargeEntity).withChargeStatus(ChargeStatus.CAPTURED).build();
chargeEntity.getEvents().add(secondChargeEventEntity);
when(chargeDao.findMaxId()).thenReturn(1L);
when(chargeDao.findById(1L)).thenReturn(Optional.of(chargeEntity));
historicalEventEmitterService.emitHistoricEventsById(1L, OptionalLong.empty(), 1L);
ArgumentCaptor<StateTransition> argument = ArgumentCaptor.forClass(StateTransition.class);
verify(stateTransitionService, times(1)).offerStateTransition(argument.capture(), any(), isNotNull());
assertThat(argument.getAllValues().get(0).getStateTransitionEventClass(), is(PaymentCreated.class));
}
use of uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity in project pay-connector by alphagov.
the class HistoricalEventEmitterServiceTest method setUp.
@Before
public void setUp() {
connectorConfiguration = new ConnectorConfiguration();
historicalEventEmitterService = new HistoricalEventEmitterService(chargeDao, refundDao, chargeEventDao, emittedEventDao, stateTransitionService, eventService, chargeService, connectorConfiguration);
CardDetailsEntity cardDetails = mock(CardDetailsEntity.class);
when(cardDetails.getLastDigitsCardNumber()).thenReturn(LastDigitsCardNumber.of("1234"));
chargeEntity = ChargeEntityFixture.aValidChargeEntity().withCardDetails(cardDetails).build();
ChargeEventEntity chargeEventEntity = ChargeEventEntityFixture.aValidChargeEventEntity().withTimestamp(ZonedDateTime.ofInstant(chargeEntity.getCreatedDate(), ZoneOffset.UTC)).withCharge(chargeEntity).withChargeStatus(ChargeStatus.CREATED).build();
chargeEntity.getEvents().add(chargeEventEntity);
}
use of uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity in project pay-connector by alphagov.
the class HistoricalEventEmitterServiceTest method executeShouldNotEmitManualEventsWithNoTerminalAuthenticationState.
@Test
public void executeShouldNotEmitManualEventsWithNoTerminalAuthenticationState() {
ChargeEventEntity firstEvent = ChargeEventEntityFixture.aValidChargeEventEntity().withTimestamp(ZonedDateTime.now().plusMinutes(1)).withCharge(chargeEntity).withChargeStatus(ChargeStatus.CREATED).build();
chargeEntity.getEvents().add(firstEvent);
when(chargeDao.findMaxId()).thenReturn(1L);
when(chargeDao.findById(1L)).thenReturn(Optional.of(chargeEntity));
historicalEventEmitterService.emitHistoricEventsById(1L, OptionalLong.empty(), 1L);
verifyNoInteractions(eventService);
}
use of uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity in project pay-connector by alphagov.
the class HistoricalEventEmitterServiceTest method executeShouldNotEmitPaymentDetailsEnteredEventWithTerminalAuthenticationStateForNotificationPayment.
@Test
public void executeShouldNotEmitPaymentDetailsEnteredEventWithTerminalAuthenticationStateForNotificationPayment() {
ChargeEventEntity firstEvent = ChargeEventEntityFixture.aValidChargeEventEntity().withTimestamp(ZonedDateTime.now().plusMinutes(1)).withCharge(chargeEntity).withChargeStatus(ChargeStatus.PAYMENT_NOTIFICATION_CREATED).build();
ChargeEventEntity secondEvent = ChargeEventEntityFixture.aValidChargeEventEntity().withTimestamp(ZonedDateTime.now().plusMinutes(2)).withCharge(chargeEntity).withChargeStatus(ChargeStatus.AUTHORISATION_SUCCESS).build();
chargeEntity.getEvents().add(firstEvent);
chargeEntity.getEvents().add(secondEvent);
when(chargeDao.findMaxId()).thenReturn(1L);
when(chargeDao.findById(1L)).thenReturn(Optional.of(chargeEntity));
historicalEventEmitterService.emitHistoricEventsById(1L, OptionalLong.empty(), 1L);
verify(eventService, never()).emitAndRecordEvent(any(PaymentDetailsEntered.class), any());
}
use of uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity in project pay-connector by alphagov.
the class HistoricalEventEmitterServiceTest method executeShouldEmitUserEmailCollectedEventWhenEnteringCardDetailsStateExists.
@Test
public void executeShouldEmitUserEmailCollectedEventWhenEnteringCardDetailsStateExists() {
ChargeEventEntity firstEvent = ChargeEventEntityFixture.aValidChargeEventEntity().withTimestamp(ZonedDateTime.now().plusMinutes(1)).withCharge(chargeEntity).withChargeStatus(ChargeStatus.ENTERING_CARD_DETAILS).build();
chargeEntity.getEvents().add(firstEvent);
when(chargeDao.findMaxId()).thenReturn(1L);
when(chargeDao.findById(1L)).thenReturn(Optional.of(chargeEntity));
historicalEventEmitterService.emitHistoricEventsById(1L, OptionalLong.empty(), 1L);
verify(eventService, times(1)).emitAndRecordEvent(any(BackfillerRecreatedUserEmailCollected.class), isNotNull());
}
Aggregations