public final class ChangeCartDiscounts extends UpdateActionImpl<DiscountCode>
See also DiscountCodeUpdateCommand.
withCartDiscount(client(), randomKey(), cartDiscount -> withPersistentDiscountCode(client(), discountCode -> { final List<Reference<CartDiscount>> oldCartDiscounts = discountCode.getCartDiscounts(); assertThat(oldCartDiscounts).doesNotContain(cartDiscount.toReference()); final List<Reference<CartDiscount>> newDiscountsList = listOf(oldCartDiscounts, cartDiscount.toReference()); final DiscountCode updatedDiscountCode = client().executeBlocking(DiscountCodeUpdateCommand.of(discountCode, ChangeCartDiscounts.of(newDiscountsList))); assertThat(updatedDiscountCode.getCartDiscounts()).isEqualTo(newDiscountsList); //clean up test client().executeBlocking(DiscountCodeUpdateCommand.of(updatedDiscountCode, ChangeCartDiscounts.of(oldCartDiscounts))); }) );
See the test code.
DiscountCode.getCartDiscounts()
Modifier and Type | Method and Description |
---|---|
List<Reference<CartDiscount>> |
getCartDiscounts() |
static ChangeCartDiscounts |
of(List<Reference<CartDiscount>> cartDiscounts) |
static ChangeCartDiscounts |
of(Referenceable<CartDiscount> cartDiscount) |
getAction
public static ChangeCartDiscounts of(Referenceable<CartDiscount> cartDiscount)
public static ChangeCartDiscounts of(List<Reference<CartDiscount>> cartDiscounts)
public List<Reference<CartDiscount>> getCartDiscounts()