public final class SetDateOfBirth extends UpdateActionImpl<Customer>
See also CustomerInStoreUpdateCommand.
withCustomer(client(), customer -> {
assertThat(customer.getDateOfBirth()).isNull();
final LocalDate dateOfBirth = LocalDate.now();
final Customer updatedCustomer =
client().executeBlocking(CustomerUpdateCommand.of(customer, SetDateOfBirth.of(dateOfBirth)));
assertThat(updatedCustomer.getDateOfBirth()).isEqualTo(dateOfBirth);
Query<CustomerDateOfBirthSetMessage> messageQuery = MessageQuery.of()
.withPredicates(m -> m.resource().is(customer))
.withSort(m -> m.createdAt().sort().desc())
.withLimit(1L)
.forMessageType(CustomerDateOfBirthSetMessage.MESSAGE_HINT);
assertEventually(() -> {
final PagedQueryResult<CustomerDateOfBirthSetMessage> queryResult = client().executeBlocking(messageQuery);
assertThat(queryResult.head()).isPresent();
final CustomerDateOfBirthSetMessage message = queryResult.head().get();
assertThat(message.getDateOfBirth()).isEqualTo(dateOfBirth);
});
});
See the test code.
Modifier and Type | Method and Description |
---|---|
LocalDate |
getDateOfBirth() |
static SetDateOfBirth |
of(LocalDate dateOfBirth) |
getAction
public static SetDateOfBirth of(@Nullable LocalDate dateOfBirth)