@Override public Reference<ProductType> getProductType() { return product.getProductType(); }
@Override public Reference<ProductType> getProductType() { return product.getProductType(); }
@Override public Reference<ProductType> getProductType() { return product.getProductType(); }
@Override public Reference<ProductType> getProductType() { return product.getProductType(); }
@Override public Reference<ProductType> getProductType() { return product.getProductType(); }
@Test public void queryByProductType() throws Exception { with2products("queryByProductType", (p1, p2) ->{ final Query<ProductProjection> query = ProductProjectionQuery.of(STAGED) .byProductType(p1.getProductType()) .withExpansionPaths(m -> m.productType()); final PagedQueryResult<ProductProjection> queryResult = client().executeBlocking(query); assertThat(queryResult.head().get().getProductType()).is(expanded()); assertThat(ids(queryResult)).containsOnly(p1.getId()); }); }
@Test public void createProductByProductTypeKeyIdentifiable() { withEmptyProductType(client(), productType -> { final ProductVariantDraft masterVariant = ProductVariantDraftBuilder.of().build(); final ResourceIdentifiable<ProductType> productTypeResourceIdentifier = productType; final ProductDraft productDraft = ProductDraftBuilder.of(productTypeResourceIdentifier, randomSlug(), randomSlug(), masterVariant).build(); final Product product = client().executeBlocking(ProductCreateCommand.of(productDraft)); assertThat(product.getProductType()).isEqualTo(productType.toReference()); client().executeBlocking(ProductDeleteCommand.of(product)); }); }
@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 createProductByJsonDraft() throws Exception { final JsonNodeReferenceResolver referenceResolver = new JsonNodeReferenceResolver(); withCategory(client(), category -> { withProductType(client(), randomKey(), productType -> { withTaxCategory(client(), taxCategory -> { withStateByBuilder(client(), stateBuilder -> stateBuilder.initial(true).type(StateType.PRODUCT_STATE), state -> { referenceResolver.addResourceByKey("t-shirt-category", category); referenceResolver.addResourceByKey("t-shirt-product-type", productType); referenceResolver.addResourceByKey("standard-tax", taxCategory); referenceResolver.addResourceByKey("initial-product-state", state); final ProductDraft productDraft = draftFromJsonResource("drafts-tests/product.json", ProductDraft.class, referenceResolver); final Product product = client().executeBlocking(ProductCreateCommand.of(productDraft)); assertThat(product.getProductType()).isEqualTo(productType.toReference()); assertThat(product.getTaxCategory()).isEqualTo(taxCategory.toReference()); assertThat(product.getState()).isEqualTo(state.toReference()); final ProductData productData = product.getMasterData().getStaged(); assertThat(productData.getName()).isEqualTo(LocalizedString.ofEnglish("red shirt")); assertThat(productData.getCategories()).extracting("id").contains(category.getId()); client().executeBlocking(ProductDeleteCommand.of(product)); }); }); }); }); }
s.assertThat(lineItem1.getProductId()).isEqualTo(product1.getId()); s.assertThat(lineItem1.getQuantity()).isEqualTo(15); s.assertThat(lineItem1.getProductType()).isEqualTo(product1.getProductType()); s.assertThat(lineItem1.getProductType().getObj()).isNotNull();