public final class AddToCategory extends UpdateActionImpl<T>
See also ProductUpdateCommand.
withProductAndUnconnectedCategory(client(), (final Product product, final Category category) -> { assertThat(product.getMasterData().getStaged().getCategories()).isEmpty(); final String orderHint = "0.123"; final Product productWithCategory = client() .executeBlocking(ProductUpdateCommand.of(product, AddToCategory.of(category, orderHint))); final Reference<Category> categoryReference = productWithCategory.getMasterData().getStaged().getCategories().stream().findAny().get(); assertThat(categoryReference.referencesSameResource(category)).isTrue(); assertThat(productWithCategory.getMasterData().getStaged().getCategoryOrderHints().get(category.getId())).isEqualTo(orderHint); final Product productWithoutCategory = client() .executeBlocking(ProductUpdateCommand.of(productWithCategory, RemoveFromCategory.of(category))); assertThat(productWithoutCategory.getMasterData().getStaged().getCategories()).isEmpty(); });
See the test code.
Modifier and Type | Method and Description |
---|---|
ResourceIdentifier<Category> |
getCategory() |
String |
getOrderHint() |
Boolean |
isStaged() |
static AddToCategory |
of(Referenceable<Category> category) |
static AddToCategory |
of(Referenceable<Category> category,
Boolean staged) |
static AddToCategory |
of(Referenceable<Category> category,
String orderHint) |
static AddToCategory |
of(Referenceable<Category> category,
String orderHint,
Boolean staged) |
static AddToCategory |
of(ResourceIdentifier<Category> category) |
static AddToCategory |
of(ResourceIdentifier<Category> category,
Boolean staged) |
static AddToCategory |
of(ResourceIdentifier<Category> category,
String orderHint) |
static AddToCategory |
of(ResourceIdentifier<Category> category,
String orderHint,
Boolean staged) |
getAction
public ResourceIdentifier<Category> getCategory()
public static AddToCategory of(Referenceable<Category> category)
public static AddToCategory of(Referenceable<Category> category, @Nullable Boolean staged)
public static AddToCategory of(Referenceable<Category> category, String orderHint)
public static AddToCategory of(Referenceable<Category> category, String orderHint, @Nullable Boolean staged)
public static AddToCategory of(ResourceIdentifier<Category> category)
public static AddToCategory of(ResourceIdentifier<Category> category, @Nullable Boolean staged)
public static AddToCategory of(ResourceIdentifier<Category> category, String orderHint)
public static AddToCategory of(ResourceIdentifier<Category> category, String orderHint, @Nullable Boolean staged)