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()));
}
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();
}
Aggregations