public static SetTaxCategory to(final Referenceable<TaxCategory> taxCategory) { return of(taxCategory); } }
public static SetTaxCategory to(final Referenceable<TaxCategory> taxCategory) { return of(taxCategory); } }
public static SetTaxCategory to(final Referenceable<TaxCategory> taxCategory) { return of(taxCategory); }
public static SetTaxCategory unset() { return of(null); }
public static SetTaxCategory to(final Referenceable<TaxCategory> taxCategory) { return of(taxCategory); } }
public static SetTaxCategory to(final Referenceable<TaxCategory> taxCategory) { return of(taxCategory); }
public static SetTaxCategory unset() { return of(Optional.<Reference<TaxCategory>>empty()); }
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); }) ); } }
@Test public void taxCategory() throws Exception { TaxCategoryFixtures.withTransientTaxCategory(client(), taxCategory -> withProduct(client(), product -> { final Product productWithTaxCategory = client().executeBlocking(ProductUpdateCommand.of(product, SetTaxCategory.of(taxCategory))); assertThat(productWithTaxCategory.getTaxCategory()).isNotNull(); final Query<Product> query = ProductQuery.of(). bySlug(ProductProjectionType.CURRENT, Locale.ENGLISH, englishSlugOf(product.getMasterData().getStaged())). withExpansionPaths(ProductExpansionModel.of().taxCategory()). toQuery(); final PagedQueryResult<Product> queryResult = client().executeBlocking(query); final Reference<TaxCategory> productTypeReference = firstOf(queryResult).getTaxCategory(); assertThat(productTypeReference).is(expanded()); }) ); } }
@Test public void expandTaxCategory() throws Exception { TaxCategoryFixtures.withTransientTaxCategory(client(), taxCategory -> withProduct(client(), product -> { final Product productWithTaxCategory = client().executeBlocking(ProductUpdateCommand.of(product, SetTaxCategory.of(taxCategory))); final ProductProjectionQuery query = ProductProjectionQuery.of(STAGED) .withPredicates(m -> m.id().is(productWithTaxCategory.getId())) .withExpansionPaths(m -> m.taxCategory()); final PagedQueryResult<ProductProjection> pagedQueryResult = client().executeBlocking(query); assertThat(pagedQueryResult.head().get().getTaxCategory()).is(expanded()); }) ); }