@Override protected TypeReference<Product> typeReference() { return Product.typeReference(); }
@Override protected JavaType jacksonJavaType() { return SphereJsonUtils.convertToJavaType(Product.typeReference()); }
@Override protected JavaType jacksonJavaType() { return SphereJsonUtils.convertToJavaType(Product.typeReference()); }
ProductDeleteCommandImpl(final Versioned<Product> versioned,final boolean eraseData) { super(versioned,eraseData, JsonEndpoint.of(Product.typeReference(), "/products"), ProductExpansionModel.of(), ProductDeleteCommandImpl::new); }
private Product getProduct() throws IOException { return SphereJsonUtils.readObjectFromResource("ProductProjectionTest/product.json", Product.typeReference()); }
@Test public void attributesForUnitTests() throws Exception { final Product referencedProduct = SphereJsonUtils.readObjectFromResource("product1.json", Product.typeReference()); final Reference<Product> productReference = referencedProduct.toReference(); assertThat(productReference.getObj()) .overridingErrorMessage("product reference is expanded") .isNotNull(); final AttributeAccess<Reference<Product>> access = AttributeAccess.ofProductReference(); final Attribute attribute = Attribute.of("attrname", access, productReference); assertThat(attribute.getValue(access)).isEqualTo(productReference); assertThat(attribute.getValue(access).getObj()).isNotNull(); }
@Test public void expandedDiscountedPrice() throws Exception { final Product product = SphereJsonUtils.readObjectFromResource("product-with-expanded-discounted-price.json", Product.typeReference()); final Price price = product.getMasterData().getStaged().getMasterVariant().getPrices().get(0); final DiscountedPrice discountedPrice = price.getDiscounted(); final ProductDiscount productDiscount = discountedPrice.getDiscount().getObj(); assertThat(productDiscount.getName().get(Locale.ENGLISH)).isEqualTo("demo product discount"); assertThat(productDiscount.getValue()).isInstanceOf(AbsoluteProductDiscountValue.class); }