public final class RemoveAddress extends UpdateActionImpl<Customer>
See also CustomerInStoreUpdateCommand.
withCustomerWithOneAddress(client(), customer -> { final Address oldAddress = customer.getAddresses().get(0); assertThat(oldAddress.getId()) .overridingErrorMessage("only fetched address contains an ID") .isNotNull(); final RemoveAddress action = RemoveAddress.of(oldAddress); final Customer customerWithoutAddresses = client().executeBlocking(CustomerUpdateCommand.of(customer, action)); assertThat(customerWithoutAddresses.getAddresses()).isEmpty(); Query<CustomerAddressRemovedMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(customer)) .withSort(m -> m.createdAt().sort().desc()) .withLimit(1L) .forMessageType(CustomerAddressRemovedMessage.MESSAGE_HINT); assertEventually(() -> { final PagedQueryResult<CustomerAddressRemovedMessage> queryResult = client().executeBlocking(messageQuery); assertThat(queryResult.head()).isPresent(); final CustomerAddressRemovedMessage message = queryResult.head().get(); assertThat(message.getAddress()).isEqualTo(oldAddress); }); });
See the test code.
Customer
Modifier and Type | Method and Description |
---|---|
String |
getAddressId() |
String |
getAddressKey() |
static RemoveAddress |
of(Address address) |
static RemoveAddress |
of(String addressId) |
static RemoveAddress |
ofKey(String addressKey) |
getAction
public static RemoveAddress of(String addressId)
public static RemoveAddress ofKey(String addressKey)
public static RemoveAddress of(Address address)
public String getAddressId()
public String getAddressKey()