@Test
public void revertStagedChanges() throws Exception {
withUpdateableProduct(client(), product -> {
final LocalizedString oldDescriptionOption = product.getMasterData().getStaged().getDescription();
final LocalizedString newDescription = LocalizedString.ofEnglish("new description " + RANDOM.nextInt());
final ProductUpdateCommand cmd = ProductUpdateCommand.of(product, asList(Publish.of(), SetDescription.of(newDescription)));
final Product updatedProduct = client().executeBlocking(cmd);
assertThat(oldDescriptionOption).isNotEqualTo(newDescription);
assertThat(updatedProduct.getMasterData().getStaged().getDescription()).isEqualTo(newDescription);
assertThat(updatedProduct.getMasterData().getCurrent().getDescription()).isEqualTo(oldDescriptionOption);
final Product revertedProduct = client().executeBlocking(ProductUpdateCommand.of(updatedProduct, RevertStagedChanges.of()));
assertThat(revertedProduct.getMasterData().getStaged().getDescription()).isEqualTo(oldDescriptionOption);
assertThat(revertedProduct.getMasterData().getCurrent().getDescription()).isEqualTo(oldDescriptionOption);
return revertedProduct;
});
}