public static ChangeLineItemQuantity of(final String lineItemId, final long quantity) { return of(lineItemId, quantity, null, null); }
public static ChangeLineItemQuantity of(final String lineItemId, final long quantity) { return of(lineItemId, quantity, null, null); }
public static ChangeLineItemQuantity ofLineItemAndExternalPrice(final String lineItemId, final long quantity, @Nullable final MonetaryAmount externalPrice) { return of(lineItemId, quantity, externalPrice, null); }
public static ChangeLineItemQuantity ofLineItemAndExternalPrice(final String lineItemId, final long quantity, @Nullable final MonetaryAmount externalPrice) { return of(lineItemId, quantity, externalPrice, null); }
public static ChangeLineItemQuantity ofLineItemAndExternalTotalPrice(final String lineItemId, final long quantity, @Nullable final ExternalLineItemTotalPrice externalTotalPrice) { return of(lineItemId, quantity, null, externalTotalPrice); }
public static ChangeLineItemQuantity ofLineItemAndExternalTotalPrice(final String lineItemId, final long quantity, @Nullable final ExternalLineItemTotalPrice externalTotalPrice) { return of(lineItemId, quantity, null, externalTotalPrice); }
public static UpdateAction<Cart> of(final LineItem lineItem, final int quantity) { return of(lineItem.getId(), quantity); } }
public static UpdateAction<Cart> of(final LineItem lineItem, final long quantity) { return of(lineItem.getId(), quantity); } }
public static UpdateAction<Cart> of(final LineItem lineItem, final long quantity) { return of(lineItem.getId(), quantity); } }
public static UpdateAction<Cart> of(final LineItem lineItem, final long quantity) { return of(lineItem.getId(), quantity); }
public static UpdateAction<Cart> of(final LineItem lineItem, final long quantity) { return of(lineItem.getId(), quantity); }
protected CompletionStage<Cart> changeLineItemQuantity(final Cart cart, final String lineItemId, final long quantity) { final ChangeLineItemQuantity changeLineItemQuantity = ChangeLineItemQuantity.of(lineItemId, quantity); final CartUpdateCommand cmd = CartUpdateCommand.of(cart, changeLineItemQuantity); return executeCartUpdateCommandWithHooks(cmd); } }
@Test public void changeLineItemQuantity() throws Exception { withEmptyCartAndProduct(client(), (cart, product) -> { assertThat(cart.getLineItems()).hasSize(0); final AddLineItem action = AddLineItem.of(product.getId(), MASTER_VARIANT_ID, 3L); final Cart cartWith3 = client().executeBlocking(CartUpdateCommand.of(cart, action)); final LineItem lineItem = cartWith3.getLineItems().get(0); assertThat(lineItem.getQuantity()).isEqualTo(3); final Cart cartWith2 = client().executeBlocking(CartUpdateCommand.of(cartWith3, ChangeLineItemQuantity.of(lineItem, 2L))); assertThat(cartWith2.getLineItems().get(0).getQuantity()).isEqualTo(2); final Cart cartWith0 = client().executeBlocking(CartUpdateCommand.of(cartWith2, ChangeLineItemQuantity.of(lineItem, 0L))); assertThat(cartWith0.getLineItems()).hasSize(0); }); }
@Test public void changeLineItemQuantityWithoutExternalTotalPrice() throws Exception { withEmptyCartAndProduct(client(), (cart, product) -> { assertThat(cart.getLineItems()).hasSize(0); final MonetaryAmount price = EURO_1; final MonetaryAmount totalPrice = EURO_5; final ExternalLineItemTotalPrice externalTotalPrice = ExternalLineItemTotalPrice.ofPriceAndTotalPrice(price, totalPrice); final AddLineItem action = AddLineItem.of(product.getId(), MASTER_VARIANT_ID, 3L).withExternalTotalPrice(externalTotalPrice); final Cart cartWith3 = client().executeBlocking(CartUpdateCommand.of(cart, action)); final LineItem lineItem = cartWith3.getLineItems().get(0); assertThat(lineItem.getQuantity()).isEqualTo(3); assertThat(lineItem.getPriceMode()).isEqualTo(EXTERNAL_TOTAL); assertThat(lineItem.getTotalPrice()).isEqualTo(totalPrice); assertThat(lineItem.getPrice().getValue()).isEqualTo(price); final Cart cartWith2 = client().executeBlocking(CartUpdateCommand.of(cartWith3, ChangeLineItemQuantity.of(lineItem, 2L))); final LineItem updatedLineItem = cartWith2.getLineItems().get(0); assertThat(updatedLineItem.getQuantity()).isEqualTo(2); assertThat(updatedLineItem.getPriceMode()).isEqualTo(PLATFORM); assertThat(updatedLineItem.getPrice().getValue()).isEqualTo(MoneyImpl.ofCents(1234, EUR)); }); }