@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(); }