Search in sources :

Example 1 with PaymentNotificationCreated

use of uk.gov.pay.connector.events.model.charge.PaymentNotificationCreated 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)

Example 2 with PaymentNotificationCreated

use of uk.gov.pay.connector.events.model.charge.PaymentNotificationCreated in project pay-connector by alphagov.

the class QueueMessageContractTest method verifyPaymentNotificationCreatedEvent.

@PactVerifyProvider("a payment notification created message")
public String verifyPaymentNotificationCreatedEvent() throws JsonProcessingException {
    ExternalMetadata externalMetadata = new ExternalMetadata(Map.of("processor_id", "processorId", "auth_code", "012345", "telephone_number", "+447700900796", "status", "success", "authorised_date", "2018-02-21T16:05:33Z", "created_date", "2018-02-21T15:05:13Z"));
    ChargeEntity charge = aValidChargeEntity().withStatus(ChargeStatus.PAYMENT_NOTIFICATION_CREATED).withGatewayTransactionId("providerId").withEmail("j.doe@example.org").withSource(CARD_EXTERNAL_TELEPHONE).withCardDetails(anAuthCardDetails().withAddress(null).getCardDetailsEntity()).withExternalMetadata(externalMetadata).build();
    ChargeEventEntity chargeEventEntity = aValidChargeEventEntity().withCharge(charge).build();
    PaymentNotificationCreated paymentNotificationCreated = PaymentNotificationCreated.from(chargeEventEntity);
    return paymentNotificationCreated.toJsonString();
}
Also used : ChargeEntityFixture.aValidChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity) ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) ChargeEventEntity(uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity) ChargeEventEntityFixture.aValidChargeEventEntity(uk.gov.pay.connector.pact.ChargeEventEntityFixture.aValidChargeEventEntity) PaymentNotificationCreated(uk.gov.pay.connector.events.model.charge.PaymentNotificationCreated) ExternalMetadata(uk.gov.service.payments.commons.model.charge.ExternalMetadata) PactVerifyProvider(au.com.dius.pact.provider.PactVerifyProvider)

Aggregations

ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)2 ChargeEventEntity (uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity)2 PaymentNotificationCreated (uk.gov.pay.connector.events.model.charge.PaymentNotificationCreated)2 PactVerifyProvider (au.com.dius.pact.provider.PactVerifyProvider)1 Test (org.junit.Test)1 ChargeEntityFixture.aValidChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity)1 PaymentNotificationCreatedEventDetails (uk.gov.pay.connector.events.eventdetails.charge.PaymentNotificationCreatedEventDetails)1 Event (uk.gov.pay.connector.events.model.Event)1 ChargeEventEntityFixture.aValidChargeEventEntity (uk.gov.pay.connector.pact.ChargeEventEntityFixture.aValidChargeEventEntity)1 PaymentStateTransition (uk.gov.pay.connector.queue.statetransition.PaymentStateTransition)1 ExternalMetadata (uk.gov.service.payments.commons.model.charge.ExternalMetadata)1