public final class RemoveLineItem extends UpdateActionImpl<ShoppingList>
See also ShoppingListInStoreUpdateCommand.
withTaxedProduct(client(), product -> {
final ShoppingListDraftDsl shoppingListDraft = newShoppingListDraftWithLineItem(product, 3L);
withShoppingList(client(), shoppingListDraft, shoppingList -> {
final LineItem lineItem = shoppingList.getLineItems().get(0);
final ShoppingList shoppingListWithRemovedLineItem = client().executeBlocking(
ShoppingListUpdateCommand.of(shoppingList, RemoveLineItem.of(lineItem).withQuantity(2L)));
assertThat(shoppingListWithRemovedLineItem.getLineItems()).hasSize(1);
final LineItem updatedLineItem = shoppingListWithRemovedLineItem.getLineItems().get(0);
assertThat(updatedLineItem.getQuantity()).isEqualTo(1L);
final ShoppingList shoppingListWithoutLineItem = client().executeBlocking(
ShoppingListUpdateCommand.of(shoppingListWithRemovedLineItem, RemoveLineItem.of(lineItem).withQuantity(1L)));
assertThat(shoppingListWithoutLineItem.getLineItems()).isEmpty();
return shoppingListWithoutLineItem;
});
});
See the test code.
ShoppingList.getLineItems()
Modifier and Type | Method and Description |
---|---|
String |
getLineItemId() |
Long |
getQuantity() |
static RemoveLineItem |
of(LineItem lineItem) |
static RemoveLineItem |
of(String lineItemId) |
RemoveLineItem |
withQuantity(Long quantity) |
getAction
public static RemoveLineItem of(String lineItemId)
public static RemoveLineItem of(LineItem lineItem)
public String getLineItemId()
public RemoveLineItem withQuantity(@Nullable Long quantity)