public interface PaymentCreateCommand extends DraftBasedCreateCommandDsl<Payment,PaymentDraft,PaymentCreateCommand>, MetaModelReferenceExpansionDsl<Payment,PaymentCreateCommand,PaymentExpansionModel<Payment>>
Payment
.
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.
PaymentDraft
,
Payment
Modifier and Type | Method and Description |
---|---|
static PaymentCreateCommand |
of(PaymentDraft draft)
Creates a command object to create a
Payment . |
getDraft, withDraft
canDeserialize, deserialize, httpRequestIntent
plusExpansionPaths, withExpansionPaths
plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, withExpansionPaths, withExpansionPaths, withExpansionPaths, withExpansionPaths
expansionPaths
static PaymentCreateCommand of(PaymentDraft draft)
Payment
.draft
- template to create the new object