public final class PaymentCreatedMessage extends GenericMessageImpl<Payment>
PaymentCreateCommand
.
CustomerFixtures.withCustomerAndCart(client(), ((customer, cart) -> { final MonetaryAmount totalAmount = cart.getTotalPrice(); final PaymentMethodInfo paymentMethodInfo = PaymentMethodInfoBuilder.of() .paymentInterface("payment interface X") .method("CREDIT_CARD") .build(); final PaymentDraftBuilder paymentDraftBuilder = PaymentDraftBuilder.of(totalAmount) .customer(customer) .paymentMethodInfo(paymentMethodInfo) ; final Payment payment = client().executeBlocking(PaymentCreateCommand.of(paymentDraftBuilder.build())); assertThat(payment.getCustomer()).isEqualTo(payment.getCustomer()); assertThat(payment.getPaymentMethodInfo()).isEqualTo(paymentMethodInfo); Assertions.assertThat(payment.getAmountPlanned()).isEqualTo(totalAmount); assertEventually(() -> { final PagedQueryResult<PaymentCreatedMessage> pagedQueryResult = client().executeBlocking(MessageQuery.of() .withPredicates(m -> m.resource().is(payment)) .forMessageType(PaymentCreatedMessage.MESSAGE_HINT)); assertThat(pagedQueryResult.head()).isPresent(); final PaymentCreatedMessage paymentCreatedMessage = pagedQueryResult.head().get(); assertThat(paymentCreatedMessage.getPayment().getId()).isEqualTo(payment.getId()); assertThat(paymentCreatedMessage.getResource().getId()).isEqualTo(payment.getId()); }); client().executeBlocking(PaymentDeleteCommand.of(payment)); }));
See the test code.
Payment
,
PaymentCreateCommand
Modifier and Type | Field and Description |
---|---|
static MessageDerivateHint<PaymentCreatedMessage> |
MESSAGE_HINT |
static String |
MESSAGE_TYPE |
resource, resourceUserProvidedIdentifiers, resourceVersion, sequenceNumber, type
Modifier and Type | Method and Description |
---|---|
Payment |
getPayment()
Gets the payment at creation time
|
as, equals, getPayload, getResource, getResourceUserProvidedIdentifiers, getResourceVersion, getSequenceNumber, getType, hashCode, toReference
getCreatedAt, getId, getLastModifiedAt, getVersion
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
referenceOfId, referenceTypeId, typeReference
getCreatedAt, getId, getLastModifiedAt, getVersion
hasSameIdAs, toResourceIdentifier
public static final String MESSAGE_TYPE
public static final MessageDerivateHint<PaymentCreatedMessage> MESSAGE_HINT
public Payment getPayment()