@Test public void productType() throws Exception { final Consumer<Product> user = product -> { final Query<Product> query = ProductQuery.of(). bySlug(ProductProjectionType.CURRENT, Locale.ENGLISH, englishSlugOf(product.getMasterData().getStaged())). withExpansionPaths(ProductExpansionModel.of().productType()). toQuery(); final PagedQueryResult<Product> queryResult = client().executeBlocking(query); final Reference<ProductType> productTypeReference = queryResult.head().get().getProductType(); assertThat(productTypeReference).is(expanded()); }; withProduct(client(), "productTypeReferenceExpansion", user); }
@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()); }) ); } }