public final class SetDefaultShippingAddress extends UpdateActionImpl<Customer>
See also CustomerInStoreUpdateCommand.
withCustomerWithOneAddress(client(), customer -> {
final Address address = customer.getAddresses().get(0);
assertThat(address.getId())
.overridingErrorMessage("only fetched address contains an ID")
.isNotNull();
assertThat(customer.getDefaultShippingAddressId()).isNull();
assertThat(customer.findDefaultShippingAddress()).isEmpty();
final Customer updatedCustomer =
client().executeBlocking(CustomerUpdateCommand.of(customer, SetDefaultShippingAddress.ofAddress(address)));
assertThat(updatedCustomer.getDefaultShippingAddressId()).contains(address.getId());
assertThat(updatedCustomer.findDefaultShippingAddress()).contains(address);
return updatedCustomer;
});
See the test code.
Customer
Modifier and Type | Method and Description |
---|---|
String |
getAddressId() |
String |
getAddressKey() |
static SetDefaultShippingAddress |
of(String addressId) |
static SetDefaultShippingAddress |
ofAddress(Address address) |
static SetDefaultShippingAddress |
ofKey(String addressKey) |
getAction
public static SetDefaultShippingAddress ofKey(String addressKey)
public static SetDefaultShippingAddress of(String addressId)
public static SetDefaultShippingAddress ofAddress(Address address)