public CategoryDraftDsl withKey(@Nullable final String key) { return newBuilder().key(key).build(); }
final LocalizedString slug = LocalizedString.of(GERMAN, columns[3]).plus(ENGLISH, columns[5]); final String externalId = columns[0]; final CategoryDraftBuilder categoryDraftBuilder = CategoryDraftBuilder.of(name, slug).externalId(externalId).key(randomKey()); final String externalIdParent = columns[1]; if (!"".equals(externalIdParent)) {
public static void withCategoryAndParentCategory(final BlockingSphereClient client, final BiConsumer<Category, Category> consumer) { withCategory(client, parent -> withCategory(client, CategoryDraftBuilder.of(randomSlug(), randomSlug()).key(randomKey()).parent(parent), category -> { consumer.accept(category, parent); }) ); }
@Test public void referenceExpansionForDeletionByKey() throws Exception { final String key = randomKey(); final Category parent = client().executeBlocking(CategoryCreateCommand.of(CategoryDraftBuilder.of(randomLocalizedString(), randomSlug()).build())); final Category category = client().executeBlocking(CategoryCreateCommand.of(CategoryDraftBuilder.of(randomLocalizedString(), randomSlug()).key(key).parent(parent).build())); final CategoryDeleteCommand deleteCommand = CategoryDeleteCommand.ofKey(key, category.getVersion()).plusExpansionPaths(m -> m.parent()); final Category deletedCategory = client().executeBlocking(deleteCommand); assertThat(deletedCategory.getParent().getObj()).isNotNull().isEqualTo(parent); client().executeBlocking(CategoryDeleteCommand.of(parent)); } }
@Test public void executionForDeletionByKey() throws Exception { final String key = randomKey(); final CategoryDraft draft = CategoryDraftBuilder.of(randomLocalizedString(), randomSlug()).key(key).build(); final Category category = client().executeBlocking(CategoryCreateCommand.of(draft)); client().executeBlocking(CategoryDeleteCommand.ofKey(key,category.getVersion())); assertThat(client().executeBlocking(CategoryQuery.of().byId(category.getId())).head()).isEmpty(); }