public static RemovePayment of(final Referenceable<Payment> payment) { return new RemovePayment(Optional.ofNullable(payment).map(Referenceable::toReference).orElse(null)); }
@Test public void addPayment() { withPayment(client(), payment -> { withCart(client(), cart -> { //add payment final CartUpdateCommand command = CartUpdateCommand.of(cart, AddPayment.of(payment)) .withExpansionPaths(m -> m.paymentInfo().payments()); final Cart cartWithPayment = client().executeBlocking(command); final Reference<Payment> paymentReference = cartWithPayment.getPaymentInfo().getPayments().get(0); assertThat(paymentReference).isEqualTo(payment.toReference()); assertThat(paymentReference).is(expanded(payment)); //query cart by payment final CartQuery cartQuery = CartQuery.of() .withPredicates(m -> m.paymentInfo().payments().isIn(singletonList(payment))); assertThat(client().executeBlocking(cartQuery).head()).contains(cartWithPayment); //remove payment final Cart cartWithoutPayment = client().executeBlocking(CartUpdateCommand.of(cartWithPayment, RemovePayment.of(payment))); assertThat(cartWithoutPayment.getPaymentInfo()).isNull(); return cartWithoutPayment; }); return payment; }); }
public static RemovePayment of(final Referenceable<Payment> payment) { return new RemovePayment(Optional.ofNullable(payment).map(Referenceable::toReference).orElse(null)); }
public static RemovePayment of(final Referenceable<Payment> payment) { return new RemovePayment(Optional.ofNullable(payment).map(Referenceable::toReference).orElse(null)); }