@Test
public void createProductWithCustomPrice() {
withEmptyProductType(client(), randomKey(), productType ->
withUpdateableType(client(), type -> {
final String value = "foo";
final PriceDraft price = PriceDraft.of(EURO_1)
.withCustom(CustomFieldsDraft.ofTypeIdAndObjects(type.getId(), singletonMap(STRING_FIELD_NAME, value)));
final ProductVariantDraft masterVariant = ProductVariantDraftBuilder.of().price(price).build();
final ProductDraft productDraft = ProductDraftBuilder.of(productType, randomSlug(), randomSlug(), masterVariant).build();
final Product product = client().executeBlocking(ProductCreateCommand.of(productDraft));
final Price loadedPrice = product.getMasterData().getStaged().getMasterVariant().getPrices().get(0);
assertThat(loadedPrice.getValue()).isEqualTo(EURO_1);
assertThat(loadedPrice.getCustom().getFieldAsString(STRING_FIELD_NAME)).isEqualTo(value);
client().executeBlocking(ProductDeleteCommand.of(product));
return type;
})
);
}