public final class SetCartPredicate extends UpdateActionImpl<DiscountCode>
See also DiscountCodeUpdateCommand.
withPersistentDiscountCode(client(), discountCode -> { final String predicateAsString = //you need to change the predicate Optional.ofNullable(discountCode.getCartPredicate()).map(p -> "1 = 1".equals(p)).orElse(false) ? "true = true" : "1 = 1"; final CartPredicate cartPredicate = CartPredicate.of(predicateAsString); final DiscountCode updatedDiscountCode = client().executeBlocking(DiscountCodeUpdateCommand.of(discountCode, SetCartPredicate.of(cartPredicate))); assertThat(updatedDiscountCode.getCartPredicate()).contains(cartPredicate.toSphereCartPredicate()); });
See the test code.
Modifier and Type | Method and Description |
---|---|
String |
getCartPredicate() |
static SetCartPredicate |
of(CartPredicate cartPredicate) |
getAction
public static SetCartPredicate of(@Nullable CartPredicate cartPredicate)