public final class ChangeSlug extends UpdateActionImpl<T>
See also ProductUpdateCommand.
withUpdateableProduct(client(), product -> { final LocalizedString oldSlug = product.getMasterData().getStaged().getSlug(); final LocalizedString newSlug = LocalizedString.ofEnglish("new-slug-" + RANDOM.nextInt()); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, ChangeSlug.of(newSlug))); assertThat(updatedProduct.getMasterData().getStaged().getSlug()).isEqualTo(newSlug); //query message assertEventually(() -> { final Query<ProductSlugChangedMessage> query = MessageQuery.of() .withPredicates(m -> m.resource().is(product)) .forMessageType(ProductSlugChangedMessage.MESSAGE_HINT); final List<ProductSlugChangedMessage> results = client().executeBlocking(query).getResults(); assertThat(results).hasSize(1); final ProductSlugChangedMessage message = results.get(0); assertThat(message.getSlug()).isEqualTo(newSlug); assertThat(message.getOldSlug()).isEqualTo(oldSlug); }); return updatedProduct; });
See the test code.
Modifier and Type | Method and Description |
---|---|
LocalizedString |
getSlug() |
Boolean |
isStaged() |
static ChangeSlug |
of(LocalizedString slug) |
static ChangeSlug |
of(LocalizedString slug,
Boolean staged) |
getAction
public static ChangeSlug of(LocalizedString slug)
public static ChangeSlug of(LocalizedString slug, @Nullable Boolean staged)
public LocalizedString getSlug()