public static SetTaxCategory to(final Referenceable<TaxCategory> taxCategory) { return of(taxCategory); } }
public static SetTaxCategory unset() { return new SetTaxCategory(null); }
public static SetTaxCategory to(final Referenceable<TaxCategory> taxCategory) { return of(taxCategory); } }
public static SetTaxCategory of(final Optional<Reference<TaxCategory>> taxCategory) { return new SetTaxCategory(taxCategory); }
public static SetTaxCategory to(final Referenceable<TaxCategory> taxCategory) { return of(taxCategory); } }
public static SetTaxCategory unset() { return new SetTaxCategory(null); }
public static SetTaxCategory to(final Referenceable<TaxCategory> taxCategory) { return of(taxCategory); }
public static SetTaxCategory of(final Optional<Reference<TaxCategory>> taxCategory) { return new SetTaxCategory(taxCategory); }
public static SetTaxCategory unset() { return of(null); }
public static SetTaxCategory of(@Nullable final Referenceable<TaxCategory> taxCategory) { return new SetTaxCategory(Optional.ofNullable(taxCategory).map(Referenceable::toResourceIdentifier).orElse(null)); }
public static SetTaxCategory to(final Referenceable<TaxCategory> taxCategory) { return of(taxCategory); }
public static SetTaxCategory of(@Nullable final Referenceable<TaxCategory> taxCategory) { return new SetTaxCategory(Optional.ofNullable(taxCategory).map(Referenceable::toResourceIdentifier).orElse(null)); }
public static SetTaxCategory unset() { return of(Optional.<Reference<TaxCategory>>empty()); }
public static SetTaxCategory of(@Nullable final Referenceable<TaxCategory> taxCategory) { return new SetTaxCategory(Optional.ofNullable(taxCategory).map(t -> t.toReference()).orElse(null)); }
public static SetTaxCategory unset() { return of(Optional.<Reference<TaxCategory>>empty()); }
public static SetTaxCategory of(final Referenceable<TaxCategory> taxCategory) { return of(Optional.of(taxCategory.toReference())); }
public static SetTaxCategory of(final Referenceable<TaxCategory> taxCategory) { return of(Optional.of(taxCategory.toReference())); }
private static ProductUpdateCommand createSetTaxesCommand(final TaxCategory taxCategory, final Product product) { return ProductUpdateCommand.of(product, asList(AddPrice.of(MASTER_VARIANT_ID, PRICE), SetTaxCategory.of(taxCategory), Publish.of())); }
@Test public void setTaxCategory() throws Exception { TaxCategoryFixtures.withTransientTaxCategory(client(), taxCategory -> withUpdateableProduct(client(), product -> { assertThat(product.getTaxCategory()).isNotEqualTo(taxCategory); final ProductUpdateCommand command = ProductUpdateCommand.of(product, SetTaxCategory.of(taxCategory)); final Product updatedProduct = client().executeBlocking(command); assertThat(updatedProduct.getTaxCategory()).isEqualTo(taxCategory.toReference()); return updatedProduct; }) ); }
private static void withTaxedAndPricedProduct(final BlockingSphereClient client, final long centAmount, final double taxRate, final boolean taxIncluded, final Consumer<Product> operator) { final List<TaxRateDraft> taxRateDrafts = singletonList(TaxRateDraftBuilder.of(randomKey(), taxRate, taxIncluded, CountryCode.DE).build()); final TaxCategoryDraft taxCategoryDraft = TaxCategoryDraft.of(randomString(), taxRateDrafts); withTaxCategory(client, taxCategoryDraft, taxCategory -> withProduct(client, product -> { final PriceDraft priceDraft = PriceDraft.of(MoneyImpl.ofCents(centAmount, EUR)).withCountry(DE); final ProductUpdateCommand setPricesCmd = ProductUpdateCommand.of(product, asList( AddPrice.of(MASTER_VARIANT_ID, priceDraft), SetTaxCategory.of(taxCategory), Publish.of())); final Product productWithPrice = client.executeBlocking(setPricesCmd); operator.accept(productWithPrice); }) ); } }