Search in sources :

Example 6 with ChargeEventEntity

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));
}
Also used : ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) StateTransition(uk.gov.pay.connector.queue.statetransition.StateTransition) PaymentCreated(uk.gov.pay.connector.events.model.charge.PaymentCreated) Test(org.junit.Test)

Example 7 with ChargeEventEntity

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);
}
Also used : ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) ConnectorConfiguration(uk.gov.pay.connector.app.ConnectorConfiguration) CardDetailsEntity(uk.gov.pay.connector.charge.model.CardDetailsEntity) Before(org.junit.Before)

Example 8 with 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);
}
Also used : ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) Test(org.junit.Test)

Example 9 with ChargeEventEntity

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());
}
Also used : PaymentDetailsEntered(uk.gov.pay.connector.events.model.charge.PaymentDetailsEntered) ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) Test(org.junit.Test)

Example 10 with ChargeEventEntity

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());
}
Also used : BackfillerRecreatedUserEmailCollected(uk.gov.pay.connector.events.model.charge.BackfillerRecreatedUserEmailCollected) ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) Test(org.junit.Test)

Aggregations

ChargeEventEntity (uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity)62 Test (org.junit.Test)42 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)25 ChargeEntityFixture.aValidChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity)14 ZonedDateTime (java.time.ZonedDateTime)12 ChargeEventEntityBuilder.aChargeEventEntity (uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity.ChargeEventEntityBuilder.aChargeEventEntity)12 Event (uk.gov.pay.connector.events.model.Event)12 ChargeEventEntityFixture.aValidChargeEventEntity (uk.gov.pay.connector.pact.ChargeEventEntityFixture.aValidChargeEventEntity)11 Before (org.junit.Before)10 PaymentStateTransition (uk.gov.pay.connector.queue.statetransition.PaymentStateTransition)8 Auth3dsRequiredEntity (uk.gov.pay.connector.charge.model.domain.Auth3dsRequiredEntity)6 PactVerifyProvider (au.com.dius.pact.provider.PactVerifyProvider)5 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)4 LoggingEvent (ch.qos.logback.classic.spi.LoggingEvent)4 ConnectorConfiguration (uk.gov.pay.connector.app.ConnectorConfiguration)4 ChargeStatus (uk.gov.pay.connector.charge.model.domain.ChargeStatus)4 PaymentCreated (uk.gov.pay.connector.events.model.charge.PaymentCreated)4 PaymentDetailsEntered (uk.gov.pay.connector.events.model.charge.PaymentDetailsEntered)4 CardServiceTest (uk.gov.pay.connector.paymentprocessor.service.CardServiceTest)4 StateTransition (uk.gov.pay.connector.queue.statetransition.StateTransition)4