protected void fillName(final ProductProjection product, final ProductVariantBean bean) { bean.setName(createName(product.getName())); }
@Test public void transformProductIntoProductProjection() throws Exception { final Product product = getProduct(); final ProductProjection staged = product.toProjection(ProductProjectionType.STAGED); assertThat(staged).overridingErrorMessage("staged is always present").isNotNull(); assertThat(staged.getName()).isEqualTo(product.getMasterData().getStaged().getName()); final ProductProjection current = product.toProjection(ProductProjectionType.CURRENT); assertThat(current).overridingErrorMessage("current can be empty").isNull(); }
@Test public void differentiateBetweenCurrentAndStaged() throws Exception { withUpdateableProduct(client(), product -> { final Product publishedProduct = client().executeBlocking(ProductUpdateCommand.of(product, Publish.of())); final Product mixedDataProduct = client().executeBlocking(ProductUpdateCommand.of(publishedProduct, ChangeName.of(randomSlug()))); final LocalizedString nameInCurrent = mixedDataProduct.getMasterData().getCurrent().getName(); final LocalizedString nameInStaged = mixedDataProduct.getMasterData().getStaged().getName(); final ProductProjectionQuery stagedQuery = ProductProjectionQuery.of(STAGED).withPredicates(m -> m.id().is(product.getId())); assertThat(client().executeBlocking(stagedQuery).head().get().getName()).isEqualTo(nameInStaged); final ProductProjectionQuery currentQuery = ProductProjectionQuery.of(CURRENT).withPredicates(m -> m.id().is(product.getId())); assertThat(client().executeBlocking(currentQuery).head().get().getName()).isEqualTo(nameInCurrent); return mixedDataProduct; }); }