public final class AddShoppingList extends UpdateActionImpl<Cart>
See also CartInStoreUpdateCommand.
withEmptyCartAndProduct(client(), (cart, product) -> {
assertThat(cart.getLineItems()).isEmpty();
final List<io.sphere.sdk.shoppinglists.LineItemDraft> lineItemDrafts = asList(
LineItemDraftBuilder.of(product.getId()).quantity(1L).build(),
LineItemDraftBuilder.of(product.getId()).quantity(2L).build(),
LineItemDraftBuilder.of(product.getId()).quantity(3L).build());
final ShoppingListDraftDsl shoppingListDraft = newShoppingListDraftBuilder().lineItems(lineItemDrafts).build();
withShoppingList(client(), shoppingListDraft, shoppingList -> {
final Cart updatedCart = client().executeBlocking(
CartUpdateCommand.of(cart, AddShoppingList.of(shoppingList.toReference())));
final List<LineItem> lineItems = updatedCart.getLineItems();
assertThat(lineItems.size()).isEqualTo(1);
final LineItem lineItem = lineItems.get(0);
assertThat(lineItem.getQuantity()).isEqualTo(6);
assertThat(lineItem.getProductId()).isEqualTo(product.getId());
return shoppingList;
});
});
See the test code.
Modifier and Type | Method and Description |
---|---|
Reference<Channel> |
getDistributionChannel() |
Reference<ShoppingList> |
getShoppingList() |
Reference<Channel> |
getSupplyChannel() |
static AddShoppingList |
of(Reference<ShoppingList> shoppingList) |
AddShoppingList |
withDistributionChannel(Reference<Channel> distributionChannel) |
AddShoppingList |
withSupplyChannel(Reference<Channel> supplyChannel) |
getAction
public Reference<ShoppingList> getShoppingList()
public static AddShoppingList of(Reference<ShoppingList> shoppingList)
public AddShoppingList withSupplyChannel(@Nullable Reference<Channel> supplyChannel)
public AddShoppingList withDistributionChannel(@Nullable Reference<Channel> distributionChannel)