public final class SetCustomerGroup extends UpdateActionImpl<Customer>
See also CustomerInStoreUpdateCommand.
withB2cCustomerGroup(client(), customerGroup -> {
withCustomer(client(), customer -> {
assertThat(customer.getCustomerGroup()).isNull();
final Customer updateCustomer = client().executeBlocking(CustomerUpdateCommand.of(customer, SetCustomerGroup.of(customerGroup)));
assertThat(updateCustomer.getCustomerGroup()).isEqualTo(customerGroup.toReference());
Query<CustomerGroupSetMessage> messageQuery = MessageQuery.of()
.withPredicates(m -> m.resource().is(customer))
.withSort(m -> m.createdAt().sort().desc())
.withLimit(1L)
.forMessageType(CustomerGroupSetMessage.MESSAGE_HINT);
assertEventually(() -> {
final PagedQueryResult<CustomerGroupSetMessage> queryResult = client().executeBlocking(messageQuery);
assertThat(queryResult.head()).isPresent();
final CustomerGroupSetMessage message = queryResult.head().get();
assertThat(message.getCustomerGroup()).isEqualTo(customerGroup.toReference());
});
});
});
See the test code.
Customer
Modifier and Type | Method and Description |
---|---|
ResourceIdentifier<CustomerGroup> |
getCustomerGroup() |
static SetCustomerGroup |
of(ResourceIdentifiable<CustomerGroup> customerGroup) |
getAction
public static SetCustomerGroup of(@Nullable ResourceIdentifiable<CustomerGroup> customerGroup)
@Nullable public ResourceIdentifier<CustomerGroup> getCustomerGroup()