public final class SetCustomerId extends UpdateActionImpl<Cart>
Sets an existing customer ID for a cart.
The customer ID can be unset by callingof(String)
with null
.
See also CartInStoreUpdateCommand.
withCustomer(client(), customer -> { final Cart cart = createCartWithCountry(client()); assertThat(cart.getCustomerId()).isNull(); final Cart cartWithCustomerId = client().executeBlocking(CartUpdateCommand.of(cart, SetCustomerId.ofCustomer(customer))); assertThat(cartWithCustomerId.getCustomerId()).contains(customer.getId()); final Cart cartWithoutCustomerId = client().executeBlocking(CartUpdateCommand.of(cartWithCustomerId, SetCustomerId.empty())); assertThat(cartWithoutCustomerId.getCustomerId()).isNull(); });
See the test code.
Modifier and Type | Method and Description |
---|---|
static SetCustomerId |
empty() |
String |
getCustomerId() |
static SetCustomerId |
of(String customerId) |
static SetCustomerId |
ofCustomer(Referenceable<Customer> customer) |
getAction
public static SetCustomerId of(@Nullable String customerId)
public static SetCustomerId empty()
public static SetCustomerId ofCustomer(@Nullable Referenceable<Customer> customer)